History

Merge tag 'ata-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux

Pull ata fixes from Damien Le Moal: - Fix PCI resource initialization in the sata_mv driver to keep legacy Marvell boards functional (Rosen) - Fix ahci_ceva driver initialization error path (Radhey) - Fix libata header file to remove a kernel doc compilation warning (Randy) - Increase the timeout for the STANDBY IMMEDIATE command to avoid suspend failures with drives that are slow to respond to this command (Matt) - Fixes for the handling of timed out commands in the presence of deferred non-NCQ commands, to avoid excessive delays in executing the error handler (me) - Disable link power management for a couple of WD drives that have been identified as not functioning properly when power management is used (Niklas) - Fix the device iteration loop when checking for link power management support to correctly handle port multiplier setups (Niklas) * tag 'ata-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ata: libata-sata: fix ata_scsi_lpm_supported() iteration ata: libata-core: Disable LPM on WD Green 2.5 480GB ata: libata-core: Disable LPM on some WD drives scsi: libsas: terminate deferred commands on time out ata: libata-scsi: schedule deferred atapi command ata: libata-scsi: terminate deferred commands on time out ata: libata-eh: Increase STANDBY IMMEDIATE timeout ata: libata: avoid kernel-doc warnings ata: ahci_ceva: fix error paths in ceva_ahci_platform_enable_resources() ata: sata_mv: accept 1 or 2 resources in platform probe

Linus Torvalds committed 3 months ago

Commit f30ca2c2 parents f01618f 3fd70e911 files · +173 −46Browse files

Unified · Split

11 files
  1. drivers/ata/ahci_ceva.c +14 −4
  2. drivers/ata/libata-core.c +9 −0
  3. drivers/ata/libata-eh.c +14 −23
  4. drivers/ata/libata-sata.c +1 −1
  5. drivers/ata/libata-scsi.c +107 −12
  6. drivers/ata/libata.h +2 −1
  7. drivers/ata/sata_mv.c +1 −1
  8. drivers/scsi/libsas/sas_scsi_host.c +15 −0
  9. include/linux/ata.h +3 −3
  10. include/linux/libata.h +5 −1
  11. include/scsi/libsas.h +2 −0
