Skip to content

Commit 8f2975c

Browse files
committed
Merge tag 'ata-6.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata fixes from Damien Le Moal: "Several libata generic code fixes for rc5: - Add missing translation of the SYNCHRONIZE CACHE 16 scsi command as this command is mandatory for host-managed ZBC drives. The lack of support for it in libata-scsi was causing issues with some passthrough applications using ZBC drives (from Shin'ichiro). - Fix the error path of libata-transport host, port, link and device attributes initialization (from Yingliang). - Prevent issuing new commands to a drive that is in the NCQ error state and undergoing recovery (From Niklas). This bug went unnoticed for a long time as commands issued to a drive in error state are aborted immediately and retried by the scsi layer, hiding the useless abort-and-retry sequence" * tag 'ata-6.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: ata: libata-core: do not issue non-internal commands once EH is pending ata: libata-transport: fix error handling in ata_tdev_add() ata: libata-transport: fix error handling in ata_tlink_add() ata: libata-transport: fix error handling in ata_tport_add() ata: libata-transport: fix double ata_host_put() in ata_tport_add() ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure
2 parents d7c2b1f + e20e81a commit 8f2975c

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

drivers/ata/libata-scsi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,6 +3264,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
32643264
case REPORT_LUNS:
32653265
case REQUEST_SENSE:
32663266
case SYNCHRONIZE_CACHE:
3267+
case SYNCHRONIZE_CACHE_16:
32673268
case REZERO_UNIT:
32683269
case SEEK_6:
32693270
case SEEK_10:
@@ -3922,6 +3923,7 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
39223923
return ata_scsi_write_same_xlat;
39233924

39243925
case SYNCHRONIZE_CACHE:
3926+
case SYNCHRONIZE_CACHE_16:
39253927
if (ata_try_flush_cache(dev))
39263928
return ata_scsi_flush_xlat;
39273929
break;
@@ -3962,9 +3964,19 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
39623964

39633965
int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev)
39643966
{
3967+
struct ata_port *ap = dev->link->ap;
39653968
u8 scsi_op = scmd->cmnd[0];
39663969
ata_xlat_func_t xlat_func;
39673970

3971+
/*
3972+
* scsi_queue_rq() will defer commands if scsi_host_in_recovery().
3973+
* However, this check is done without holding the ap->lock (a libata
3974+
* specific lock), so we can have received an error irq since then,
3975+
* therefore we must check if EH is pending, while holding ap->lock.
3976+
*/
3977+
if (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS))
3978+
return SCSI_MLQUEUE_DEVICE_BUSY;
3979+
39683980
if (unlikely(!scmd->cmd_len))
39693981
goto bad_cdb_len;
39703982

@@ -4145,6 +4157,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
41454157
* turning this into a no-op.
41464158
*/
41474159
case SYNCHRONIZE_CACHE:
4160+
case SYNCHRONIZE_CACHE_16:
41484161
fallthrough;
41494162

41504163
/* no-op's, complete with success */

drivers/ata/libata-transport.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ int ata_tport_add(struct device *parent,
301301
pm_runtime_enable(dev);
302302
pm_runtime_forbid(dev);
303303

304-
transport_add_device(dev);
304+
error = transport_add_device(dev);
305+
if (error)
306+
goto tport_transport_add_err;
305307
transport_configure_device(dev);
306308

307309
error = ata_tlink_add(&ap->link);
@@ -312,12 +314,12 @@ int ata_tport_add(struct device *parent,
312314

313315
tport_link_err:
314316
transport_remove_device(dev);
317+
tport_transport_add_err:
315318
device_del(dev);
316319

317320
tport_err:
318321
transport_destroy_device(dev);
319322
put_device(dev);
320-
ata_host_put(ap->host);
321323
return error;
322324
}
323325

@@ -456,7 +458,9 @@ int ata_tlink_add(struct ata_link *link)
456458
goto tlink_err;
457459
}
458460

459-
transport_add_device(dev);
461+
error = transport_add_device(dev);
462+
if (error)
463+
goto tlink_transport_err;
460464
transport_configure_device(dev);
461465

462466
ata_for_each_dev(ata_dev, link, ALL) {
@@ -471,6 +475,7 @@ int ata_tlink_add(struct ata_link *link)
471475
ata_tdev_delete(ata_dev);
472476
}
473477
transport_remove_device(dev);
478+
tlink_transport_err:
474479
device_del(dev);
475480
tlink_err:
476481
transport_destroy_device(dev);
@@ -708,7 +713,13 @@ static int ata_tdev_add(struct ata_device *ata_dev)
708713
return error;
709714
}
710715

711-
transport_add_device(dev);
716+
error = transport_add_device(dev);
717+
if (error) {
718+
device_del(dev);
719+
ata_tdev_free(ata_dev);
720+
return error;
721+
}
722+
712723
transport_configure_device(dev);
713724
return 0;
714725
}

0 commit comments

Comments
 (0)