scsi: hisi_sas: Fix I/O errors caused by hardware port ID changes
Subsystems (10)
Sasha Levin
maintainerPATCH 1/12 scsi: hisi_sas: Fix I/O errors caused by hardware port ID changes
From: Xingui Yang <[email protected]>
[ Upstream commit daff37f00c7506ca322ccfce95d342022f06ec58 ]
The hw port ID of phy may change when inserting disks in batches, causing the port ID in hisi_sas_port and itct to be inconsistent with the hardware, resulting in I/O errors. The solution is to set the device state to gone to intercept I/O sent to the device, and then execute linkreset to discard and find the disk to re-update its information.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +20 -0
@@ -865,8 +865,28 @@ static void hisi_sas_phyup_work_common(struct work_struct *work,container_of (work,typeof (*phy), works[event]);struct hisi_hba *hisi_hba = phy->hisi_hba;struct asd_sas_phy *sas_phy = &phy->sas_phy; +struct asd_sas_port *sas_port = sas_phy->port; +struct hisi_sas_port *port = phy->port; +struct device *dev = hisi_hba->dev; +struct domain_device *port_dev;int phy_no = sas_phy->id; +if (!test_bit (HISI_SAS_RESETTING_BIT , &hisi_hba->flags) && + sas_port && port && (port->id != phy->port_id)) { +dev_info (dev,"phy%d's hw port id changed from %d to %llu\n" , + phy_no, port->id, phy->port_id); + port_dev = sas_port->port_dev; +if (port_dev && !dev_is_expander (port_dev->dev_type)) { +/* +* Set the device state to gone to block +* sending IO to the device. +*/ +set_bit (SAS_DEV_GONE , &port_dev->state); +hisi_sas_notify_phy_event (phy,HISI_PHYE_LINK_RESET ); +return ; + } + } + phy->wait_phyup_cnt =0 ;if (phy->identify.target_port_protocols ==SAS_PROTOCOL_SSP ) hisi_hba->hw->sl_notify_ssp (hisi_hba, phy_no);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/12 scsi: ufs: exynos: Ensure pre_link() executes before exynos_ufs_phy_init()
From: Peter Griffin <[email protected]>
[ Upstream commit 3d101165e72316775947d71321d97194f03dfef3 ]
Ensure clocks are enabled before configuring unipro. Additionally move the pre_link() hook before the exynos_ufs_phy_init() calls. This means the register write sequence more closely resembles the ordering of the downstream driver.
--- drivers/ufs/host/ufs-exynos.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/ufs/host/ufs-exynos.c +5 -5
@@ -984,9 +984,14 @@ static int exynos_ufs_pre_link(struct ufs_hba *hba)exynos_ufs_config_intr (ufs,DFES_DEF_L4_ERRS ,UNIPRO_L4 );exynos_ufs_set_unipro_pclk_div (ufs); +exynos_ufs_setup_clocks (hba, true,PRE_CHANGE ); +/* unipro */ exynos_ufs_config_unipro (ufs); +if (ufs->drv_data->pre_link) + ufs->drv_data->pre_link (ufs); +/* m-phy */ exynos_ufs_phy_init (ufs);if (!(ufs->opts &EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR )) {
@@ -994,11 +999,6 @@ static int exynos_ufs_pre_link(struct ufs_hba *hba)exynos_ufs_config_phy_cap_attr (ufs); } -exynos_ufs_setup_clocks (hba, true,PRE_CHANGE ); - -if (ufs->drv_data->pre_link) - ufs->drv_data->pre_link (ufs); -return 0 ; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/12 scsi: pm80xx: Set phy_attached to zero when device is gone
In reply to Sasha LevinFrom: Igor Pylypiv <[email protected]>
[ Upstream commit f7b705c238d1483f0a766e2b20010f176e5c0fb7 ]
When a fatal error occurs, a phy down event may not be received to set phy->phy_attached to zero.
--- drivers/scsi/pm8001/pm8001_sas.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/pm8001/pm8001_sas.c +1 -0
@@ -720,6 +720,7 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)spin_lock_irqsave (&pm8001_ha->lock, flags); }PM8001_CHIP_DISP ->dereg_dev_req (pm8001_ha, device_id); + pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached =0 ;pm8001_free_dev (pm8001_dev); }else {pm8001_dbg (pm8001_ha,DISC ,"Found dev has gone.\n" );
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 4/12 x86/i8253: Call clockevent_i8253_disable() with interrupts disabled
In reply to Sasha LevinFrom: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 3940f5349b476197fb079c5aa19c9a988de64efb ]
There's a lockdep false positive warning related to i8253_lock:
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
...
systemd-sleep/3324 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
ffffffffb2c23398 (i8253_lock){+.+.}-{2:2}, at: pcspkr_event+0x3f/0xe0 [pcspkr]
...
... which became HARDIRQ-irq-unsafe at:
...
lock_acquire+0xd0/0x2f0
_raw_spin_lock+0x30/0x40
clockevent_i8253_disable+0x1c/0x60
pit_timer_init+0x25/0x50
hpet_time_init+0x46/0x50
x86_late_time_init+0x1b/0x40
start_kernel+0x962/0xa00
x86_64_start_reservations+0x24/0x30
x86_64_start_kernel+0xed/0xf0
common_startup_64+0x13e/0x141
...Lockdep complains due pit_timer_init() using the lock in an IRQ-unsafe fashion, but it's a false positive, because there is no deadlock possible at that point due to init ordering: at the point where pit_timer_init() is called there is no other possible usage of i8253_lock because the system is still in the very early boot stage with no interrupts.
But in any case, pit_timer_init() should disable interrupts before calling clockevent_i8253_disable() out of general principle, and to keep lockdep working even in this scenario.
Use scoped_guard() for that, as suggested by Thomas Gleixner.
[ mingo: Cleaned up the changelog. ]
--- arch/x86/kernel/i8253.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/i8253.c +2 -1
@@ -46,7 +46,8 @@ bool __init pit_timer_init(void)* VMMs otherwise steal CPU time just to pointlessly waggle * the (masked) IRQ. */ -clockevent_i8253_disable (); +scoped_guard (irq) +clockevent_i8253_disable ();return false; }clockevent_i8253_init (true);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 5/12 loop: aio inherit the ioprio of original request
In reply to Sasha LevinFrom: Yunlong Xing <[email protected]>
[ Upstream commit 1fdb8188c3d505452b40cdb365b1bb32be533a8e ]
Set cmd->iocb.ki_ioprio to the ioprio of loop device's request. The purpose is to inherit the original request ioprio in the aio flow.
--- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/loop.c +1 -1
@@ -441,7 +441,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, cmd->iocb.ki_filp = file; cmd->iocb.ki_complete = lo_rw_aio_complete; cmd->iocb.ki_flags =IOCB_DIRECT ; - cmd->iocb.ki_ioprio =IOPRIO_PRIO_VALUE (IOPRIO_CLASS_NONE ,0 ); + cmd->iocb.ki_ioprio =req_get_ioprio (rq);if (rw ==ITER_SOURCE ) ret =call_write_iter (file, &cmd->iocb, &iter);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 6/12 spi: tegra210-quad: use WARN_ON_ONCE instead of WARN_ON for timeouts
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit 41c721fc093938745d116c3a21326a0ee03bb491 ]
Some machines with tegra_qspi_combined_seq_xfer hardware issues generate excessive kernel warnings, severely polluting the logs:
dmesg | grep -i "WARNING:.*tegra_qspi_transfer_one_message" | wc -l 94451
This patch replaces WARN_ON with WARN_ON_ONCE for timeout conditions to reduce log spam. The subsequent error message still prints on each occurrence, providing sufficient information about the failure, while the stack trace is only needed once for debugging purposes.
--- drivers/spi/spi-tegra210-quad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-tegra210-quad.c +1 -1
@@ -1110,7 +1110,7 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, (&tqspi->xfer_completion,QSPI_DMA_TIMEOUT ); -if (WARN_ON (ret ==0 )) { +if (WARN_ON_ONCE (ret ==0 )) {dev_err (tqspi->dev,"QSPI Transfer failed with timeout: %d\n" , ret); if (tqspi->is_curr_dma_xfer &&
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 7/12 spi: tegra210-quad: add rate limiting and simplify timeout error message
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit 21f4314e66ed8d40b2ee24185d1a06a07a512eb1 ]
On malfunctioning hardware, timeout error messages can appear thousands of times, creating unnecessary system pressure and log bloat. This patch makes two improvements:
1. Replace dev_err() with dev_err_ratelimited() to prevent log flooding when hardware errors persist
2. Remove the redundant timeout value parameter from the error message, as 'ret' is always zero in this error path
These changes reduce logging overhead while maintaining necessary error reporting for debugging purposes.
--- drivers/spi/spi-tegra210-quad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-tegra210-quad.c +2 -2
@@ -1111,8 +1111,8 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, QSPI_DMA_TIMEOUT);if (WARN_ON_ONCE (ret ==0 )) { -dev_err (tqspi->dev,"QSPI Transfer failed with timeout: %d\n" , - ret); +dev_err_ratelimited (tqspi->dev, +"QSPI Transfer failed with timeout\n" );if (tqspi->is_curr_dma_xfer && (tqspi->cur_direction &DATA_DIR_TX )) dmaengine_terminate_all
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 8/12 hardening: Disable GCC randstruct for COMPILE_TEST
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit f5c68a4e84f9feca3be578199ec648b676db2030 ]
There is a GCC crash bug in the randstruct for latest GCC versions that is being tickled by landlock[1]. Temporarily disable GCC randstruct for COMPILE_TEST builds to unbreak CI systems for the coming -rc2. This can be restored once the bug is fixed.
--- security/Kconfig.hardening | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/Kconfig.hardening +1 -1
@@ -287,7 +287,7 @@ config CC_HAS_RANDSTRUCT choice prompt "Randomize layout of sensitive kernel structures" - default RANDSTRUCT_FULL if COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT) + default RANDSTRUCT_FULL if COMPILE_TEST && CC_HAS_RANDSTRUCT default RANDSTRUCT_NONE help If you enable this, the layouts of structures that are entirely
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 9/12 ubsan: Fix panic from test_ubsan_out_of_bounds
In reply to Sasha LevinFrom: Mostafa Saleh <[email protected]>
[ Upstream commit 9b044614be12d78d3a93767708b8d02fb7dfa9b0 ]
Running lib_ubsan.ko on arm64 (without CONFIG_UBSAN_TRAP) panics the kernel:
[ 31.616546] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: test_ubsan_out_of_bounds+0x158/0x158 [test_ubsan] [ 31.646817] CPU: 3 UID: 0 PID: 179 Comm: insmod Not tainted 6.15.0-rc2 #1 PREEMPT [ 31.648153] Hardware name: linux,dummy-virt (DT) [ 31.648970] Call trace: [ 31.649345] show_stack+0x18/0x24 (C) [ 31.650960] dump_stack_lvl+0x40/0x84 [ 31.651559] dump_stack+0x18/0x24 [ 31.652264] panic+0x138/0x3b4 [ 31.652812] __ktime_get_real_seconds+0x0/0x10 [ 31.653540] test_ubsan_load_invalid_value+0x0/0xa8 [test_ubsan] [ 31.654388] init_module+0x24/0xff4 [test_ubsan] [ 31.655077] do_one_initcall+0xd4/0x280 [ 31.655680] do_init_module+0x58/0x2b4
That happens because the test corrupts other data in the stack:
400: d5384108 mrs x8, sp_el0 404: f9426d08 ldr x8, [x8, #1240] 408: f85f83a9 ldur x9, [x29, #-8] 40c: eb09011f cmp x8, x9 410: 54000301 b.ne 470 <test_ubsan_out_of_bounds+0x154> // b.any
As there is no guarantee the compiler will order the local variables as declared in the module:
volatile char above[4] = { }; /* Protect surrounding memory. */ volatile int arr[4];
volatile char below[4] = { }; /* Protect surrounding memory. */
There is another problem where the out-of-bound index is 5 which is larger than the extra surrounding memory for protection.
So, use a struct to enforce the ordering, and fix the index to be 4. Also, remove some of the volatiles and rely on OPTIMIZER_HIDE_VAR()
--- lib/test_ubsan.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
lib/test_ubsan.c +11 -7
@@ -35,18 +35,22 @@ static void test_ubsan_shift_out_of_bounds(void)static void test_ubsan_out_of_bounds (void ) { -volatile int i =4 , j =5 , k =-1 ; -volatile char above[4 ] = { };/* Protect surrounding memory. */ -volatile int arr[4 ]; -volatile char below[4 ] = { };/* Protect surrounding memory. */ +int i =4 , j =4 , k =-1 ; +volatile struct { +char above[4 ];/* Protect surrounding memory. */ +int arr[4 ]; +char below[4 ];/* Protect surrounding memory. */ + } data; - above[0 ] = below[0 ]; +OPTIMIZER_HIDE_VAR (i); +OPTIMIZER_HIDE_VAR (j); +OPTIMIZER_HIDE_VAR (k);UBSAN_TEST (CONFIG_UBSAN_BOUNDS ,"above" ); - arr[j] = i; + data.arr[j] = i;UBSAN_TEST (CONFIG_UBSAN_BOUNDS ,"below" ); - arr[k] = i; + data.arr[k] = i; }enum ubsan_test_enum {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 10/12 md/raid1: Add check for missing source disk in process_checks()
In reply to Sasha LevinFrom: Meir Elisha <[email protected]>
[ Upstream commit b7c178d9e57c8fd4238ff77263b877f6f16182ba ]
During recovery/check operations, the process_checks function loops through available disks to find a 'primary' source with successfully read data.
If no suitable source disk is found after checking all possibilities, the 'primary' index will reach conf->raid_disks * 2. Add an explicit check for this condition after the loop. If no source disk was found, print an error message and return early to prevent further processing without a valid primary source.
--- drivers/md/raid1.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/md/raid1.c +16 -10
@@ -2068,14 +2068,9 @@ static int fix_sync_read_error(struct r1bio *r1_bio)if (!rdev_set_badblocks (rdev, sect, s,0 )) abort =1 ; } -if (abort) { - conf->recovery_disabled = - mddev->recovery_disabled; -set_bit (MD_RECOVERY_INTR , &mddev->recovery); -md_done_sync (mddev, r1_bio->sectors,0 ); -put_buf (r1_bio); +if (abort)return 0 ; - } +/* Try next page */ sectors -= s; sect += s;
@@ -2214,10 +2209,21 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)int disks = conf->raid_disks *2 ;struct bio *wbio; -if (!test_bit (R1BIO_Uptodate, &r1_bio->state)) -/* ouch - failed to read all of that. */ -if (!fix_sync_read_error (r1_bio)) +if (!test_bit (R1BIO_Uptodate, &r1_bio->state)) { +/* +* ouch - failed to read all of that. +* No need to fix read error for check/repair +* because all member disks are read. +*/ +if (test_bit (MD_RECOVERY_REQUESTED , &mddev->recovery) || + !fix_sync_read_error (r1_bio)) { + conf->recovery_disabled = mddev->recovery_disabled; +set_bit (MD_RECOVERY_INTR , &mddev->recovery); +md_done_sync (mddev, r1_bio->sectors,0 ); +put_buf (r1_bio);return ; + } + }if (test_bit (MD_RECOVERY_REQUESTED , &mddev->recovery))process_checks (r1_bio);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 11/12 riscv: Avoid fortify warning in syscall_get_arguments()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 1413708f990cb7d025affd706ba9c23e2bfc1a27 ]
When building with CONFIG_FORTIFY_SOURCE=y and W=1, there is a warning because of the memcpy() in syscall_get_arguments():
In file included from include/linux/string.h:392,
from include/linux/bitmap.h:13,
from include/linux/cpumask.h:12,
from arch/riscv/include/asm/processor.h:55,
from include/linux/sched.h:13,
from kernel/ptrace.c:13:
In function 'fortify_memcpy_chk',
inlined from 'syscall_get_arguments.isra' at arch/riscv/include/asm/syscall.h:66:2:
include/linux/fortify-string.h:580:25: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
580 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
The fortified memcpy() routine enforces that the source is not overread and the destination is not overwritten if the size of either field and the size of the copy are known at compile time. The memcpy() in syscall_get_arguments() intentionally overreads from a1 to a5 in 'struct pt_regs' but this is bigger than the size of a1.
Normally, this could be solved by wrapping a1 through a5 with struct_group() but there was already a struct_group() applied to these members in commit bba547810c66 ("riscv: tracing: Fix __write_overflow_field in ftrace_partial_regs()").
Just avoid memcpy() altogether and write the copying of args from regs manually, which clears up the warning at the expense of three extra lines of code.
--- arch/riscv/include/asm/syscall.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/riscv/include/asm/syscall.h +5 -2
@@ -61,8 +61,11 @@ static inline void syscall_get_arguments(struct task_struct *task, unsigned long *args) { args[0 ] = regs->orig_a0; - args++; -memcpy (args, ®s->a1,5 *sizeof (args[0 ])); + args[1 ] = regs->a1; + args[2 ] = regs->a2; + args[3 ] = regs->a3; + args[4 ] = regs->a4; + args[5 ] = regs->a5; }static inline int syscall_get_arch (struct task_struct *task)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 12/12 spi: spi-imx: Add check for spi_imx_setupxfer()
In reply to Sasha LevinFrom: Tamura Dai <[email protected]>
[ Upstream commit 951a04ab3a2db4029debfa48d380ef834b93207e ]
Add check for the return value of spi_imx_setupxfer(). spi_imx->rx and spi_imx->tx function pointer can be NULL when spi_imx_setupxfer() return error, and make NULL pointer dereference.
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: 0x0 spi_imx_pio_transfer+0x50/0xd8 spi_imx_transfer_one+0x18c/0x858 spi_transfer_one_message+0x43c/0x790 __spi_pump_transfer_message+0x238/0x5d4 __spi_sync+0x2b0/0x454 spi_write_then_read+0x11c/0x200
--- drivers/spi/spi-imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-imx.c +4 -1
@@ -1605,10 +1605,13 @@ static int spi_imx_transfer_one(struct spi_controller *controller,struct spi_device *spi, struct spi_transfer *transfer) { + int ret;struct spi_imx_data *spi_imx =spi_controller_get_devdata (spi->controller);unsigned long hz_per_byte, byte_limit; -spi_imx_setupxfer (spi, transfer); + ret =spi_imx_setupxfer (spi, transfer); +if (ret <0 ) +return ret; transfer->effective_speed_hz = spi_imx->spi_bus_clk;/* flush rxfifo before transfer */
Signature · 1 line
2.39.5