• John Garry's avatar
    scsi: hisi_sas: Fix rescan after deleting a disk · e9dedc13
    John Garry authored
    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: 36c6b761 ("scsi: hisi_sas: Initialise devices in .slave_alloc callback")
    Tested-by: default avatarYihang Li <liyihang6@hisilicon.com>
    Reviewed-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
    Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    e9dedc13
hisi_sas_main.c 65 KB