Skip to content

Commit d78c5bb

Browse files
committed
Merge branch 'for-7.0-fixes' into for-7.1
2 parents 46a9d97 + e6d7eba commit d78c5bb

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

drivers/ata/libata-core.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,7 +4188,11 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = {
41884188
{ "ST3320[68]13AS", "SD1[5-9]", ATA_QUIRK_NONCQ |
41894189
ATA_QUIRK_FIRMWARE_WARN },
41904190

4191+
/* ADATA devices with LPM issues. */
4192+
{ "ADATA SU680", NULL, ATA_QUIRK_NOLPM },
4193+
41914194
/* Seagate disks with LPM issues */
4195+
{ "ST1000DM010-2EP102", NULL, ATA_QUIRK_NOLPM },
41924196
{ "ST2000DM008-2FR102", NULL, ATA_QUIRK_NOLPM },
41934197

41944198
/* drives which fail FPDMA_AA activation (some may freeze afterwards)
@@ -4231,6 +4235,7 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = {
42314235
/* Devices that do not need bridging limits applied */
42324236
{ "MTRON MSP-SATA*", NULL, ATA_QUIRK_BRIDGE_OK },
42334237
{ "BUFFALO HD-QSU2/R5", NULL, ATA_QUIRK_BRIDGE_OK },
4238+
{ "QEMU HARDDISK", "2.5+", ATA_QUIRK_BRIDGE_OK },
42344239

42354240
/* Devices which aren't very happy with higher link speeds */
42364241
{ "WD My Book", NULL, ATA_QUIRK_1_5_GBPS },
@@ -6274,10 +6279,6 @@ static void ata_port_detach(struct ata_port *ap)
62746279
}
62756280
}
62766281

6277-
/* Make sure the deferred qc work finished. */
6278-
cancel_work_sync(&ap->deferred_qc_work);
6279-
WARN_ON(ap->deferred_qc);
6280-
62816282
/* Tell EH to disable all devices */
62826283
ap->pflags |= ATA_PFLAG_UNLOADING;
62836284
ata_port_schedule_eh(ap);
@@ -6288,9 +6289,11 @@ static void ata_port_detach(struct ata_port *ap)
62886289
/* wait till EH commits suicide */
62896290
ata_port_wait_eh(ap);
62906291

6291-
/* it better be dead now */
6292+
/* It better be dead now and not have any remaining deferred qc. */
62926293
WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6294+
WARN_ON(ap->deferred_qc);
62936295

6296+
cancel_work_sync(&ap->deferred_qc_work);
62946297
cancel_delayed_work_sync(&ap->hotplug_task);
62956298
cancel_delayed_work_sync(&ap->scsi_rescan_task);
62966299

drivers/ata/libata-eh.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,29 @@ int ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
648648
set_host_byte(scmd, DID_OK);
649649

650650
ata_qc_for_each_raw(ap, qc, i) {
651-
if (qc->flags & ATA_QCFLAG_ACTIVE &&
652-
qc->scsicmd == scmd)
651+
if (qc->scsicmd != scmd)
652+
continue;
653+
if ((qc->flags & ATA_QCFLAG_ACTIVE) ||
654+
qc == ap->deferred_qc)
653655
break;
654656
}
655657

656-
if (i < ATA_MAX_QUEUE) {
658+
if (i < ATA_MAX_QUEUE && qc == ap->deferred_qc) {
659+
/*
660+
* This is a deferred command that timed out while
661+
* waiting for the command queue to drain. Since the qc
662+
* is not active yet (deferred_qc is still set, so the
663+
* deferred qc work has not issued the command yet),
664+
* simply signal the timeout by finishing the SCSI
665+
* command and clear the deferred qc to prevent the
666+
* deferred qc work from issuing this qc.
667+
*/
668+
WARN_ON_ONCE(qc->flags & ATA_QCFLAG_ACTIVE);
669+
ap->deferred_qc = NULL;
670+
cancel_work(&ap->deferred_qc_work);
671+
set_host_byte(scmd, DID_TIME_OUT);
672+
scsi_eh_finish_cmd(scmd, &ap->eh_done_q);
673+
} else if (i < ATA_MAX_QUEUE) {
657674
/* the scmd has an associated qc */
658675
if (!(qc->flags & ATA_QCFLAG_EH)) {
659676
/* which hasn't failed yet, timeout */

drivers/ata/libata-scsi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
16991699
*/
17001700
if (qc) {
17011701
ap->deferred_qc = NULL;
1702+
cancel_work(&ap->deferred_qc_work);
17021703
ata_scsi_qc_done(qc, true, DID_SOFT_ERROR << 16);
17031704
}
17041705
}
@@ -3596,7 +3597,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_device *dev,
35963597

35973598
if (cdb[2] != 1 && cdb[2] != 3) {
35983599
ata_dev_warn(dev, "invalid command format %d\n", cdb[2]);
3599-
ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
3600+
ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
36003601
return 0;
36013602
}
36023603

0 commit comments

Comments
 (0)