linux-brain/drivers/scsi/pm8001
Yufen Yu d7b647d055 scsi: libsas: Add LUN number check in .slave_alloc callback
[ Upstream commit 49da96d77938db21864dae6b7736b71e96c1d203 ]

Offlining a SATA device connected to a hisi SAS controller and then
scanning the host will result in detecting 255 non-existent devices:

  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:2:0]    disk    SEAGATE  ST600MM0006      B001  /dev/sdc
  # echo "offline" > /sys/block/sdb/device/state
  # echo "- - -" > /sys/class/scsi_host/host2/scan
  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:1:1]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdh
  ...
  [2:0:1:255]  disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdjb

After a REPORT LUN command issued to the offline device fails, the SCSI
midlayer tries to do a sequential scan of all devices whose LUN number is
not 0. However, SATA does not support LUN numbers at all.

Introduce a generic sas_slave_alloc() handler which will return -ENXIO for
SATA devices if the requested LUN number is larger than 0 and make libsas
drivers use this function as their .slave_alloc callback.

Link: https://lore.kernel.org/r/20210622034037.1467088-1-yuyufen@huawei.com
Reported-by: Wu Bo <wubo40@huawei.com>
Suggested-by: John Garry <john.garry@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-25 14:35:13 +02:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pm80xx_hwi.c scsi: pm80xx: Fix for SATA device discovery 2020-01-04 19:18:14 +01:00
pm80xx_hwi.h scsi: pm80xx: Fixed kernel panic during error recovery for SATA drive 2019-07-11 20:35:21 -04:00
pm8001_chips.h
pm8001_ctl.c scsi: pm80xx: Modified the logic to collect IOP event logs 2019-06-27 00:03:21 -04:00
pm8001_ctl.h
pm8001_defs.h scsi: pm80xx: Fix for phy enable/disable functionality 2018-09-11 21:13:08 -04:00
pm8001_hwi.c scsi: libsas: aic94xx: hisi_sas: mvsas: pm8001: Use dev_is_expander() 2019-06-20 15:37:02 -04:00
pm8001_hwi.h scsi: pm80xx: Fix for phy enable/disable functionality 2018-09-11 21:13:08 -04:00
pm8001_init.c scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:35:13 +02:00
pm8001_sas.c scsi: pm80xx: Cleanup command when a reset times out 2020-10-01 13:17:20 +02:00
pm8001_sas.h scsi: libsas: aic94xx: hisi_sas: mvsas: pm8001: Use dev_is_expander() 2019-06-20 15:37:02 -04:00