drivers/ata/ahci_ceva.c+14−4
@@ -211,7 +211,7 @@ static int ceva_ahci_platform_enable_resources(struct ahci_host_priv *hpriv) · 210 unmodified lines
211211
212212 rc = phy_init(hpriv->phys[i]);
213213 if (rc)
214− goto disable_rsts;
214+ goto exit_phys;
215215 }
216216
217217 /* De-assert the controller reset */
@@ -230,14 +230,24 @@ static int ceva_ahci_platform_enable_resources(struct ahci_host_priv *hpriv) · 12 unmodified lines
230230
231231 return 0;
232232
233−disable_rsts:
234− ahci_platform_deassert_rsts(hpriv);
235−
236233 disable_phys:
237234 while (--i >= 0) {
235+ if (ahci_ignore_port(hpriv, i))
236+ continue;
237+
238238 phy_power_off(hpriv->phys[i]);
239239 phy_exit(hpriv->phys[i]);
240240 }
241+ ahci_platform_assert_rsts(hpriv);
242+ goto disable_clks;
243+
244+exit_phys:
245+ while (--i >= 0) {
246+ if (ahci_ignore_port(hpriv, i))
247+ continue;
248+
249+ phy_exit(hpriv->phys[i]);
250+ }
241251
242252 disable_clks:
243253 ahci_platform_disable_clks(hpriv);
drivers/ata/libata-core.c+9−0
@@ -4413,6 +4413,15 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { · 4412 unmodified lines
44134413 { "WDC WD3000JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM },
44144414 { "WDC WD3200JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM },
44154415
4416+ /*
4417+ * WD drives with LPM issues (irrespective of supported SATA speeds).
4418+ * (Unlike ATA_QUIRK_WD_BROKEN_LPM, which is only applied if the drive
4419+ * exposes SATA Gen1 speed support, and SATA Gen1 speed support only.)
4420+ */
4421+ { "WDC WD100EFGX-68CPLN0", NULL, ATA_QUIRK_NOLPM },
4422+ { "WDC WD102KFBX-68M95N0", NULL, ATA_QUIRK_NOLPM },
4423+ { "WD Green 2.5 480GB", NULL, ATA_QUIRK_NOLPM },
4424+
44164425 /*
44174426 * This sata dom device goes on a walkabout when the ATA_LOG_DIRECTORY
44184427 * log page is accessed. Ensure we never ask for this log page with
drivers/ata/libata-eh.c+14−23
@@ -106,6 +106,12 @@ static const unsigned int ata_eh_flush_timeouts[] = { · 105 unmodified lines
106106 UINT_MAX,
107107 };
108108
109+static const unsigned int ata_eh_standby_timeouts[] = {
110+ 15000, /* Some drives may be slow to standby */
111+ /* but don't hold up a suspend too long waiting for them */
112+ UINT_MAX,
113+};
114+
109115 static const unsigned int ata_eh_other_timeouts[] = {
110116 5000, /* same rationale as identify timeout */
111117 10000, /* ditto */
@@ -147,6 +153,8 @@ ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = { · 35 unmodified lines
147153 .timeouts = ata_eh_other_timeouts, },
148154 { .commands = CMDS(ATA_CMD_FLUSH, ATA_CMD_FLUSH_EXT),
149155 .timeouts = ata_eh_flush_timeouts },
156+ { .commands = CMDS(ATA_CMD_STANDBYNOW1),
157+ .timeouts = ata_eh_standby_timeouts },
150158 { .commands = CMDS(ATA_CMD_VERIFY),
151159 .timeouts = ata_eh_reset_timeouts },
152160 };
@@ -650,29 +658,12 @@ int ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, · 497 unmodified lines
650658 set_host_byte(scmd, DID_OK);
651659
652660 ata_qc_for_each_raw(ap, qc, i) {
653− if (qc->scsicmd != scmd)
654− continue;
655− if ((qc->flags & ATA_QCFLAG_ACTIVE) ||
656− qc == qc->dev->link->deferred_qc)
661+ if (qc->scsicmd == scmd &&
662+ qc->flags & ATA_QCFLAG_ACTIVE)
657663 break;
658664 }
659665
660− if (i < ATA_MAX_QUEUE && qc == qc->dev->link->deferred_qc) {
661− /*
662− * This is a deferred command that timed out while
663− * waiting for the command queue to drain. Since the qc
664− * is not active yet (deferred_qc is still set, so the
665− * deferred qc work has not issued the command yet),
666− * simply signal the timeout by finishing the SCSI
667− * command and clear the deferred qc to prevent the
668− * deferred qc work from issuing this qc.
669− */
670− WARN_ON_ONCE(qc->flags & ATA_QCFLAG_ACTIVE);
671− qc->dev->link->deferred_qc = NULL;
672− cancel_work(&qc->dev->link->deferred_qc_work);
673− set_host_byte(scmd, DID_TIME_OUT);
674− scsi_eh_finish_cmd(scmd, &ap->eh_done_q);
675− } else if (i < ATA_MAX_QUEUE) {
666+ if (i < ATA_MAX_QUEUE) {
676667 /* the scmd has an associated qc */
677668 if (!(qc->flags & ATA_QCFLAG_EH)) {
678669 /* which hasn't failed yet, timeout */
@@ -948,10 +939,10 @@ static void ata_eh_set_pending(struct ata_port *ap, bool fastdrain) · 269 unmodified lines
948939 ap->pflags |= ATA_PFLAG_EH_PENDING;
949940
950941 /*
951− * If we have a deferred qc, requeue it so that it is retried once EH
952− * completes.
942+ * If we have deferred QCs, requeue them so that the SCSI EH task can
943+ * run.
953944 */
954− ata_scsi_requeue_deferred_qc(ap);
945+ ata_scsi_requeue_deferred_qc(ap, NULL);
955946
956947 if (!fastdrain)
957948 return;
drivers/ata/libata-sata.c+1−1
@@ -913,7 +913,7 @@ static bool ata_scsi_lpm_supported(struct ata_port *ap) · 912 unmodified lines
913913 return false;
914914
915915 ata_for_each_link(link, ap, EDGE) {
916− ata_for_each_dev(dev, &ap->link, ENABLED) {
916+ ata_for_each_dev(dev, link, ENABLED) {
917917 if (dev->quirks & ATA_QUIRK_NOLPM)
918918 return false;
919919 }
drivers/ata/libata-scsi.c+107−12
@@ -1685,26 +1685,80 @@ void ata_scsi_deferred_qc_work(struct work_struct *work) · 1684 unmodified lines
16851685 spin_unlock_irqrestore(ap->lock, flags);
16861686 }
16871687
1688−void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
1688+enum scsi_timeout_action ata_scsi_requeue_deferred_qc(struct ata_port *ap,
1689+ struct scsi_cmnd *timedout_scmd)
16891690 {
1691+ enum scsi_timeout_action action = SCSI_EH_NOT_HANDLED;
1692+ struct ata_queued_cmd *qc;
16901693 struct ata_link *link;
1694+ u32 host_byte;
16911695
16921696 lockdep_assert_held(ap->lock);
16931697
16941698 /*
1695− * If we have a deferred qc when a reset occurs or NCQ commands fail,
1696− * do not try to be smart about what to do with this deferred command
1697− * and simply requeue it by completing it with DID_REQUEUE.
1699+ * If we have deferred QCs when a reset, a timeout or an NCQ command
1700+ * fails, do not try to be smart about what to do with the deferred
1701+ * commands and simply terminate them and let the SCSI layer decide
1702+ * what to do.
16981703 */
16991704 ata_for_each_link(link, ap, PMP_FIRST) {
1700− struct ata_queued_cmd *qc = link->deferred_qc;
1705+ qc = link->deferred_qc;
1706+ if (!qc)
1707+ continue;
17011708
1702− if (qc) {
1703− link->deferred_qc = NULL;
1704− cancel_work(&link->deferred_qc_work);
1705− ata_scsi_qc_done(qc, true, DID_REQUEUE << 16);
1709+ /*
1710+ * Clear the deferred QC so that the deferred work does not try
1711+ * to issue it.
1712+ */
1713+ link->deferred_qc = NULL;
1714+ cancel_work(&link->deferred_qc_work);
1715+
1716+ /*
1717+ * We are going to complete some scsi command, either with
1718+ * DID_TIME_OUT if the command timed out while waiting for being
1719+ * issued, or with DID_REQUEUE if another command timed out or
1720+ * we had a failed command. However, the block layer may re-issue
1721+ * these commands immediately, keeping the scsi host busy and
1722+ * thus preventing the SCSI EH task from running.
1723+ * So schedule EH on the port to prevent accepting new commands
1724+ * until everything is sorted out with the error or timeout that
1725+ * got us here in the first place. Note that we set EH pending
1726+ * on the port before calling ata_port_schedule_eh() so that we
1727+ * do not reenter this function from ata_eh_set_pending() with
1728+ * timedout_scmd being NULL and erroneously retry deferred QCs
1729+ * that have timed out on other links.
1730+ */
1731+ if (!ata_port_eh_scheduled(ap)) {
1732+ ap->pflags |= ATA_PFLAG_EH_PENDING;
1733+ ata_port_schedule_eh(ap);
17061734 }
1735+
1736+ /*
1737+ * If we are being called from scsi_timeout(), then we have a
1738+ * non-NULL timedout_scmd. If the timed out command is for a
1739+ * deferred QC, terminate that deferred QC with DID_TIME_OUT and
1740+ * requeue all other deferred QCs. In this case we need to
1741+ * return SCSI_EH_DONE, because the timed out command was
1742+ * handled.
1743+ * If the timed out command is not for a deferred QC, we need to
1744+ * requeue all deferred QCs, and return SCSI_EH_NOT_HANDLED so
1745+ * that the timed out command gets added to the EH work queue
1746+ * with scsi_eh_scmd_add(), for later handling with libata EH
1747+ * ata_scsi_cmd_error_handler().
1748+ * If timedout_scmd is NULL, we simply need to requeue all
1749+ * deferred QCs and the return value does not matter as we were
1750+ * not called from scsi_timeout().
1751+ */
1752+ if (timedout_scmd && qc->scsicmd == timedout_scmd) {
1753+ host_byte = DID_TIME_OUT;
1754+ action = SCSI_EH_DONE;
1755+ } else {
1756+ host_byte = DID_REQUEUE;
1757+ }
1758+ ata_scsi_qc_done(qc, true, host_byte << 16);
17071759 }
1760+
1761+ return action;
17081762 }
17091763
17101764 static void ata_scsi_schedule_deferred_qc(struct ata_link *link)
@@ -1723,13 +1777,42 @@ static void ata_scsi_schedule_deferred_qc(struct ata_link *link) · 12 unmodified lines
17231777 return;
17241778
17251779 if (ata_port_eh_scheduled(ap)) {
1726− ata_scsi_requeue_deferred_qc(ap);
1780+ ata_scsi_requeue_deferred_qc(ap, NULL);
17271781 return;
17281782 }
17291783 if (!ap->ops->qc_defer(qc))
17301784 queue_work(system_highpri_wq, &link->deferred_qc_work);
17311785 }
17321786
1787+enum scsi_timeout_action ata_scsi_retry_deferred_qc(struct ata_port *ap,
1788+ struct scsi_cmnd *scmd)
1789+{
1790+ enum scsi_timeout_action action;
1791+ unsigned long flags;
1792+
1793+ spin_lock_irqsave(ap->lock, flags);
1794+ action = ata_scsi_requeue_deferred_qc(ap, scmd);
1795+ spin_unlock_irqrestore(ap->lock, flags);
1796+
1797+ return action;
1798+}
1799+EXPORT_SYMBOL_GPL(ata_scsi_retry_deferred_qc);
1800+
1801+enum scsi_timeout_action ata_scsi_eh_timed_out(struct scsi_cmnd *scmd)
1802+{
1803+ struct ata_port *ap = ata_shost_to_port(scmd->device->host);
1804+
1805+ /*
1806+ * ata_scsi_cmd_error_handler() takes care of commands that timed out
1807+ * while executing. However, if we have deferred QCs while a timeout
1808+ * triggers, we must requeue these commands for retry so that we do not
1809+ * unnecessarily delay starting the SCSI EH task until these deferred
1810+ * commands also time out.
1811+ */
1812+ return ata_scsi_retry_deferred_qc(ap, scmd);
1813+}
1814+EXPORT_SYMBOL_GPL(ata_scsi_eh_timed_out);
1815+
17331816 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
17341817 {
17351818 struct ata_link *link = qc->dev->link;
@@ -2911,6 +2994,7 @@ static void atapi_fixup_inquiry(struct scsi_cmnd *cmd) · 1175 unmodified lines
29112994
29122995 static void atapi_qc_complete(struct ata_queued_cmd *qc)
29132996 {
2997+ struct ata_link *link = qc->dev->link;
29142998 struct scsi_cmnd *cmd = qc->scsicmd;
29152999 unsigned int err_mask = qc->err_mask;
29163000
@@ -2936,8 +3020,16 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) · 19 unmodified lines
29363020 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
29373021 qc->dev->sdev->locked = 0;
29383022
2939− ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION);
2940− return;
3023+ if (cmd->result)
3024+ ata_scsi_qc_done(qc, false, 0);
3025+ else
3026+ ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION);
3027+ goto schedule_deferred;
3028+ }
3029+
3030+ if (cmd->result) {
3031+ ata_scsi_qc_done(qc, false, 0);
3032+ goto schedule_deferred;
29413033 }
29423034
29433035 /* successful completion path */
@@ -2945,6 +3037,9 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) · 1 unmodified line
29453037 atapi_fixup_inquiry(cmd);
29463038
29473039 ata_scsi_qc_done(qc, true, SAM_STAT_GOOD);
3040+
3041+schedule_deferred:
3042+ ata_scsi_schedule_deferred_qc(link);
29483043 }
29493044 /**
29503045 * atapi_xlat - Initialize PACKET taskfile
drivers/ata/libata.h+2−1
@@ -180,7 +180,8 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · 179 unmodified lines
180180 struct ata_port *ap)
181181 __must_hold(ap->lock);
182182 void ata_scsi_deferred_qc_work(struct work_struct *work);
183−void ata_scsi_requeue_deferred_qc(struct ata_port *ap);
183+enum scsi_timeout_action ata_scsi_requeue_deferred_qc(struct ata_port *ap,
184+ struct scsi_cmnd *scmd);
184185
185186 /* libata-eh.c */
186187 extern unsigned int ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd);
drivers/ata/sata_mv.c+1−1
@@ -4027,7 +4027,7 @@ static int mv_platform_probe(struct platform_device *pdev) · 4026 unmodified lines
40274027 /*
40284028 * Simple resource validation ..
40294029 */
4030− if (unlikely(pdev->num_resources != 1)) {
4030+ if (unlikely(pdev->num_resources != 1 && pdev->num_resources != 2)) {
40314031 dev_err(&pdev->dev, "invalid number of resources\n");
40324032 return -EINVAL;
40334033 }
drivers/scsi/libsas/sas_scsi_host.c+15−0
@@ -502,6 +502,21 @@ int sas_eh_target_reset_handler(struct scsi_cmnd *cmd) · 501 unmodified lines
502502 }
503503 EXPORT_SYMBOL_GPL(sas_eh_target_reset_handler);
504504
505+/*
506+ * Handle deferred QCs in case of a command timeout.
507+ * See ata_scsi_eh_timed_out() for details.
508+ */
509+enum scsi_timeout_action sas_eh_timed_out(struct scsi_cmnd *cmd)
510+{
511+ struct domain_device *dev = cmd_to_domain_dev(cmd);
512+
513+ if (dev_is_sata(dev))
514+ return ata_scsi_retry_deferred_qc(dev->sata_dev.ap, cmd);
515+
516+ return SCSI_EH_NOT_HANDLED;
517+}
518+EXPORT_SYMBOL_GPL(sas_eh_timed_out);
519+
505520 /* Try to reset a device */
506521 static int try_to_reset_cmd_device(struct scsi_cmnd *cmd)
507522 {
include/linux/ata.h+3−3
@@ -762,8 +762,7 @@ static inline bool ata_id_sense_reporting_enabled(const u16 *id) · 761 unmodified lines
762762 return id[ATA_ID_COMMAND_SET_4] & BIT(6);
763763 }
764764
765−/**
766− *
765+/*
767766 * Word: 206 - SCT Command Transport
768767 * 15:12 - Vendor Specific
769768 * 11:6 - Reserved
@@ -810,8 +809,9 @@ static inline bool ata_id_sct_supported(const u16 *id) · 40 unmodified lines
810809 *
811810 * The practical impact of this is that ata_id_major_version cannot
812811 * reliably report on drives below ATA3.
812+ *
813+ * Returns: major version of ATA drive level or %0 if unknown
813814 */
814−
815815 static inline unsigned int ata_id_major_version(const u16 *id)
816816 {
817817 unsigned int mver;
include/linux/libata.h+5−1
@@ -425,7 +425,7 @@ enum { · 424 unmodified lines
425425 /* This should match the actual table size of
426426 * ata_eh_cmd_timeout_table in libata-eh.c.
427427 */
428− ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 8,
428+ ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 9,
429429
430430 /* User visible DMA mask for DMA control. DO NOT renumber. */
431431 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */
@@ -1153,6 +1153,9 @@ extern int ata_scsi_ioctl(struct scsi_device *dev, unsigned int cmd, · 721 unmodified lines
11531153 #endif
11541154 extern enum scsi_qc_status ata_scsi_queuecmd(struct Scsi_Host *h,
11551155 struct scsi_cmnd *cmd);
1156+enum scsi_timeout_action ata_scsi_retry_deferred_qc(struct ata_port *ap,
1157+ struct scsi_cmnd *scmd);
1158+enum scsi_timeout_action ata_scsi_eh_timed_out(struct scsi_cmnd *cmd);
11561159 #if IS_REACHABLE(CONFIG_ATA)
11571160 bool ata_scsi_dma_need_drain(struct request *rq);
11581161 #else
@@ -1464,6 +1467,7 @@ extern const struct attribute_group *ata_common_sdev_groups[]; · 305 unmodified lines
14641467 .ioctl = ata_scsi_ioctl, \
14651468 ATA_SCSI_COMPAT_IOCTL \
14661469 .queuecommand = ata_scsi_queuecmd, \
1470+ .eh_timed_out = ata_scsi_eh_timed_out, \
14671471 .dma_need_drain = ata_scsi_dma_need_drain, \
14681472 .this_id = ATA_SHT_THIS_ID, \
14691473 .emulated = ATA_SHT_EMULATED, \
include/scsi/libsas.h+2−0
@@ -705,6 +705,7 @@ void sas_task_abort(struct sas_task *); · 704 unmodified lines
705705 int sas_eh_abort_handler(struct scsi_cmnd *cmd);
706706 int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
707707 int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
708+enum scsi_timeout_action sas_eh_timed_out(struct scsi_cmnd *cmd);
708709
709710 extern void sas_target_destroy(struct scsi_target *);
710711 extern int sas_sdev_init(struct scsi_device *);
@@ -743,6 +744,7 @@ void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, · 32 unmodified lines
743744 .this_id = -1, \
744745 .eh_device_reset_handler = sas_eh_device_reset_handler, \
745746 .eh_target_reset_handler = sas_eh_target_reset_handler, \
747+ .eh_timed_out = sas_eh_timed_out, \
746748 .target_destroy = sas_target_destroy, \
747749 .ioctl = sas_ioctl, \
748750