From: Greg Kroah-Hartman Date: Tue, 3 Jun 2014 20:48:20 +0000 (-0700) Subject: 3.10-stable patches X-Git-Tag: v3.14.6~79 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=561c050a1a3f70fd80ead187831d151a6dc02236;p=thirdparty%2Fkernel%2Fstable-queue.git 3.10-stable patches added patches: drivercore-deferral-race-condition-fix.patch hrtimer-prevent-all-reprogramming-if-hang-detected.patch hrtimer-prevent-remote-enqueue-of-leftmost-timers.patch hrtimer-set-expiry-time-before-switch_hrtimer_base.patch hwmon-emc1403-fix-inverted-store_hyst.patch hwmon-emc1403-support-full-range-of-known-chip-revision-numbers.patch md-avoid-possible-spinning-md-thread-at-shutdown.patch --- diff --git a/queue-3.10/drivercore-deferral-race-condition-fix.patch b/queue-3.10/drivercore-deferral-race-condition-fix.patch new file mode 100644 index 00000000000..06556cbd953 --- /dev/null +++ b/queue-3.10/drivercore-deferral-race-condition-fix.patch @@ -0,0 +1,123 @@ +From 58b116bce13612e5aa6fcd49ecbd4cf8bb59e835 Mon Sep 17 00:00:00 2001 +From: Grant Likely +Date: Tue, 29 Apr 2014 12:05:22 +0100 +Subject: drivercore: deferral race condition fix + +From: Grant Likely + +commit 58b116bce13612e5aa6fcd49ecbd4cf8bb59e835 upstream. + +When the kernel is built with CONFIG_PREEMPT it is possible to reach a state +when all modules loaded but some driver still stuck in the deferred list +and there is a need for external event to kick the deferred queue to probe +these drivers. + +The issue has been observed on embedded systems with CONFIG_PREEMPT enabled, +audio support built as modules and using nfsroot for root filesystem. + +The following log fragment shows such sequence when all audio modules +were loaded but the sound card is not present since the machine driver has +failed to probe due to missing dependency during it's probe. +The board is am335x-evmsk (McASP<->tlv320aic3106 codec) with davinci-evm +machine driver: + +... +[ 12.615118] davinci-mcasp 4803c000.mcasp: davinci_mcasp_probe: ENTER +[ 12.719969] davinci_evm sound.3: davinci_evm_probe: ENTER +[ 12.725753] davinci_evm sound.3: davinci_evm_probe: snd_soc_register_card +[ 12.753846] davinci-mcasp 4803c000.mcasp: davinci_mcasp_probe: snd_soc_register_component +[ 12.922051] davinci-mcasp 4803c000.mcasp: davinci_mcasp_probe: snd_soc_register_component DONE +[ 12.950839] davinci_evm sound.3: ASoC: platform (null) not registered +[ 12.957898] davinci_evm sound.3: davinci_evm_probe: snd_soc_register_card DONE (-517) +[ 13.099026] davinci-mcasp 4803c000.mcasp: Kicking the deferred list +[ 13.177838] davinci-mcasp 4803c000.mcasp: really_probe: probe_count = 2 +[ 13.194130] davinci_evm sound.3: snd_soc_register_card failed (-517) +[ 13.346755] davinci_mcasp_driver_init: LEAVE +[ 13.377446] platform sound.3: Driver davinci_evm requests probe deferral +[ 13.592527] platform sound.3: really_probe: probe_count = 0 + +In the log the machine driver enters it's probe at 12.719969 (this point it +has been removed from the deferred lists). McASP driver already executing +it's probing (since 12.615118). +The machine driver tries to construct the sound card (12.950839) but did +not found one of the components so it fails. After this McASP driver +registers all the ASoC components (the machine driver still in it's probe +function after it failed to construct the card) and the deferred work is +prepared at 13.099026 (note that this time the machine driver is not in the +lists so it is not going to be handled when the work is executing). +Lastly the machine driver exit from it's probe and the core places it to +the deferred list but there will be no other driver going to load and the +deferred queue is not going to be kicked again - till we have external event +like connecting USB stick, etc. + +The proposed solution is to try the deferred queue once more when the last +driver is asking for deferring and we had drivers loaded while this last +driver was probing. + +This way we can avoid drivers stuck in the deferred queue. + +Signed-off-by: Grant Likely +Reviewed-by: Peter Ujfalusi +Tested-by: Peter Ujfalusi +Acked-by: Greg Kroah-Hartman +Cc: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/base/dd.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +--- a/drivers/base/dd.c ++++ b/drivers/base/dd.c +@@ -52,6 +52,7 @@ static DEFINE_MUTEX(deferred_probe_mutex + static LIST_HEAD(deferred_probe_pending_list); + static LIST_HEAD(deferred_probe_active_list); + static struct workqueue_struct *deferred_wq; ++static atomic_t deferred_trigger_count = ATOMIC_INIT(0); + + /** + * deferred_probe_work_func() - Retry probing devices in the active list. +@@ -135,6 +136,17 @@ static bool driver_deferred_probe_enable + * This functions moves all devices from the pending list to the active + * list and schedules the deferred probe workqueue to process them. It + * should be called anytime a driver is successfully bound to a device. ++ * ++ * Note, there is a race condition in multi-threaded probe. In the case where ++ * more than one device is probing at the same time, it is possible for one ++ * probe to complete successfully while another is about to defer. If the second ++ * depends on the first, then it will get put on the pending list after the ++ * trigger event has already occured and will be stuck there. ++ * ++ * The atomic 'deferred_trigger_count' is used to determine if a successful ++ * trigger has occurred in the midst of probing a driver. If the trigger count ++ * changes in the midst of a probe, then deferred processing should be triggered ++ * again. + */ + static void driver_deferred_probe_trigger(void) + { +@@ -147,6 +159,7 @@ static void driver_deferred_probe_trigge + * into the active list so they can be retried by the workqueue + */ + mutex_lock(&deferred_probe_mutex); ++ atomic_inc(&deferred_trigger_count); + list_splice_tail_init(&deferred_probe_pending_list, + &deferred_probe_active_list); + mutex_unlock(&deferred_probe_mutex); +@@ -265,6 +278,7 @@ static DECLARE_WAIT_QUEUE_HEAD(probe_wai + static int really_probe(struct device *dev, struct device_driver *drv) + { + int ret = 0; ++ int local_trigger_count = atomic_read(&deferred_trigger_count); + + atomic_inc(&probe_count); + pr_debug("bus: '%s': %s: probing driver %s with device %s\n", +@@ -310,6 +324,9 @@ probe_failed: + /* Driver requested deferred probing */ + dev_info(dev, "Driver %s requests probe deferral\n", drv->name); + driver_deferred_probe_add(dev); ++ /* Did a trigger occur while probing? Need to re-trigger if yes */ ++ if (local_trigger_count != atomic_read(&deferred_trigger_count)) ++ driver_deferred_probe_trigger(); + } else if (ret != -ENODEV && ret != -ENXIO) { + /* driver matched but the probe failed */ + printk(KERN_WARNING diff --git a/queue-3.10/hrtimer-prevent-all-reprogramming-if-hang-detected.patch b/queue-3.10/hrtimer-prevent-all-reprogramming-if-hang-detected.patch new file mode 100644 index 00000000000..d302dbcaba8 --- /dev/null +++ b/queue-3.10/hrtimer-prevent-all-reprogramming-if-hang-detected.patch @@ -0,0 +1,77 @@ +From 6c6c0d5a1c949d2e084706f9e5fb1fccc175b265 Mon Sep 17 00:00:00 2001 +From: Stuart Hayes +Date: Tue, 29 Apr 2014 17:55:02 -0500 +Subject: hrtimer: Prevent all reprogramming if hang detected + +From: Stuart Hayes + +commit 6c6c0d5a1c949d2e084706f9e5fb1fccc175b265 upstream. + +If the last hrtimer interrupt detected a hang it sets hang_detected=1 +and programs the clock event device with a delay to let the system +make progress. + +If hang_detected == 1, we prevent reprogramming of the clock event +device in hrtimer_reprogram() but not in hrtimer_force_reprogram(). + +This can lead to the following situation: + +hrtimer_interrupt() + hang_detected = 1; + program ce device to Xms from now (hang delay) + +We have two timers pending: + T1 expires 50ms from now + T2 expires 5s from now + +Now T1 gets canceled, which causes hrtimer_force_reprogram() to be +invoked, which in turn programs the clock event device to T2 (5 +seconds from now). + +Any hrtimer_start after that will not reprogram the hardware due to +hang_detected still being set. So we effectivly block all timers until +the T2 event fires and cleans up the hang situation. + +Add a check for hang_detected to hrtimer_force_reprogram() which +prevents the reprogramming of the hang delay in the hardware +timer. The subsequent hrtimer_interrupt will resolve all outstanding +issues. + +[ tglx: Rewrote subject and changelog and fixed up the comment in + hrtimer_force_reprogram() ] + +Signed-off-by: Stuart Hayes +Link: http://lkml.kernel.org/r/53602DC6.2060101@gmail.com +Signed-off-by: Thomas Gleixner +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/hrtimer.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +--- a/kernel/hrtimer.c ++++ b/kernel/hrtimer.c +@@ -580,6 +580,23 @@ hrtimer_force_reprogram(struct hrtimer_c + + cpu_base->expires_next.tv64 = expires_next.tv64; + ++ /* ++ * If a hang was detected in the last timer interrupt then we ++ * leave the hang delay active in the hardware. We want the ++ * system to make progress. That also prevents the following ++ * scenario: ++ * T1 expires 50ms from now ++ * T2 expires 5s from now ++ * ++ * T1 is removed, so this code is called and would reprogram ++ * the hardware to 5s from now. Any hrtimer_start after that ++ * will not reprogram the hardware due to hang_detected being ++ * set. So we'd effectivly block all timers until the T2 event ++ * fires. ++ */ ++ if (cpu_base->hang_detected) ++ return; ++ + if (cpu_base->expires_next.tv64 != KTIME_MAX) + tick_program_event(cpu_base->expires_next, 1); + } diff --git a/queue-3.10/hrtimer-prevent-remote-enqueue-of-leftmost-timers.patch b/queue-3.10/hrtimer-prevent-remote-enqueue-of-leftmost-timers.patch new file mode 100644 index 00000000000..613000b5b21 --- /dev/null +++ b/queue-3.10/hrtimer-prevent-remote-enqueue-of-leftmost-timers.patch @@ -0,0 +1,55 @@ +From 012a45e3f4af68e86d85cce060c6c2fed56498b2 Mon Sep 17 00:00:00 2001 +From: Leon Ma +Date: Wed, 30 Apr 2014 16:43:10 +0800 +Subject: hrtimer: Prevent remote enqueue of leftmost timers + +From: Leon Ma + +commit 012a45e3f4af68e86d85cce060c6c2fed56498b2 upstream. + +If a cpu is idle and starts an hrtimer which is not pinned on that +same cpu, the nohz code might target the timer to a different cpu. + +In the case that we switch the cpu base of the timer we already have a +sanity check in place, which determines whether the timer is earlier +than the current leftmost timer on the target cpu. In that case we +enqueue the timer on the current cpu because we cannot reprogram the +clock event device on the target. + +If the timers base is already the target CPU we do not have this +sanity check in place so we enqueue the timer as the leftmost timer in +the target cpus rb tree, but we cannot reprogram the clock event +device on the target cpu. So the timer expires late and subsequently +prevents the reprogramming of the target cpu clock event device until +the previously programmed event fires or a timer with an earlier +expiry time gets enqueued on the target cpu itself. + +Add the same target check as we have for the switch base case and +start the timer on the current cpu if it would become the leftmost +timer on the target. + +[ tglx: Rewrote subject and changelog ] + +Signed-off-by: Leon Ma +Link: http://lkml.kernel.org/r/1398847391-5994-1-git-send-email-xindong.ma@intel.com +Signed-off-by: Thomas Gleixner +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/hrtimer.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/kernel/hrtimer.c ++++ b/kernel/hrtimer.c +@@ -245,6 +245,11 @@ again: + goto again; + } + timer->base = new_base; ++ } else { ++ if (cpu != this_cpu && hrtimer_check_target(timer, new_base)) { ++ cpu = this_cpu; ++ goto again; ++ } + } + return new_base; + } diff --git a/queue-3.10/hrtimer-set-expiry-time-before-switch_hrtimer_base.patch b/queue-3.10/hrtimer-set-expiry-time-before-switch_hrtimer_base.patch new file mode 100644 index 00000000000..baff973516d --- /dev/null +++ b/queue-3.10/hrtimer-set-expiry-time-before-switch_hrtimer_base.patch @@ -0,0 +1,59 @@ +From 84ea7fe37908254c3bd90910921f6e1045c1747a Mon Sep 17 00:00:00 2001 +From: Viresh Kumar +Date: Mon, 12 May 2014 13:42:29 +0530 +Subject: hrtimer: Set expiry time before switch_hrtimer_base() + +From: Viresh Kumar + +commit 84ea7fe37908254c3bd90910921f6e1045c1747a upstream. + +switch_hrtimer_base() calls hrtimer_check_target() which ensures that +we do not migrate a timer to a remote cpu if the timer expires before +the current programmed expiry time on that remote cpu. + +But __hrtimer_start_range_ns() calls switch_hrtimer_base() before the +new expiry time is set. So the sanity check in hrtimer_check_target() +is operating on stale or even uninitialized data. + +Update expiry time before calling switch_hrtimer_base(). + +[ tglx: Rewrote changelog once again ] + +Signed-off-by: Viresh Kumar +Cc: linaro-kernel@lists.linaro.org +Cc: linaro-networking@linaro.org +Cc: fweisbec@gmail.com +Cc: arvind.chauhan@arm.com +Link: http://lkml.kernel.org/r/81999e148745fc51bbcd0615823fbab9b2e87e23.1399882253.git.viresh.kumar@linaro.org +Signed-off-by: Thomas Gleixner +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/hrtimer.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/kernel/hrtimer.c ++++ b/kernel/hrtimer.c +@@ -999,11 +999,8 @@ int __hrtimer_start_range_ns(struct hrti + /* Remove an active timer from the queue: */ + ret = remove_hrtimer(timer, base); + +- /* Switch the timer base, if necessary: */ +- new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); +- + if (mode & HRTIMER_MODE_REL) { +- tim = ktime_add_safe(tim, new_base->get_time()); ++ tim = ktime_add_safe(tim, base->get_time()); + /* + * CONFIG_TIME_LOW_RES is a temporary way for architectures + * to signal that they simply return xtime in +@@ -1018,6 +1015,9 @@ int __hrtimer_start_range_ns(struct hrti + + hrtimer_set_expires_range_ns(timer, tim, delta_ns); + ++ /* Switch the timer base, if necessary: */ ++ new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); ++ + timer_stats_hrtimer_set_start_info(timer); + + leftmost = enqueue_hrtimer(timer, new_base); diff --git a/queue-3.10/hwmon-emc1403-fix-inverted-store_hyst.patch b/queue-3.10/hwmon-emc1403-fix-inverted-store_hyst.patch new file mode 100644 index 00000000000..49a54817b7b --- /dev/null +++ b/queue-3.10/hwmon-emc1403-fix-inverted-store_hyst.patch @@ -0,0 +1,34 @@ +From 17c048fc4bd95efea208a1920f169547d8588f1f Mon Sep 17 00:00:00 2001 +From: Josef Gajdusek +Date: Sun, 11 May 2014 14:40:44 +0200 +Subject: hwmon: (emc1403) fix inverted store_hyst() + +From: Josef Gajdusek + +commit 17c048fc4bd95efea208a1920f169547d8588f1f upstream. + +Attempts to set the hysteresis value to a temperature below the target +limit fails with "write error: Numerical result out of range" due to +an inverted comparison. + +Signed-off-by: Josef Gajdusek +Reviewed-by: Jean Delvare +[Guenter Roeck: Updated headline and description] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hwmon/emc1403.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/hwmon/emc1403.c ++++ b/drivers/hwmon/emc1403.c +@@ -162,7 +162,7 @@ static ssize_t store_hyst(struct device + if (retval < 0) + goto fail; + +- hyst = val - retval * 1000; ++ hyst = retval * 1000 - val; + hyst = DIV_ROUND_CLOSEST(hyst, 1000); + if (hyst < 0 || hyst > 255) { + retval = -ERANGE; diff --git a/queue-3.10/hwmon-emc1403-support-full-range-of-known-chip-revision-numbers.patch b/queue-3.10/hwmon-emc1403-support-full-range-of-known-chip-revision-numbers.patch new file mode 100644 index 00000000000..cfca88f6335 --- /dev/null +++ b/queue-3.10/hwmon-emc1403-support-full-range-of-known-chip-revision-numbers.patch @@ -0,0 +1,34 @@ +From 3a18e1398fc2dc9c32bbdc50664da3a77959a8d1 Mon Sep 17 00:00:00 2001 +From: Josef Gajdusek +Date: Mon, 12 May 2014 13:48:26 +0200 +Subject: hwmon: (emc1403) Support full range of known chip revision numbers + +From: Josef Gajdusek + +commit 3a18e1398fc2dc9c32bbdc50664da3a77959a8d1 upstream. + +The datasheet for EMC1413/EMC1414, which is fully compatible to +EMC1403/1404 and uses the same chip identification, references revision +numbers 0x01, 0x03, and 0x04. Accept the full range of revision numbers +from 0x01 to 0x04 to make sure none are missed. + +Signed-off-by: Josef Gajdusek +[Guenter Roeck: Updated headline and description] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hwmon/emc1403.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/hwmon/emc1403.c ++++ b/drivers/hwmon/emc1403.c +@@ -295,7 +295,7 @@ static int emc1403_detect(struct i2c_cli + } + + id = i2c_smbus_read_byte_data(client, THERMAL_REVISION_REG); +- if (id != 0x01) ++ if (id < 0x01 || id > 0x04) + return -ENODEV; + + return 0; diff --git a/queue-3.10/md-avoid-possible-spinning-md-thread-at-shutdown.patch b/queue-3.10/md-avoid-possible-spinning-md-thread-at-shutdown.patch new file mode 100644 index 00000000000..8c9c97b12e2 --- /dev/null +++ b/queue-3.10/md-avoid-possible-spinning-md-thread-at-shutdown.patch @@ -0,0 +1,38 @@ +From 0f62fb220aa4ebabe8547d3a9ce4a16d3c045f21 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 6 May 2014 09:36:08 +1000 +Subject: md: avoid possible spinning md thread at shutdown. + +From: NeilBrown + +commit 0f62fb220aa4ebabe8547d3a9ce4a16d3c045f21 upstream. + +If an md array with externally managed metadata (e.g. DDF or IMSM) +is in use, then we should not set safemode==2 at shutdown because: + +1/ this is ineffective: user-space need to be involved in any 'safemode' handling, +2/ The safemode management code doesn't cope with safemode==2 on external metadata + and md_check_recover enters an infinite loop. + +Even at shutdown, an infinite-looping process can be problematic, so this +could cause shutdown to hang. + +Signed-off-by: NeilBrown +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/md/md.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/md/md.c ++++ b/drivers/md/md.c +@@ -8481,7 +8481,8 @@ static int md_notify_reboot(struct notif + if (mddev_trylock(mddev)) { + if (mddev->pers) + __md_stop_writes(mddev); +- mddev->safemode = 2; ++ if (mddev->persistent) ++ mddev->safemode = 2; + mddev_unlock(mddev); + } + need_delay = 1; diff --git a/queue-3.10/series b/queue-3.10/series index 6fbc2a2af41..7a4e77a4e64 100644 --- a/queue-3.10/series +++ b/queue-3.10/series @@ -20,3 +20,10 @@ mm-thp-close-race-between-mremap-and-split_huge_page.patch x86-mm-hugetlb-add-missing-tlb-page-invalidation-for-hugetlb_cow.patch hwpoison-hugetlb-lock_page-unlock_page-does-not-match-for-handling-a-free-hugepage.patch mac80211-fix-on-channel-remain-on-channel.patch +hwmon-emc1403-fix-inverted-store_hyst.patch +hwmon-emc1403-support-full-range-of-known-chip-revision-numbers.patch +drivercore-deferral-race-condition-fix.patch +hrtimer-prevent-all-reprogramming-if-hang-detected.patch +hrtimer-prevent-remote-enqueue-of-leftmost-timers.patch +hrtimer-set-expiry-time-before-switch_hrtimer_base.patch +md-avoid-possible-spinning-md-thread-at-shutdown.patch