linux-stable/drivers/scsi/hisi_sas
John Garry 72e5385451 scsi: hisi_sas: Fix rescan after deleting a disk
[ Upstream commit e9dedc13bb ]

Removing an ATA device via sysfs means that the device may not be found
through re-scanning:

root@ubuntu:/home/john# lsscsi
[0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda
[0:0:1:0] disk ATA HGST HUS724040AL A8B0 /dev/sdb
[0:0:8:0] enclosu 12G SAS Expander RevB -
root@ubuntu:/home/john# echo 1 > /sys/block/sdb/device/delete
root@ubuntu:/home/john# echo "- - -" > /sys/class/scsi_host/host0/scan
root@ubuntu:/home/john# lsscsi
[0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda
[0:0:8:0] enclosu 12G SAS Expander RevB -
root@ubuntu:/home/john#

The problem is that the rescan of the device may conflict with the device
in being re-initialized, as follows:

 - In the rescan we call hisi_sas_slave_alloc() in store_scan() ->
   sas_user_scan() -> [__]scsi_scan_target() -> scsi_probe_and_add_lunc()
   -> scsi_alloc_sdev() -> hisi_sas_slave_alloc() -> hisi_sas_init_device()
   In hisi_sas_init_device() we issue an IT nexus reset for ATA devices

 - That IT nexus causes the remote PHY to go down and this triggers a bcast
   event

 - In parallel libsas processes the bcast event, finds that the phy is down
   and marks the device as gone

The hard reset issued in hisi_sas_init_device() is unncessary - as
described in the code comment - so remove it. Also set dev status as
HISI_SAS_DEV_NORMAL as the hisi_sas_init_device() call.

Link: https://lore.kernel.org/r/1652354134-171343-4-git-send-email-john.garry@huawei.com
Fixes: 36c6b7613e ("scsi: hisi_sas: Initialise devices in .slave_alloc callback")
Tested-by: Yihang Li <liyihang6@hisilicon.com>
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:56 +02:00
..
hisi_sas.h scsi: hisi_sas: Keep controller active between ISR of phyup and the event being processed 2021-12-22 23:38:31 -05:00
hisi_sas_main.c scsi: hisi_sas: Fix rescan after deleting a disk 2022-06-09 10:25:56 +02:00
hisi_sas_v1_hw.c scsi: hisi_sas: Switch to attribute groups 2021-10-16 21:45:55 -04:00
hisi_sas_v2_hw.c scsi: hisi_sas: Switch to attribute groups 2021-10-16 21:45:55 -04:00
hisi_sas_v3_hw.c scsi: hisi_sas: Undo RPM resume for failed notify phy event for v3 HW 2022-06-09 10:25:25 +02:00
Kconfig
Makefile