]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 7 Oct 2024 03:41:37 +0000 (23:41 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 7 Oct 2024 03:41:37 +0000 (23:41 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/selftests-breakpoints-use-remaining-time-to-check-if.patch [new file with mode: 0644]
queue-5.4/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch [new file with mode: 0644]

diff --git a/queue-5.4/selftests-breakpoints-use-remaining-time-to-check-if.patch b/queue-5.4/selftests-breakpoints-use-remaining-time-to-check-if.patch
new file mode 100644 (file)
index 0000000..1acf695
--- /dev/null
@@ -0,0 +1,87 @@
+From 3d2ce76fdcbb8b56746b69b2b4a39a8e2e257445 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Sep 2024 15:40:25 -0700
+Subject: selftests: breakpoints: use remaining time to check if suspend
+ succeed
+
+From: Yifei Liu <yifei.l.liu@oracle.com>
+
+[ Upstream commit c66be905cda24fb782b91053b196bd2e966f95b7 ]
+
+step_after_suspend_test fails with device busy error while
+writing to /sys/power/state to start suspend. The test believes
+it failed to enter suspend state with
+
+$ sudo ./step_after_suspend_test
+TAP version 13
+Bail out! Failed to enter Suspend state
+
+However, in the kernel message, I indeed see the system get
+suspended and then wake up later.
+
+[611172.033108] PM: suspend entry (s2idle)
+[611172.044940] Filesystems sync: 0.006 seconds
+[611172.052254] Freezing user space processes
+[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
+[611172.067920] OOM killer disabled.
+[611172.072465] Freezing remaining freezable tasks
+[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
+[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
+[611172.117126] serial 00:03: disabled
+some other hardware get reconnected
+[611203.136277] OOM killer enabled.
+[611203.140637] Restarting tasks ...
+[611203.141135] usb 1-8.1: USB disconnect, device number 7
+[611203.141755] done.
+[611203.155268] random: crng reseeded on system resumption
+[611203.162059] PM: suspend exit
+
+After investigation, I noticed that for the code block
+if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
+       ksft_exit_fail_msg("Failed to enter Suspend state\n");
+
+The write will return -1 and errno is set to 16 (device busy).
+It should be caused by the write function is not successfully returned
+before the system suspend and the return value get messed when waking up.
+As a result, It may be better to check the time passed of those few
+instructions to determine whether the suspend is executed correctly for
+it is pretty hard to execute those few lines for 5 seconds.
+
+The timer to wake up the system is set to expire after 5 seconds and
+no re-arm. If the timer remaining time is 0 second and 0 nano secomd,
+it means the timer expired and wake the system up. Otherwise, the system
+could be considered to enter the suspend state failed if there is any
+remaining time.
+
+After appling this patch, the test would not fail for it believes the
+system does not go to suspend by mistake. It now could continue to the
+rest part of the test after suspend.
+
+Fixes: bfd092b8c272 ("selftests: breakpoint: add step_after_suspend_test")
+Reported-by: Sinadin Shan <sinadin.shan@oracle.com>
+Signed-off-by: Yifei Liu <yifei.l.liu@oracle.com>
+Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+index b3ead29c60894..bff81d95a0319 100644
+--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
++++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+@@ -152,7 +152,10 @@ void suspend(void)
+       if (err < 0)
+               ksft_exit_fail_msg("timerfd_settime() failed\n");
+-      if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
++      system("(echo mem > /sys/power/state) 2> /dev/null");
++
++      timerfd_gettime(timerfd, &spec);
++      if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
+               ksft_exit_fail_msg("Failed to enter Suspend state\n");
+       close(timerfd);
+-- 
+2.43.0
+
diff --git a/queue-5.4/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch b/queue-5.4/selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch
new file mode 100644 (file)
index 0000000..d716cf3
--- /dev/null
@@ -0,0 +1,108 @@
+From 742451c624025eeaa07db86b11de597a84f54920 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 30 Aug 2024 14:28:37 +0200
+Subject: selftests: vDSO: fix vDSO symbols lookup for powerpc64
+
+From: Christophe Leroy <christophe.leroy@csgroup.eu>
+
+[ Upstream commit ba83b3239e657469709d15dcea5f9b65bf9dbf34 ]
+
+On powerpc64, following tests fail locating vDSO functions:
+
+  ~ # ./vdso_test_abi
+  TAP version 13
+  1..16
+  # [vDSO kselftest] VDSO_VERSION: LINUX_2.6.15
+  # Couldn't find __kernel_gettimeofday
+  ok 1 # SKIP __kernel_gettimeofday
+  # clock_id: CLOCK_REALTIME
+  # Couldn't find __kernel_clock_gettime
+  ok 2 # SKIP __kernel_clock_gettime CLOCK_REALTIME
+  # Couldn't find __kernel_clock_getres
+  ok 3 # SKIP __kernel_clock_getres CLOCK_REALTIME
+  ...
+  # Couldn't find __kernel_time
+  ok 16 # SKIP __kernel_time
+  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:16 error:0
+
+  ~ # ./vdso_test_getrandom
+  __kernel_getrandom is missing!
+
+  ~ # ./vdso_test_gettimeofday
+  Could not find __kernel_gettimeofday
+
+  ~ # ./vdso_test_getcpu
+  Could not find __kernel_getcpu
+
+On powerpc64, as shown below by readelf, vDSO functions symbols have
+type NOTYPE, so also accept that type when looking for symbols.
+
+$ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg
+ELF Header:
+  Magic:   7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
+  Class:                             ELF64
+  Data:                              2's complement, big endian
+  Version:                           1 (current)
+  OS/ABI:                            UNIX - System V
+  ABI Version:                       0
+  Type:                              DYN (Shared object file)
+  Machine:                           PowerPC64
+  Version:                           0x1
+...
+
+Symbol table '.dynsym' contains 12 entries:
+   Num:    Value          Size Type    Bind   Vis      Ndx Name
+     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
+     1: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     2: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     3: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     4: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
+     5: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     6: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     7: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     8: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+     9: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+    10: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+    11: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
+
+Symbol table '.symtab' contains 56 entries:
+   Num:    Value          Size Type    Bind   Vis      Ndx Name
+...
+    45: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
+    46: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __kernel_getcpu
+    47: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_getres
+    48: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_tbfreq
+    49: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_gettimeofday
+    50: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __kernel_sync_dicache
+    51: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_getrandom
+    52: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __kernel_sigtram[...]
+    53: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __kernel_time
+    54: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_g[...]
+    55: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_sys[...]
+
+Fixes: 98eedc3a9dbf ("Document the vDSO and add a reference parser")
+Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
+Acked-by: Shuah Khan <skhan@linuxfoundation.org>
+Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/vDSO/parse_vdso.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c
+index 9ef3ad3789c17..540f9a284e9f0 100644
+--- a/tools/testing/selftests/vDSO/parse_vdso.c
++++ b/tools/testing/selftests/vDSO/parse_vdso.c
+@@ -238,7 +238,8 @@ void *vdso_sym(const char *version, const char *name)
+               ELF(Sym) *sym = &vdso_info.symtab[chain];
+               /* Check for a defined global or weak function w/ right name. */
+-              if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC)
++              if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC &&
++                  ELF64_ST_TYPE(sym->st_info) != STT_NOTYPE)
+                       continue;
+               if (ELF64_ST_BIND(sym->st_info) != STB_GLOBAL &&
+                   ELF64_ST_BIND(sym->st_info) != STB_WEAK)
+-- 
+2.43.0
+
index 03b3c6c6a9fdd16f1d33cf2a7e855d37fb663729..945b0d26bcb87739eebbe200a518ca483656cc37 100644 (file)
@@ -238,3 +238,6 @@ drm-radeon-r100-handle-unknown-family-in-r100_cp_ini.patch
 of-irq-refer-to-actual-buffer-size-in-of_irq_parse_o.patch
 ext4-ext4_search_dir-should-return-a-proper-error.patch
 ext4-fix-i_data_sem-unlock-order-in-ext4_ind_migrate.patch
+spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch
+selftests-breakpoints-use-remaining-time-to-check-if.patch
+selftests-vdso-fix-vdso-symbols-lookup-for-powerpc64.patch
diff --git a/queue-5.4/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch b/queue-5.4/spi-s3c64xx-fix-timeout-counters-in-flush_fifo.patch
new file mode 100644 (file)
index 0000000..bae0edc
--- /dev/null
@@ -0,0 +1,49 @@
+From b5d67db44f1f13514b2a02282d09058a1656720f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Sep 2024 14:40:08 +0100
+Subject: spi: s3c64xx: fix timeout counters in flush_fifo
+
+From: Ben Dooks <ben.dooks@codethink.co.uk>
+
+[ Upstream commit 68a16708d2503b6303d67abd43801e2ca40c208d ]
+
+In the s3c64xx_flush_fifo() code, the loops counter is post-decremented
+in the do { } while(test && loops--) condition. This means the loops is
+left at the unsigned equivalent of -1 if the loop times out. The test
+after will never pass as if tests for loops == 0.
+
+Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
+Fixes: 230d42d422e7 ("spi: Add s3c64xx SPI Controller driver")
+Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://patch.msgid.link/20240924134009.116247-2-ben.dooks@codethink.co.uk
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-s3c64xx.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
+index d9420561236c2..108a087a2777c 100644
+--- a/drivers/spi/spi-s3c64xx.c
++++ b/drivers/spi/spi-s3c64xx.c
+@@ -211,7 +211,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)
+       loops = msecs_to_loops(1);
+       do {
+               val = readl(regs + S3C64XX_SPI_STATUS);
+-      } while (TX_FIFO_LVL(val, sdd) && loops--);
++      } while (TX_FIFO_LVL(val, sdd) && --loops);
+       if (loops == 0)
+               dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n");
+@@ -224,7 +224,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd)
+                       readl(regs + S3C64XX_SPI_RX_DATA);
+               else
+                       break;
+-      } while (loops--);
++      } while (--loops);
+       if (loops == 0)
+               dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n");
+-- 
+2.43.0
+