From a8bbff7bdb7d4bf5ed13fb42669e53e4427428de Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Tue, 26 Jun 2018 21:28:31 +0200 Subject: linux-toradex-rt: forward port rt to use latest non rt kernel sources While at it use consistently the .xz compressed rt-patch file. Signed-off-by: Max Krummenacher Acked-by: Marcel Ziswiler --- ...rs-Forward-timer-base-before-migrating-ti.patch | 35 +++++++++ ...orward-timer-base-before-migrating-timers.patch | 88 ++++++++++++++++++++++ recipes-kernel/linux/linux-toradex-rt_4.4.bb | 12 +-- recipes-kernel/linux/linux-toradex-rt_4.9-1.0.x.bb | 8 +- 4 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0001-Revert-timers-Forward-timer-base-before-migrating-ti.patch create mode 100644 recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0003-timers-Forward-timer-base-before-migrating-timers.patch (limited to 'recipes-kernel/linux') diff --git a/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0001-Revert-timers-Forward-timer-base-before-migrating-ti.patch b/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0001-Revert-timers-Forward-timer-base-before-migrating-ti.patch new file mode 100644 index 0000000..7656ab6 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0001-Revert-timers-Forward-timer-base-before-migrating-ti.patch @@ -0,0 +1,35 @@ +From 4e529c1110601d9ecc941e74e6711f3aefa36f88 Mon Sep 17 00:00:00 2001 +From: Max Krummenacher +Date: Tue, 26 Jun 2018 20:41:38 +0200 +Subject: [PATCH 1/3] Revert "timers: Forward timer base before migrating + timers" + +Prepare to apply rt patch and reapply afterwards. + +This reverts commit 13e75c74cd69ca460778fad5ab902f0b20869267. + +Signed-off-by: Max Krummenacher +--- + kernel/time/timer.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/kernel/time/timer.c b/kernel/time/timer.c +index 7c477912f36d..2d5cc7dfee14 100644 +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -1884,12 +1884,6 @@ int timers_dead_cpu(unsigned int cpu) + spin_lock_irq(&new_base->lock); + spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); + +- /* +- * The current CPUs base clock might be stale. Update it +- * before moving the timers over. +- */ +- forward_timer_base(new_base); +- + BUG_ON(old_base->running_timer); + + for (i = 0; i < WHEEL_SIZE; i++) +-- +2.13.6 + diff --git a/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0003-timers-Forward-timer-base-before-migrating-timers.patch b/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0003-timers-Forward-timer-base-before-migrating-timers.patch new file mode 100644 index 0000000..a6c70d8 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-rt-4.9-1.0.x/0003-timers-Forward-timer-base-before-migrating-timers.patch @@ -0,0 +1,88 @@ +From 030a2d50079f1a8c6319fa6a026c03e43c3f87f6 Mon Sep 17 00:00:00 2001 +From: Lingutla Chandrasekhar +Date: Thu, 18 Jan 2018 17:20:22 +0530 +Subject: [PATCH 3/3] timers: Forward timer base before migrating timers + +commit c52232a49e203a65a6e1a670cd5262f59e9364a0 upstream. + +On CPU hotunplug the enqueued timers of the unplugged CPU are migrated to a +live CPU. This happens from the control thread which initiated the unplug. + +If the CPU on which the control thread runs came out from a longer idle +period then the base clock of that CPU might be stale because the control +thread runs prior to any event which forwards the clock. + +In such a case the timers from the unplugged CPU are queued on the live CPU +based on the stale clock which can cause large delays due to increased +granularity of the outer timer wheels which are far away from base:;clock. + +But there is a worse problem than that. The following sequence of events +illustrates it: + + - CPU0 timer1 is queued expires = 59969 and base->clk = 59131. + + The timer is queued at wheel level 2, with resulting expiry time = 60032 + (due to level granularity). + + - CPU1 enters idle @60007, with next timer expiry @60020. + + - CPU0 is hotplugged at @60009 + + - CPU1 exits idle and runs the control thread which migrates the + timers from CPU0 + + timer1 is now queued in level 0 for immediate handling in the next + softirq because the requested expiry time 59969 is before CPU1 base->clk + 60007 + + - CPU1 runs code which forwards the base clock which succeeds because the + next expiring timer. which was collected at idle entry time is still set + to 60020. + + So it forwards beyond 60007 and therefore misses to expire the migrated + timer1. That timer gets expired when the wheel wraps around again, which + takes between 63 and 630ms depending on the HZ setting. + +Address both problems by invoking forward_timer_base() for the control CPUs +timer base. All other places, which might run into a similar problem +(mod_timer()/add_timer_on()) already invoke forward_timer_base() to avoid +that. + +[ tglx: Massaged comment and changelog ] + +Fixes: a683f390b93f ("timers: Forward the wheel clock whenever possible") +Co-developed-by: Neeraj Upadhyay +Signed-off-by: Neeraj Upadhyay +Signed-off-by: Lingutla Chandrasekhar +Signed-off-by: Thomas Gleixner +Cc: Anna-Maria Gleixner +Cc: linux-arm-msm@vger.kernel.org +Cc: stable@vger.kernel.org +Link: https://lkml.kernel.org/r/20180118115022.6368-1-clingutla@codeaurora.org +Signed-off-by: Greg Kroah-Hartman + +(cherry picked from commit 13e75c74cd69ca460778fad5ab902f0b20869267) +--- + kernel/time/timer.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/kernel/time/timer.c b/kernel/time/timer.c +index ec0169f49c39..00f3db2c6cca 100644 +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -1919,6 +1919,12 @@ int timers_dead_cpu(unsigned int cpu) + raw_spin_lock_irq(&new_base->lock); + raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); + ++ /* ++ * The current CPUs base clock might be stale. Update it ++ * before moving the timers over. ++ */ ++ forward_timer_base(new_base); ++ + BUG_ON(old_base->running_timer); + + for (i = 0; i < WHEEL_SIZE; i++) +-- +2.13.6 + diff --git a/recipes-kernel/linux/linux-toradex-rt_4.4.bb b/recipes-kernel/linux/linux-toradex-rt_4.4.bb index 0a95e7f..1466da1 100644 --- a/recipes-kernel/linux/linux-toradex-rt_4.4.bb +++ b/recipes-kernel/linux/linux-toradex-rt_4.4.bb @@ -3,12 +3,14 @@ include conf/tdx_version.conf SUMMARY = "Linux kernel with real-time patch for Toradex Colibri VFxx Computer on Modules" -SRC_URI = "git://git.toradex.com/linux-toradex.git;protocol=git;branch=${SRCBRANCH} \ - https://www.kernel.org/pub/linux/kernel/projects/rt/4.4/patch-4.4.60-rt73.patch.xz \ - file://defconfig" +SRC_URI = " \ + git://git.toradex.com/linux-toradex.git;protocol=git;branch=${SRCBRANCH} \ + https://www.kernel.org/pub/linux/kernel/projects/rt/4.4/older/patch-4.4.138-rt155.patch.xz;name=rt-patch \ + file://defconfig \ +" -SRC_URI[md5sum] = "9084b5fe511383d0588a15d6034116cb" -SRC_URI[sha256sum] = "cbe77f8db27bae1d018b786bead3996c753f0e45fdec6dab088fbe2cffd0f890" +SRC_URI[rt-patch.md5sum] = "77d6867ad455e28225faafb8ceb999ea" +SRC_URI[rt-patch.sha256sum] = "f2e6b4bda77840ecbe7d2b30ad72ed6056c3562a4b5d25e4b15d7f377c81d342" KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains('COMBINED_FEATURES', 'usbgadget', ' libcomposite', '',d)}" diff --git a/recipes-kernel/linux/linux-toradex-rt_4.9-1.0.x.bb b/recipes-kernel/linux/linux-toradex-rt_4.9-1.0.x.bb index b27b6a3..7667061 100644 --- a/recipes-kernel/linux/linux-toradex-rt_4.9-1.0.x.bb +++ b/recipes-kernel/linux/linux-toradex-rt_4.9-1.0.x.bb @@ -4,13 +4,15 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/linux-toradex-rt-4.9-1.0.x:" SUMMARY = "Real-Time Linux kernel for Toradex Freescale i.MX based modules" SRC_URI += " \ - https://www.kernel.org/pub/linux/kernel/projects/rt/4.9/older/patch-4.9.84-rt62.patch.gz;name=rt-patch \ + file://0001-Revert-timers-Forward-timer-base-before-migrating-ti.patch \ + https://www.kernel.org/pub/linux/kernel/projects/rt/4.9/older/patch-4.9.84-rt62.patch.xz;name=rt-patch \ + file://0003-timers-Forward-timer-base-before-migrating-timers.patch \ file://0001-gpu-viv-enable-PREEMPT-RT-fixes.patch \ file://0002-mm-Work-around-the-oops-below-by-disabling-split-ptl.patch \ " -SRC_URI[rt-patch.md5sum] = "ff3eef7b14d02a689433e7a6849cae54" -SRC_URI[rt-patch.sha256sum] = "67dd6a689a9355093b98b52d8f26e22685462797765ee44c0893fee5860d383f" +SRC_URI[rt-patch.md5sum] = "c0c5e47f37c0b25dbab934c2a2e456bb" +SRC_URI[rt-patch.sha256sum] = "399c873031599e356231fcf5694c7a438fb1f9faaa9bedcc0df4ef13fd8efc80" SRCREV = "07d40f6ffcbb9b3db3c146f0949725752ed61b63" SRCBRANCH = "toradex_4.9-1.0.x-imx" -- cgit v1.2.3