@@ -708,20 +708,15 @@ void scsi_cdl_check(struct scsi_device *sdev)
int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
{
char buf[64];
- bool is_ata;
int ret;
if (!sdev->cdl_supported)
return -EOPNOTSUPP;
- rcu_read_lock();
- is_ata = rcu_dereference(sdev->vpd_pg89);
- rcu_read_unlock();
-
/*
* For ATA devices, CDL needs to be enabled with a SET FEATURES command.
*/
- if (is_ata) {
+ if (sdev->is_ata) {
struct scsi_mode_data data;
struct scsi_sense_hdr sshdr;
char *buf_data;
@@ -909,7 +909,8 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
sdev->model = (char *) (sdev->inquiry + 16);
sdev->rev = (char *) (sdev->inquiry + 32);
- if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
+ sdev->is_ata = strncmp(sdev->vendor, "ATA ", 8) == 0;
+ if (sdev->is_ata) {
/*
* sata emulation layer device. This is a hack to work around
* the SATL power management specifications which state that
@@ -184,6 +184,11 @@ struct scsi_device {
*/
unsigned force_runtime_start_on_system_start:1;
+ /*
+ * Set if the device is an ATA device.
+ */
+ unsigned is_ata:1;
+
unsigned removable:1;
unsigned changed:1; /* Data invalid due to media change */
unsigned busy:1; /* Used to prevent races */
scsi_add_lun() tests the device vendor string of SCSI devices to detect if a SCSI device is in fact an ATA device, in order to correctly handle SATL power management. The function scsi_cdl_enable() also requires knowing if a SCSI device is an ATA device to control the state of the device CDL feature but this function does that by testing for the presence of the VPD page 89h (ATA INFORMATION page). Simplify these different methods by adding the is_ata field to struct scsi_device to remember that a SCSI device is in fact an ATA one based on the device vendor name test. This filed can also allow low level SCSI host adapter drivers to take special actions for ATA devices (e.g. to better handle ATA NCQ errors). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> --- drivers/scsi/scsi.c | 7 +------ drivers/scsi/scsi_scan.c | 3 ++- include/scsi/scsi_device.h | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-)