]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.15
authorSasha Levin <sashal@kernel.org>
Mon, 12 Aug 2024 10:01:53 +0000 (06:01 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 12 Aug 2024 10:01:53 +0000 (06:01 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.15/clocksource-fix-brown-bag-boolean-thinko-in-cs_watch.patch [new file with mode: 0644]
queue-5.15/clocksource-reduce-the-default-clocksource_watchdog-.patch [new file with mode: 0644]
queue-5.15/clocksource-scale-the-watchdog-read-retries-automati.patch [new file with mode: 0644]
queue-5.15/irqchip-meson-gpio-convert-meson_gpio_irq_controller.patch [new file with mode: 0644]
queue-5.15/irqchip-meson-gpio-support-more-than-8-channels-gpio.patch [new file with mode: 0644]
queue-5.15/ntp-clamp-maxerror-and-esterror-to-operating-range.patch [new file with mode: 0644]
queue-5.15/series
queue-5.15/torture-enable-clocksource-watchdog-with-tsc-watchdo.patch [new file with mode: 0644]

diff --git a/queue-5.15/clocksource-fix-brown-bag-boolean-thinko-in-cs_watch.patch b/queue-5.15/clocksource-fix-brown-bag-boolean-thinko-in-cs_watch.patch
new file mode 100644 (file)
index 0000000..9deb6f7
--- /dev/null
@@ -0,0 +1,43 @@
+From d9b69c864d59e23ff97079b6d616018c48e27790 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 2 Aug 2024 08:46:15 -0700
+Subject: clocksource: Fix brown-bag boolean thinko in cs_watchdog_read()
+
+From: Paul E. McKenney <paulmck@kernel.org>
+
+[ Upstream commit f2655ac2c06a15558e51ed6529de280e1553c86e ]
+
+The current "nretries > 1 || nretries >= max_retries" check in
+cs_watchdog_read() will always evaluate to true, and thus pr_warn(), if
+nretries is greater than 1.  The intent is instead to never warn on the
+first try, but otherwise warn if the successful retry was the last retry.
+
+Therefore, change that "||" to "&&".
+
+Fixes: db3a34e17433 ("clocksource: Retry clock read if long delays detected")
+Reported-by: Borislav Petkov <bp@alien8.de>
+Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/all/20240802154618.4149953-2-paulmck@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/time/clocksource.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
+index c3b59f2250a17..3ccb383741d08 100644
+--- a/kernel/time/clocksource.c
++++ b/kernel/time/clocksource.c
+@@ -229,7 +229,7 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow,
+               wd_delay = clocksource_cyc2ns(wd_delta, watchdog->mult,
+                                             watchdog->shift);
+               if (wd_delay <= WATCHDOG_MAX_SKEW) {
+-                      if (nretries > 1 || nretries >= max_retries) {
++                      if (nretries > 1 && nretries >= max_retries) {
+                               pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n",
+                                       smp_processor_id(), watchdog->name, nretries);
+                       }
+-- 
+2.43.0
+
diff --git a/queue-5.15/clocksource-reduce-the-default-clocksource_watchdog-.patch b/queue-5.15/clocksource-reduce-the-default-clocksource_watchdog-.patch
new file mode 100644 (file)
index 0000000..4b653e7
--- /dev/null
@@ -0,0 +1,56 @@
+From 9f679a1f2aa7e738e3ab7b445627942659d962a8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Nov 2021 14:14:37 -0500
+Subject: clocksource: Reduce the default clocksource_watchdog() retries to 2
+
+From: Waiman Long <longman@redhat.com>
+
+[ Upstream commit 1a5620671a1b6fd9cc08761677d050f1702f910c ]
+
+With the previous patch, there is an extra watchdog read in each retry.
+Now the total number of clocksource reads is increased to 4 per iteration.
+In order to avoid increasing the clock skew check overhead, the default
+maximum number of retries is reduced from 3 to 2 to maintain the same 12
+clocksource reads in the worst case.
+
+Suggested-by: Paul E. McKenney <paulmck@kernel.org>
+Signed-off-by: Waiman Long <longman@redhat.com>
+Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
+Stable-dep-of: f2655ac2c06a ("clocksource: Fix brown-bag boolean thinko in cs_watchdog_read()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/admin-guide/kernel-parameters.txt | 4 ++--
+ kernel/time/clocksource.c                       | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
+index d49e11962333c..2db3d5b6fc038 100644
+--- a/Documentation/admin-guide/kernel-parameters.txt
++++ b/Documentation/admin-guide/kernel-parameters.txt
+@@ -603,8 +603,8 @@
+       clocksource.max_cswd_read_retries= [KNL]
+                       Number of clocksource_watchdog() retries due to
+                       external delays before the clock will be marked
+-                      unstable.  Defaults to three retries, that is,
+-                      four attempts to read the clock under test.
++                      unstable.  Defaults to two retries, that is,
++                      three attempts to read the clock under test.
+       clocksource.verify_n_cpus= [KNL]
+                       Limit the number of CPUs checked for clocksources
+diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
+index 7d6d87a22ad55..38bb654d2a7e1 100644
+--- a/kernel/time/clocksource.c
++++ b/kernel/time/clocksource.c
+@@ -201,7 +201,7 @@ void clocksource_mark_unstable(struct clocksource *cs)
+       spin_unlock_irqrestore(&watchdog_lock, flags);
+ }
+-ulong max_cswd_read_retries = 3;
++ulong max_cswd_read_retries = 2;
+ module_param(max_cswd_read_retries, ulong, 0644);
+ EXPORT_SYMBOL_GPL(max_cswd_read_retries);
+ static int verify_n_cpus = 8;
+-- 
+2.43.0
+
diff --git a/queue-5.15/clocksource-scale-the-watchdog-read-retries-automati.patch b/queue-5.15/clocksource-scale-the-watchdog-read-retries-automati.patch
new file mode 100644 (file)
index 0000000..77a05e7
--- /dev/null
@@ -0,0 +1,194 @@
+From 07549d2a93b4d3de2e2ad327ce7282b3cf5a4894 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 21 Feb 2024 14:08:59 +0800
+Subject: clocksource: Scale the watchdog read retries automatically
+
+From: Feng Tang <feng.tang@intel.com>
+
+[ Upstream commit 2ed08e4bc53298db3f87b528cd804cb0cce066a9 ]
+
+On a 8-socket server the TSC is wrongly marked as 'unstable' and disabled
+during boot time on about one out of 120 boot attempts:
+
+    clocksource: timekeeping watchdog on CPU227: wd-tsc-wd excessive read-back delay of 153560ns vs. limit of 125000ns,
+    wd-wd read-back delay only 11440ns, attempt 3, marking tsc unstable
+    tsc: Marking TSC unstable due to clocksource watchdog
+    TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
+    sched_clock: Marking unstable (119294969739, 159204297)<-(125446229205, -5992055152)
+    clocksource: Checking clocksource tsc synchronization from CPU 319 to CPUs 0,99,136,180,210,542,601,896.
+    clocksource: Switched to clocksource hpet
+
+The reason is that for platform with a large number of CPUs, there are
+sporadic big or huge read latencies while reading the watchog/clocksource
+during boot or when system is under stress work load, and the frequency and
+maximum value of the latency goes up with the number of online CPUs.
+
+The cCurrent code already has logic to detect and filter such high latency
+case by reading the watchdog twice and checking the two deltas. Due to the
+randomness of the latency, there is a low probabilty that the first delta
+(latency) is big, but the second delta is small and looks valid. The
+watchdog code retries the readouts by default twice, which is not
+necessarily sufficient for systems with a large number of CPUs.
+
+There is a command line parameter 'max_cswd_read_retries' which allows to
+increase the number of retries, but that's not user friendly as it needs to
+be tweaked per system. As the number of required retries is proportional to
+the number of online CPUs, this parameter can be calculated at runtime.
+
+Scale and enlarge the number of retries according to the number of online
+CPUs and remove the command line parameter completely.
+
+[ tglx: Massaged change log and comments ]
+
+Signed-off-by: Feng Tang <feng.tang@intel.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Tested-by: Jin Wang <jin1.wang@intel.com>
+Tested-by: Paul E. McKenney <paulmck@kernel.org>
+Reviewed-by: Waiman Long <longman@redhat.com>
+Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
+Link: https://lore.kernel.org/r/20240221060859.1027450-1-feng.tang@intel.com
+Stable-dep-of: f2655ac2c06a ("clocksource: Fix brown-bag boolean thinko in cs_watchdog_read()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/admin-guide/kernel-parameters.txt   |  6 ------
+ include/linux/clocksource.h                       | 14 +++++++++++++-
+ kernel/time/clocksource-wdtest.c                  | 13 +++++++------
+ kernel/time/clocksource.c                         | 10 ++++------
+ tools/testing/selftests/rcutorture/bin/torture.sh |  2 +-
+ 5 files changed, 25 insertions(+), 20 deletions(-)
+
+diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
+index 2db3d5b6fc038..cf35b2cf90c27 100644
+--- a/Documentation/admin-guide/kernel-parameters.txt
++++ b/Documentation/admin-guide/kernel-parameters.txt
+@@ -600,12 +600,6 @@
+                       loops can be debugged more effectively on production
+                       systems.
+-      clocksource.max_cswd_read_retries= [KNL]
+-                      Number of clocksource_watchdog() retries due to
+-                      external delays before the clock will be marked
+-                      unstable.  Defaults to two retries, that is,
+-                      three attempts to read the clock under test.
+-
+       clocksource.verify_n_cpus= [KNL]
+                       Limit the number of CPUs checked for clocksources
+                       marked with CLOCK_SOURCE_VERIFY_PERCPU that
+diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
+index 1d42d4b173271..0ad8b550bb4b4 100644
+--- a/include/linux/clocksource.h
++++ b/include/linux/clocksource.h
+@@ -291,7 +291,19 @@ static inline void timer_probe(void) {}
+ #define TIMER_ACPI_DECLARE(name, table_id, fn)                \
+       ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn)
+-extern ulong max_cswd_read_retries;
++static inline unsigned int clocksource_get_max_watchdog_retry(void)
++{
++      /*
++       * When system is in the boot phase or under heavy workload, there
++       * can be random big latencies during the clocksource/watchdog
++       * read, so allow retries to filter the noise latency. As the
++       * latency's frequency and maximum value goes up with the number of
++       * CPUs, scale the number of retries with the number of online
++       * CPUs.
++       */
++      return (ilog2(num_online_cpus()) / 2) + 1;
++}
++
+ void clocksource_verify_percpu(struct clocksource *cs);
+ #endif /* _LINUX_CLOCKSOURCE_H */
+diff --git a/kernel/time/clocksource-wdtest.c b/kernel/time/clocksource-wdtest.c
+index df922f49d171b..d06185e054ea2 100644
+--- a/kernel/time/clocksource-wdtest.c
++++ b/kernel/time/clocksource-wdtest.c
+@@ -104,8 +104,8 @@ static void wdtest_ktime_clocksource_reset(void)
+ static int wdtest_func(void *arg)
+ {
+       unsigned long j1, j2;
++      int i, max_retries;
+       char *s;
+-      int i;
+       schedule_timeout_uninterruptible(holdoff * HZ);
+@@ -139,18 +139,19 @@ static int wdtest_func(void *arg)
+       WARN_ON_ONCE(time_before(j2, j1 + NSEC_PER_USEC));
+       /* Verify tsc-like stability with various numbers of errors injected. */
+-      for (i = 0; i <= max_cswd_read_retries + 1; i++) {
+-              if (i <= 1 && i < max_cswd_read_retries)
++      max_retries = clocksource_get_max_watchdog_retry();
++      for (i = 0; i <= max_retries + 1; i++) {
++              if (i <= 1 && i < max_retries)
+                       s = "";
+-              else if (i <= max_cswd_read_retries)
++              else if (i <= max_retries)
+                       s = ", expect message";
+               else
+                       s = ", expect clock skew";
+-              pr_info("--- Watchdog with %dx error injection, %lu retries%s.\n", i, max_cswd_read_retries, s);
++              pr_info("--- Watchdog with %dx error injection, %d retries%s.\n", i, max_retries, s);
+               WRITE_ONCE(wdtest_ktime_read_ndelays, i);
+               schedule_timeout_uninterruptible(2 * HZ);
+               WARN_ON_ONCE(READ_ONCE(wdtest_ktime_read_ndelays));
+-              WARN_ON_ONCE((i <= max_cswd_read_retries) !=
++              WARN_ON_ONCE((i <= max_retries) !=
+                            !(clocksource_wdtest_ktime.flags & CLOCK_SOURCE_UNSTABLE));
+               wdtest_ktime_clocksource_reset();
+       }
+diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
+index 38bb654d2a7e1..c3b59f2250a17 100644
+--- a/kernel/time/clocksource.c
++++ b/kernel/time/clocksource.c
+@@ -201,9 +201,6 @@ void clocksource_mark_unstable(struct clocksource *cs)
+       spin_unlock_irqrestore(&watchdog_lock, flags);
+ }
+-ulong max_cswd_read_retries = 2;
+-module_param(max_cswd_read_retries, ulong, 0644);
+-EXPORT_SYMBOL_GPL(max_cswd_read_retries);
+ static int verify_n_cpus = 8;
+ module_param(verify_n_cpus, int, 0644);
+@@ -215,11 +212,12 @@ enum wd_read_status {
+ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow)
+ {
+-      unsigned int nretries;
++      unsigned int nretries, max_retries;
+       u64 wd_end, wd_end2, wd_delta;
+       int64_t wd_delay, wd_seq_delay;
+-      for (nretries = 0; nretries <= max_cswd_read_retries; nretries++) {
++      max_retries = clocksource_get_max_watchdog_retry();
++      for (nretries = 0; nretries <= max_retries; nretries++) {
+               local_irq_disable();
+               *wdnow = watchdog->read(watchdog);
+               *csnow = cs->read(cs);
+@@ -231,7 +229,7 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow,
+               wd_delay = clocksource_cyc2ns(wd_delta, watchdog->mult,
+                                             watchdog->shift);
+               if (wd_delay <= WATCHDOG_MAX_SKEW) {
+-                      if (nretries > 1 || nretries >= max_cswd_read_retries) {
++                      if (nretries > 1 || nretries >= max_retries) {
+                               pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n",
+                                       smp_processor_id(), watchdog->name, nretries);
+                       }
+diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
+index 33ba08ea10a73..d9513e50f24c2 100755
+--- a/tools/testing/selftests/rcutorture/bin/torture.sh
++++ b/tools/testing/selftests/rcutorture/bin/torture.sh
+@@ -389,7 +389,7 @@ then
+       torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
+       torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+-      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1 tsc=watchdog"
++      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
+       torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+       # In case our work is already done...
+-- 
+2.43.0
+
diff --git a/queue-5.15/irqchip-meson-gpio-convert-meson_gpio_irq_controller.patch b/queue-5.15/irqchip-meson-gpio-convert-meson_gpio_irq_controller.patch
new file mode 100644 (file)
index 0000000..943166b
--- /dev/null
@@ -0,0 +1,111 @@
+From c326e9077f604d888b5b221cecc86fc284159ad9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 Jul 2024 16:18:50 +0300
+Subject: irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to
+ 'raw_spinlock_t'
+
+From: Arseniy Krasnov <avkrasnov@salutedevices.com>
+
+[ Upstream commit f872d4af79fe8c71ae291ce8875b477e1669a6c7 ]
+
+This lock is acquired under irq_desc::lock with interrupts disabled.
+
+When PREEMPT_RT is enabled, 'spinlock_t' becomes preemptible, which results
+in invalid lock acquire context;
+
+  [ BUG: Invalid wait context ]
+  swapper/0/1 is trying to lock:
+  ffff0000008fed30 (&ctl->lock){....}-{3:3}, at: meson_gpio_irq_update_bits0
+  other info that might help us debug this:
+  context-{5:5}
+  3 locks held by swapper/0/1:
+   #0: ffff0000003cd0f8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0x90c
+   #1: ffff000004714650 (&desc->request_mutex){+.+.}-{4:4}, at: __setup_irq0
+   #2: ffff0000047144c8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __setup_irq0
+  stack backtrace:
+  CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.9.9-sdkernel #1
+  Call trace:
+   _raw_spin_lock_irqsave+0x60/0x88
+   meson_gpio_irq_update_bits+0x34/0x70
+   meson8_gpio_irq_set_type+0x78/0xc4
+   meson_gpio_irq_set_type+0x30/0x60
+   __irq_set_trigger+0x60/0x180
+   __setup_irq+0x30c/0x6e0
+   request_threaded_irq+0xec/0x1a4
+
+Fixes: 215f4cc0fb20 ("irqchip/meson: Add support for gpio interrupt controller")
+Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/all/20240729131850.3015508-1-avkrasnov@salutedevices.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-meson-gpio.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
+index 89dab14406e69..6a3d18d5ba2f0 100644
+--- a/drivers/irqchip/irq-meson-gpio.c
++++ b/drivers/irqchip/irq-meson-gpio.c
+@@ -141,7 +141,7 @@ struct meson_gpio_irq_controller {
+       void __iomem *base;
+       u32 channel_irqs[MAX_NUM_CHANNEL];
+       DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);
+-      spinlock_t lock;
++      raw_spinlock_t lock;
+ };
+ static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl,
+@@ -150,14 +150,14 @@ static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl,
+       unsigned long flags;
+       u32 tmp;
+-      spin_lock_irqsave(&ctl->lock, flags);
++      raw_spin_lock_irqsave(&ctl->lock, flags);
+       tmp = readl_relaxed(ctl->base + reg);
+       tmp &= ~mask;
+       tmp |= val;
+       writel_relaxed(tmp, ctl->base + reg);
+-      spin_unlock_irqrestore(&ctl->lock, flags);
++      raw_spin_unlock_irqrestore(&ctl->lock, flags);
+ }
+ static void meson_gpio_irq_init_dummy(struct meson_gpio_irq_controller *ctl)
+@@ -207,12 +207,12 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
+       unsigned long flags;
+       unsigned int idx;
+-      spin_lock_irqsave(&ctl->lock, flags);
++      raw_spin_lock_irqsave(&ctl->lock, flags);
+       /* Find a free channel */
+       idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels);
+       if (idx >= ctl->params->nr_channels) {
+-              spin_unlock_irqrestore(&ctl->lock, flags);
++              raw_spin_unlock_irqrestore(&ctl->lock, flags);
+               pr_err("No channel available\n");
+               return -ENOSPC;
+       }
+@@ -220,7 +220,7 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
+       /* Mark the channel as used */
+       set_bit(idx, ctl->channel_map);
+-      spin_unlock_irqrestore(&ctl->lock, flags);
++      raw_spin_unlock_irqrestore(&ctl->lock, flags);
+       /*
+        * Setup the mux of the channel to route the signal of the pad
+@@ -488,7 +488,7 @@ static int __init meson_gpio_irq_of_init(struct device_node *node,
+       if (!ctl)
+               return -ENOMEM;
+-      spin_lock_init(&ctl->lock);
++      raw_spin_lock_init(&ctl->lock);
+       ctl->base = of_iomap(node, 0);
+       if (!ctl->base) {
+-- 
+2.43.0
+
diff --git a/queue-5.15/irqchip-meson-gpio-support-more-than-8-channels-gpio.patch b/queue-5.15/irqchip-meson-gpio-support-more-than-8-channels-gpio.patch
new file mode 100644 (file)
index 0000000..47d9498
--- /dev/null
@@ -0,0 +1,107 @@
+From 21b31403de2465346ee376eb6715566e39740d72 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 25 Feb 2022 13:52:04 +0800
+Subject: irqchip/meson-gpio: support more than 8 channels gpio irq
+
+From: Qianggui Song <qianggui.song@amlogic.com>
+
+[ Upstream commit cc311074f681443266ed9f5969a5b5a0e833c5bc ]
+
+Current meson gpio irqchip driver only support 8 channels for gpio irq
+line, later chips may have more then 8 channels, so need to modify code
+to support more.
+
+Signed-off-by: Qianggui Song <qianggui.song@amlogic.com>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Link: https://lore.kernel.org/r/20220225055207.1048-3-qianggui.song@amlogic.com
+Stable-dep-of: f872d4af79fe ("irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to 'raw_spinlock_t'")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-meson-gpio.c | 21 ++++++++++++---------
+ 1 file changed, 12 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
+index e50676ce2ec84..89dab14406e69 100644
+--- a/drivers/irqchip/irq-meson-gpio.c
++++ b/drivers/irqchip/irq-meson-gpio.c
+@@ -16,7 +16,7 @@
+ #include <linux/of.h>
+ #include <linux/of_address.h>
+-#define NUM_CHANNEL 8
++#define MAX_NUM_CHANNEL 64
+ #define MAX_INPUT_MUX 256
+ #define REG_EDGE_POL  0x00
+@@ -60,6 +60,7 @@ struct irq_ctl_ops {
+ struct meson_gpio_irq_params {
+       unsigned int nr_hwirq;
++      unsigned int nr_channels;
+       bool support_edge_both;
+       unsigned int edge_both_offset;
+       unsigned int edge_single_offset;
+@@ -81,6 +82,7 @@ struct meson_gpio_irq_params {
+       .edge_single_offset = 0,                                \
+       .pol_low_offset = 16,                                   \
+       .pin_sel_mask = 0xff,                                   \
++      .nr_channels = 8,                                       \
+ #define INIT_MESON_A1_COMMON_DATA(irqs)                               \
+       INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init,         \
+@@ -90,6 +92,7 @@ struct meson_gpio_irq_params {
+       .edge_single_offset = 8,                                \
+       .pol_low_offset = 0,                                    \
+       .pin_sel_mask = 0x7f,                                   \
++      .nr_channels = 8,                                       \
+ static const struct meson_gpio_irq_params meson8_params = {
+       INIT_MESON8_COMMON_DATA(134)
+@@ -136,8 +139,8 @@ static const struct of_device_id meson_irq_gpio_matches[] = {
+ struct meson_gpio_irq_controller {
+       const struct meson_gpio_irq_params *params;
+       void __iomem *base;
+-      u32 channel_irqs[NUM_CHANNEL];
+-      DECLARE_BITMAP(channel_map, NUM_CHANNEL);
++      u32 channel_irqs[MAX_NUM_CHANNEL];
++      DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);
+       spinlock_t lock;
+ };
+@@ -207,8 +210,8 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
+       spin_lock_irqsave(&ctl->lock, flags);
+       /* Find a free channel */
+-      idx = find_first_zero_bit(ctl->channel_map, NUM_CHANNEL);
+-      if (idx >= NUM_CHANNEL) {
++      idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels);
++      if (idx >= ctl->params->nr_channels) {
+               spin_unlock_irqrestore(&ctl->lock, flags);
+               pr_err("No channel available\n");
+               return -ENOSPC;
+@@ -451,10 +454,10 @@ static int __init meson_gpio_irq_parse_dt(struct device_node *node,
+       ret = of_property_read_variable_u32_array(node,
+                                                 "amlogic,channel-interrupts",
+                                                 ctl->channel_irqs,
+-                                                NUM_CHANNEL,
+-                                                NUM_CHANNEL);
++                                                ctl->params->nr_channels,
++                                                ctl->params->nr_channels);
+       if (ret < 0) {
+-              pr_err("can't get %d channel interrupts\n", NUM_CHANNEL);
++              pr_err("can't get %d channel interrupts\n", ctl->params->nr_channels);
+               return ret;
+       }
+@@ -509,7 +512,7 @@ static int __init meson_gpio_irq_of_init(struct device_node *node,
+       }
+       pr_info("%d to %d gpio interrupt mux initialized\n",
+-              ctl->params->nr_hwirq, NUM_CHANNEL);
++              ctl->params->nr_hwirq, ctl->params->nr_channels);
+       return 0;
+-- 
+2.43.0
+
diff --git a/queue-5.15/ntp-clamp-maxerror-and-esterror-to-operating-range.patch b/queue-5.15/ntp-clamp-maxerror-and-esterror-to-operating-range.patch
new file mode 100644 (file)
index 0000000..ad66816
--- /dev/null
@@ -0,0 +1,74 @@
+From 52546f41e094f6aa8f9b75f8ef5e0281edfc4aa9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 17 May 2024 20:22:44 +0000
+Subject: ntp: Clamp maxerror and esterror to operating range
+
+From: Justin Stitt <justinstitt@google.com>
+
+[ Upstream commit 87d571d6fb77ec342a985afa8744bb9bb75b3622 ]
+
+Using syzkaller alongside the newly reintroduced signed integer overflow
+sanitizer spits out this report:
+
+UBSAN: signed-integer-overflow in ../kernel/time/ntp.c:461:16
+9223372036854775807 + 500 cannot be represented in type 'long'
+Call Trace:
+ handle_overflow+0x171/0x1b0
+ second_overflow+0x2d6/0x500
+ accumulate_nsecs_to_secs+0x60/0x160
+ timekeeping_advance+0x1fe/0x890
+ update_wall_time+0x10/0x30
+
+time_maxerror is unconditionally incremented and the result is checked
+against NTP_PHASE_LIMIT, but the increment itself can overflow, resulting
+in wrap-around to negative space.
+
+Before commit eea83d896e31 ("ntp: NTP4 user space bits update") the user
+supplied value was sanity checked to be in the operating range. That change
+removed the sanity check and relied on clamping in handle_overflow() which
+does not work correctly when the user supplied value is in the overflow
+zone of the '+ 500' operation.
+
+The operation requires CAP_SYS_TIME and the side effect of the overflow is
+NTP getting out of sync.
+
+Miroslav confirmed that the input value should be clamped to the operating
+range and the same applies to time_esterror. The latter is not used by the
+kernel, but the value still should be in the operating range as it was
+before the sanity check got removed.
+
+Clamp them to the operating range.
+
+[ tglx: Changed it to clamping and included time_esterror ]
+
+Fixes: eea83d896e31 ("ntp: NTP4 user space bits update")
+Signed-off-by: Justin Stitt <justinstitt@google.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Miroslav Lichvar <mlichvar@redhat.com>
+Link: https://lore.kernel.org/all/20240517-b4-sio-ntp-usec-v2-1-d539180f2b79@google.com
+Closes: https://github.com/KSPP/linux/issues/354
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/time/ntp.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
+index 406dccb79c2b6..502e1e5b7f7f6 100644
+--- a/kernel/time/ntp.c
++++ b/kernel/time/ntp.c
+@@ -727,10 +727,10 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
+       }
+       if (txc->modes & ADJ_MAXERROR)
+-              time_maxerror = txc->maxerror;
++              time_maxerror = clamp(txc->maxerror, 0, NTP_PHASE_LIMIT);
+       if (txc->modes & ADJ_ESTERROR)
+-              time_esterror = txc->esterror;
++              time_esterror = clamp(txc->esterror, 0, NTP_PHASE_LIMIT);
+       if (txc->modes & ADJ_TIMECONST) {
+               time_constant = txc->constant;
+-- 
+2.43.0
+
index 50ae5770a1a0f6c858a15732e9e9a7abcc2f1ad8..8082793ff54a3054417e808564d580f69b8890d3 100644 (file)
@@ -443,3 +443,10 @@ alsa-hda-add-hp-mp9-g4-retail-system-ams-to-force-connect-list.patch
 alsa-hda-hdmi-yet-more-pin-fix-for-hp-elitedesk-800-g4.patch
 usb-vhci-hcd-do-not-drop-references-before-new-references-are-gained.patch
 usb-serial-debug-do-not-echo-input-by-default.patch
+ntp-clamp-maxerror-and-esterror-to-operating-range.patch
+clocksource-reduce-the-default-clocksource_watchdog-.patch
+torture-enable-clocksource-watchdog-with-tsc-watchdo.patch
+clocksource-scale-the-watchdog-read-retries-automati.patch
+clocksource-fix-brown-bag-boolean-thinko-in-cs_watch.patch
+irqchip-meson-gpio-support-more-than-8-channels-gpio.patch
+irqchip-meson-gpio-convert-meson_gpio_irq_controller.patch
diff --git a/queue-5.15/torture-enable-clocksource-watchdog-with-tsc-watchdo.patch b/queue-5.15/torture-enable-clocksource-watchdog-with-tsc-watchdo.patch
new file mode 100644 (file)
index 0000000..c9c053b
--- /dev/null
@@ -0,0 +1,47 @@
+From c9af3814c42740270770df842aff6866d7e7d1cf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:04:09 -0800
+Subject: torture: Enable clocksource watchdog with "tsc=watchdog"
+
+From: Paul E. McKenney <paulmck@kernel.org>
+
+[ Upstream commit 877a0e83c57fa5e2a7fd628ec2e1733ed70c8792 ]
+
+This commit tests the "tsc=watchdog" kernel boot parameter when running
+the clocksourcewd torture tests.
+
+Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
+Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
+Stable-dep-of: f2655ac2c06a ("clocksource: Fix brown-bag boolean thinko in cs_watchdog_read()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/rcutorture/bin/torture.sh | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
+index 66f0f724a1a6d..33ba08ea10a73 100755
+--- a/tools/testing/selftests/rcutorture/bin/torture.sh
++++ b/tools/testing/selftests/rcutorture/bin/torture.sh
+@@ -386,16 +386,16 @@ fi
+ if test "$do_clocksourcewd" = "yes"
+ then
+-      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"
++      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
+       torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+-      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1"
++      torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1 tsc=watchdog"
+       torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+       # In case our work is already done...
+       if test "$do_rcutorture" != "yes"
+       then
+-              torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"
++              torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
+               torture_set "clocksourcewd-3" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --trust-make
+       fi
+ fi
+-- 
+2.43.0
+