Commit 8ecd28b7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ata-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata

Pull ata updates from Damien Le Moal:
 "The ususal set of driver fixes and improvements as well as several
  patches improving libata core in preparation of the introduction of
  the support for the command duration limits feature. In more details:

   - Define the missing COMPLETED sense key in scsi header (me)

   - Several patches to improve libata handling of the status of
     completed commands and the retry and sense data reported to the
     scsi layer for failed commands. In particular, this widen the
     support for NCQ autosense to all drives that support this feature
     instead of restricting this feature use to ZAC drives only (Niklas)

   - Cleanup of the pata_mpc52xx and sata_dwc_460ex drivers to remove
     the use of the deprecated NO_IRQ macro (Christophe)

   - Fix build dedependency on OF vs use of the of_match_ptr() macro to
     avoid build errors with the sata_gemini and pata_ftide010 drivers
     (me)

   - Some libata cleanups using the new helper function
     ata_port_is_frozen() (Niklas)

   - Improve internal command handling by not retrying commands that
     failed with a timeout (Niklas)

   - Remove code for several unused libata helper functions (from
     Niklas)

   - Remove the palmchip pata_bk3710 driver. A couple of other driver
     removal should come in through the arm tree pull request (from
     Arnd)

   - Remove unused variable and function in the sata_dwc_460ex driver
     and libata-sff code (Colin and Sergey)

   - Minor cleanup of the pata_ep93xx driver platform code (from
     Minghao)

   - Remove the unnecessary linux/msi.h include from the ahci driver
     (Thomas)

   - Changes to libata enum constants definitions to avoid warnings with
     gcc-13 (Arnd)"

* tag 'ata-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: (24 commits)
  ata: ahci: fix enum constants for gcc-13
  ata: libata: fix commands incorrectly not getting retried during NCQ error
  ata: ahci: Remove linux/msi.h include
  ata: sata_dwc_460ex: Check !irq instead of irq == NO_IRQ
  ata: pata_ep93xx: use devm_platform_get_and_ioremap_resource()
  ata: libata-sff: kill unused ata_sff_busy_sleep()
  ata: sata_dwc_460ex: remove variable num_processed
  ata: remove palmchip pata_bk3710 driver
  ata: remove unused helper ata_id_flush_ext_enabled()
  ata: remove unused helper ata_id_flush_enabled()
  ata: remove unused helper ata_id_lba48_enabled()
  ata: libata-core: do not retry reading the log on timeout
  scsi: libsas: make use of ata_port_is_frozen() helper
  ata: make use of ata_port_is_frozen() helper
  ata: add ata_port_is_frozen() helper
  ata: pata_ftide010: Remove build dependency on OF
  ata: sata_gemini: Remove dependency on OF for compile tests
  ata: pata_mpc52xx: Replace NO_IRQ with 0
  ata: libahci: read correct status and error field for NCQ commands
  ata: libata: fetch sense data for ATA devices supporting sense reporting
  ...
parents ce8a79d5 f0778807
...@@ -295,7 +295,7 @@ config SATA_FSL ...@@ -295,7 +295,7 @@ config SATA_FSL
config SATA_GEMINI config SATA_GEMINI
tristate "Gemini SATA bridge support" tristate "Gemini SATA bridge support"
depends on ARCH_GEMINI || (OF && COMPILE_TEST) depends on ARCH_GEMINI || COMPILE_TEST
select SATA_HOST select SATA_HOST
default ARCH_GEMINI default ARCH_GEMINI
help help
...@@ -609,16 +609,6 @@ config PATA_ATP867X ...@@ -609,16 +609,6 @@ config PATA_ATP867X
If unsure, say N. If unsure, say N.
config PATA_BK3710
tristate "Palmchip BK3710 PATA support"
depends on ARCH_DAVINCI || COMPILE_TEST
select PATA_TIMINGS
help
This option enables support for the integrated IDE controller on
the TI DaVinci SoC.
If unsure, say N.
config PATA_CMD64X config PATA_CMD64X
tristate "CMD64x PATA support" tristate "CMD64x PATA support"
depends on PCI depends on PCI
...@@ -696,7 +686,6 @@ config PATA_EP93XX ...@@ -696,7 +686,6 @@ config PATA_EP93XX
config PATA_FTIDE010 config PATA_FTIDE010
tristate "Faraday Technology FTIDE010 PATA support" tristate "Faraday Technology FTIDE010 PATA support"
depends on OF
depends on ARM || COMPILE_TEST depends on ARM || COMPILE_TEST
depends on SATA_GEMINI depends on SATA_GEMINI
help help
......
...@@ -54,7 +54,6 @@ obj-$(CONFIG_PATA_AMD) += pata_amd.o ...@@ -54,7 +54,6 @@ obj-$(CONFIG_PATA_AMD) += pata_amd.o
obj-$(CONFIG_PATA_ARTOP) += pata_artop.o obj-$(CONFIG_PATA_ARTOP) += pata_artop.o
obj-$(CONFIG_PATA_ATIIXP) += pata_atiixp.o obj-$(CONFIG_PATA_ATIIXP) += pata_atiixp.o
obj-$(CONFIG_PATA_ATP867X) += pata_atp867x.o obj-$(CONFIG_PATA_ATP867X) += pata_atp867x.o
obj-$(CONFIG_PATA_BK3710) += pata_bk3710.o
obj-$(CONFIG_PATA_CMD64X) += pata_cmd64x.o obj-$(CONFIG_PATA_CMD64X) += pata_cmd64x.o
obj-$(CONFIG_PATA_CS5520) += pata_cs5520.o obj-$(CONFIG_PATA_CS5520) += pata_cs5520.o
obj-$(CONFIG_PATA_CS5530) += pata_cs5530.o obj-$(CONFIG_PATA_CS5530) += pata_cs5530.o
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/msi.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
#include <linux/libata.h> #include <linux/libata.h>
......
This diff is collapsed.
...@@ -2071,6 +2071,20 @@ static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc) ...@@ -2071,6 +2071,20 @@ static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
!(qc->flags & ATA_QCFLAG_FAILED)) { !(qc->flags & ATA_QCFLAG_FAILED)) {
ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf); ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf);
qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15]; qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15];
/*
* For NCQ commands, we never get a D2H FIS, so reading the D2H Register
* FIS area of the Received FIS Structure (which contains a copy of the
* last D2H FIS received) will contain an outdated status code.
* For NCQ commands, we instead get a SDB FIS, so read the SDB FIS area
* instead. However, the SDB FIS does not contain the LBA, so we can't
* use the ata_tf_from_fis() helper.
*/
} else if (ata_is_ncq(qc->tf.protocol)) {
const u8 *fis = rx_fis + RX_FIS_SDB;
qc->result_tf.status = fis[2];
qc->result_tf.error = fis[3];
} else } else
ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf); ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf);
...@@ -2106,7 +2120,7 @@ void ahci_error_handler(struct ata_port *ap) ...@@ -2106,7 +2120,7 @@ void ahci_error_handler(struct ata_port *ap)
{ {
struct ahci_host_priv *hpriv = ap->host->private_data; struct ahci_host_priv *hpriv = ap->host->private_data;
if (!(ap->pflags & ATA_PFLAG_FROZEN)) { if (!ata_port_is_frozen(ap)) {
/* restart engine */ /* restart engine */
hpriv->stop_engine(ap); hpriv->stop_engine(ap);
hpriv->start_engine(ap); hpriv->start_engine(ap);
...@@ -2297,7 +2311,7 @@ static void ahci_pmp_attach(struct ata_port *ap) ...@@ -2297,7 +2311,7 @@ static void ahci_pmp_attach(struct ata_port *ap)
* Note that during initialization, the port is marked as * Note that during initialization, the port is marked as
* frozen since the irq handler is not yet registered. * frozen since the irq handler is not yet registered.
*/ */
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
} }
...@@ -2316,7 +2330,7 @@ static void ahci_pmp_detach(struct ata_port *ap) ...@@ -2316,7 +2330,7 @@ static void ahci_pmp_detach(struct ata_port *ap)
pp->intr_mask &= ~PORT_IRQ_BAD_PMP; pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
/* see comment above in ahci_pmp_attach() */ /* see comment above in ahci_pmp_attach() */
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
} }
......
...@@ -992,7 +992,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev) ...@@ -992,7 +992,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
acpi_err: acpi_err:
/* ignore evaluation failure if we can continue safely */ /* ignore evaluation failure if we can continue safely */
if (rc == -EINVAL && !nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) if (rc == -EINVAL && !nr_executed && !ata_port_is_frozen(ap))
return 0; return 0;
/* fail and let EH retry once more for unknown IO errors */ /* fail and let EH retry once more for unknown IO errors */
...@@ -1007,7 +1007,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev) ...@@ -1007,7 +1007,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
/* We can safely continue if no _GTF command has been executed /* We can safely continue if no _GTF command has been executed
* and port is not frozen. * and port is not frozen.
*/ */
if (!nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) if (!nr_executed && !ata_port_is_frozen(ap))
return 0; return 0;
return rc; return rc;
......
...@@ -1489,7 +1489,7 @@ static unsigned ata_exec_internal_sg(struct ata_device *dev, ...@@ -1489,7 +1489,7 @@ static unsigned ata_exec_internal_sg(struct ata_device *dev,
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
/* no internal command while frozen */ /* no internal command while frozen */
if (ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(ap)) {
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
return AC_ERR_SYSTEM; return AC_ERR_SYSTEM;
} }
...@@ -2000,7 +2000,8 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log, ...@@ -2000,7 +2000,8 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
if (err_mask) { if (err_mask) {
if (dma) { if (dma) {
dev->horkage |= ATA_HORKAGE_NO_DMA_LOG; dev->horkage |= ATA_HORKAGE_NO_DMA_LOG;
goto retry; if (!ata_port_is_frozen(dev->link->ap))
goto retry;
} }
ata_dev_err(dev, ata_dev_err(dev,
"Read log 0x%02x page 0x%02x failed, Emask 0x%x\n", "Read log 0x%02x page 0x%02x failed, Emask 0x%x\n",
...@@ -4721,7 +4722,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc) ...@@ -4721,7 +4722,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
return; return;
} }
WARN_ON_ONCE(ap->pflags & ATA_PFLAG_FROZEN); WARN_ON_ONCE(ata_port_is_frozen(ap));
/* read result TF if requested */ /* read result TF if requested */
if (qc->flags & ATA_QCFLAG_RESULT_TF) if (qc->flags & ATA_QCFLAG_RESULT_TF)
......
...@@ -1406,7 +1406,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc) ...@@ -1406,7 +1406,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc)
struct ata_taskfile tf; struct ata_taskfile tf;
unsigned int err_mask; unsigned int err_mask;
if (qc->ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(qc->ap)) {
ata_dev_warn(dev, "sense data available but port frozen\n"); ata_dev_warn(dev, "sense data available but port frozen\n");
return; return;
} }
...@@ -1428,8 +1428,10 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc) ...@@ -1428,8 +1428,10 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc)
err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
/* Ignore err_mask; ATA_ERR might be set */ /* Ignore err_mask; ATA_ERR might be set */
if (tf.status & ATA_SENSE) { if (tf.status & ATA_SENSE) {
ata_scsi_set_sense(dev, cmd, tf.lbah, tf.lbam, tf.lbal); if (ata_scsi_sense_is_valid(tf.lbah, tf.lbam, tf.lbal)) {
qc->flags |= ATA_QCFLAG_SENSE_VALID; ata_scsi_set_sense(dev, cmd, tf.lbah, tf.lbam, tf.lbal);
qc->flags |= ATA_QCFLAG_SENSE_VALID;
}
} else { } else {
ata_dev_warn(dev, "request sense failed stat %02x emask %x\n", ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
tf.status, err_mask); tf.status, err_mask);
...@@ -1574,11 +1576,17 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc) ...@@ -1574,11 +1576,17 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc)
} }
switch (qc->dev->class) { switch (qc->dev->class) {
case ATA_DEV_ATA:
case ATA_DEV_ZAC: case ATA_DEV_ZAC:
if (stat & ATA_SENSE) /*
* Fetch the sense data explicitly if:
* -It was a non-NCQ command that failed, or
* -It was a NCQ command that failed, but the sense data
* was not included in the NCQ command error log
* (i.e. NCQ autosense is not supported by the device).
*/
if (!(qc->flags & ATA_QCFLAG_SENSE_VALID) && (stat & ATA_SENSE))
ata_eh_request_sense(qc); ata_eh_request_sense(qc);
fallthrough;
case ATA_DEV_ATA:
if (err & ATA_ICRC) if (err & ATA_ICRC)
qc->err_mask |= AC_ERR_ATA_BUS; qc->err_mask |= AC_ERR_ATA_BUS;
if (err & (ATA_UNC | ATA_AMNF)) if (err & (ATA_UNC | ATA_AMNF))
...@@ -1588,7 +1596,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc) ...@@ -1588,7 +1596,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc)
break; break;
case ATA_DEV_ATAPI: case ATA_DEV_ATAPI:
if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { if (!ata_port_is_frozen(qc->ap)) {
tmp = atapi_eh_request_sense(qc->dev, tmp = atapi_eh_request_sense(qc->dev,
qc->scsicmd->sense_buffer, qc->scsicmd->sense_buffer,
qc->result_tf.error >> 4); qc->result_tf.error >> 4);
...@@ -1947,6 +1955,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) ...@@ -1947,6 +1955,7 @@ static void ata_eh_link_autopsy(struct ata_link *link)
ata_qc_for_each_raw(ap, qc, tag) { ata_qc_for_each_raw(ap, qc, tag) {
if (!(qc->flags & ATA_QCFLAG_FAILED) || if (!(qc->flags & ATA_QCFLAG_FAILED) ||
qc->flags & ATA_QCFLAG_RETRY ||
ata_dev_phys_link(qc->dev) != link) ata_dev_phys_link(qc->dev) != link)
continue; continue;
...@@ -1995,7 +2004,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) ...@@ -1995,7 +2004,7 @@ static void ata_eh_link_autopsy(struct ata_link *link)
ehc->i.flags |= ATA_EHI_QUIET; ehc->i.flags |= ATA_EHI_QUIET;
/* enforce default EH actions */ /* enforce default EH actions */
if (ap->pflags & ATA_PFLAG_FROZEN || if (ata_port_is_frozen(ap) ||
all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT))
ehc->i.action |= ATA_EH_RESET; ehc->i.action |= ATA_EH_RESET;
else if (((eflags & ATA_EFLAG_IS_IO) && all_err_mask) || else if (((eflags & ATA_EFLAG_IS_IO) && all_err_mask) ||
...@@ -2238,7 +2247,7 @@ static void ata_eh_link_report(struct ata_link *link) ...@@ -2238,7 +2247,7 @@ static void ata_eh_link_report(struct ata_link *link)
return; return;
frozen = ""; frozen = "";
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
frozen = " frozen"; frozen = " frozen";
if (ap->eh_tries < ATA_EH_MAX_TRIES) if (ap->eh_tries < ATA_EH_MAX_TRIES)
...@@ -2559,8 +2568,7 @@ int ata_eh_reset(struct ata_link *link, int classify, ...@@ -2559,8 +2568,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
if (reset && !(ehc->i.action & ATA_EH_RESET)) { if (reset && !(ehc->i.action & ATA_EH_RESET)) {
ata_for_each_dev(dev, link, ALL) ata_for_each_dev(dev, link, ALL)
classes[dev->devno] = ATA_DEV_NONE; classes[dev->devno] = ATA_DEV_NONE;
if ((ap->pflags & ATA_PFLAG_FROZEN) && if (ata_port_is_frozen(ap) && ata_is_host_link(link))
ata_is_host_link(link))
ata_eh_thaw_port(ap); ata_eh_thaw_port(ap);
rc = 0; rc = 0;
goto out; goto out;
...@@ -2718,7 +2726,7 @@ int ata_eh_reset(struct ata_link *link, int classify, ...@@ -2718,7 +2726,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
ap->pflags &= ~ATA_PFLAG_EH_PENDING; ap->pflags &= ~ATA_PFLAG_EH_PENDING;
spin_unlock_irqrestore(link->ap->lock, flags); spin_unlock_irqrestore(link->ap->lock, flags);
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
ata_eh_thaw_port(ap); ata_eh_thaw_port(ap);
/* /*
...@@ -3225,7 +3233,7 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev) ...@@ -3225,7 +3233,7 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
if (err_mask & AC_ERR_DEV) { if (err_mask & AC_ERR_DEV) {
qc->err_mask |= AC_ERR_DEV; qc->err_mask |= AC_ERR_DEV;
qc->result_tf = tf; qc->result_tf = tf;
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
rc = 0; rc = 0;
} }
} }
...@@ -3402,7 +3410,7 @@ static int ata_eh_skip_recovery(struct ata_link *link) ...@@ -3402,7 +3410,7 @@ static int ata_eh_skip_recovery(struct ata_link *link)
return 1; return 1;
/* thaw frozen port and recover failed devices */ /* thaw frozen port and recover failed devices */
if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link))
return 0; return 0;
/* reset at least once if reset is requested */ /* reset at least once if reset is requested */
...@@ -3757,7 +3765,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -3757,7 +3765,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
if (dev) if (dev)
ata_eh_handle_dev_fail(dev, rc); ata_eh_handle_dev_fail(dev, rc);
if (ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(ap)) {
/* PMP reset requires working host port. /* PMP reset requires working host port.
* Can't retry if it's frozen. * Can't retry if it's frozen.
*/ */
...@@ -3931,7 +3939,7 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) ...@@ -3931,7 +3939,7 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
ap->pflags &= ~ATA_PFLAG_PM_PENDING; ap->pflags &= ~ATA_PFLAG_PM_PENDING;
if (rc == 0) if (rc == 0)
ap->pflags |= ATA_PFLAG_SUSPENDED; ap->pflags |= ATA_PFLAG_SUSPENDED;
else if (ap->pflags & ATA_PFLAG_FROZEN) else if (ata_port_is_frozen(ap))
ata_port_schedule_eh(ap); ata_port_schedule_eh(ap);
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
......
...@@ -1392,7 +1392,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev, ...@@ -1392,7 +1392,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
tf->hob_lbah = buf[10]; tf->hob_lbah = buf[10];
tf->nsect = buf[12]; tf->nsect = buf[12];
tf->hob_nsect = buf[13]; tf->hob_nsect = buf[13];
if (dev->class == ATA_DEV_ZAC && ata_id_has_ncq_autosense(dev->id)) if (ata_id_has_ncq_autosense(dev->id) && (tf->status & ATA_SENSE))
tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16]; tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16];
return 0; return 0;
...@@ -1420,7 +1420,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) ...@@ -1420,7 +1420,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
int tag, rc; int tag, rc;
/* if frozen, we can't do much */ /* if frozen, we can't do much */
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
return; return;
/* is it NCQ device error? */ /* is it NCQ device error? */
...@@ -1456,17 +1456,51 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) ...@@ -1456,17 +1456,51 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
memcpy(&qc->result_tf, &tf, sizeof(tf)); memcpy(&qc->result_tf, &tf, sizeof(tf));
qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48; qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
if (dev->class == ATA_DEV_ZAC &&
((qc->result_tf.status & ATA_SENSE) || qc->result_tf.auxiliary)) { /*
* If the device supports NCQ autosense, ata_eh_read_log_10h() will have
* stored the sense data in qc->result_tf.auxiliary.
*/
if (qc->result_tf.auxiliary) {
char sense_key, asc, ascq; char sense_key, asc, ascq;
sense_key = (qc->result_tf.auxiliary >> 16) & 0xff; sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
asc = (qc->result_tf.auxiliary >> 8) & 0xff; asc = (qc->result_tf.auxiliary >> 8) & 0xff;
ascq = qc->result_tf.auxiliary & 0xff; ascq = qc->result_tf.auxiliary & 0xff;
ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc, ascq); if (ata_scsi_sense_is_valid(sense_key, asc, ascq)) {
ata_scsi_set_sense_information(dev, qc->scsicmd, ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc,
&qc->result_tf); ascq);
qc->flags |= ATA_QCFLAG_SENSE_VALID; ata_scsi_set_sense_information(dev, qc->scsicmd,
&qc->result_tf);
qc->flags |= ATA_QCFLAG_SENSE_VALID;
}
}
ata_qc_for_each_raw(ap, qc, tag) {
if (!(qc->flags & ATA_QCFLAG_FAILED) ||
ata_dev_phys_link(qc->dev) != link)
continue;
/* Skip the single QC which caused the NCQ error. */
if (qc->err_mask)
continue;
/*
* For SATA, the STATUS and ERROR fields are shared for all NCQ
* commands that were completed with the same SDB FIS.
* Therefore, we have to clear the ATA_ERR bit for all QCs
* except the one that caused the NCQ error.
*/
qc->result_tf.status &= ~ATA_ERR;
qc->result_tf.error = 0;
/*
* If we get a NCQ error, that means that a single command was
* aborted. All other failed commands for our link should be
* retried and has no business of going though further scrutiny
* by ata_eh_link_autopsy().
*/
qc->flags |= ATA_QCFLAG_RETRY;
} }
ehc->i.err_mask &= ~AC_ERR_DEV; ehc->i.err_mask &= ~AC_ERR_DEV;
......
...@@ -188,6 +188,22 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR, ...@@ -188,6 +188,22 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR,
ata_scsi_park_show, ata_scsi_park_store); ata_scsi_park_show, ata_scsi_park_store);
EXPORT_SYMBOL_GPL(dev_attr_unload_heads); EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
bool ata_scsi_sense_is_valid(u8 sk, u8 asc, u8 ascq)
{
/*
* If sk == NO_SENSE, and asc + ascq == NO ADDITIONAL SENSE INFORMATION,
* then there is no sense data to add.
*/
if (sk == 0 && asc == 0 && ascq == 0)
return false;
/* If sk > COMPLETED, sense data is bogus. */
if (sk > COMPLETED)
return false;
return true;
}
void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd,
u8 sk, u8 asc, u8 ascq) u8 sk, u8 asc, u8 ascq)
{ {
...@@ -642,7 +658,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, ...@@ -642,7 +658,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
int tag; int tag;
if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) if (unlikely(ata_port_is_frozen(ap)))
goto fail; goto fail;
if (ap->flags & ATA_FLAG_SAS_HOST) { if (ap->flags & ATA_FLAG_SAS_HOST) {
......
...@@ -184,62 +184,6 @@ void ata_sff_dma_pause(struct ata_port *ap) ...@@ -184,62 +184,6 @@ void ata_sff_dma_pause(struct ata_port *ap)
} }
EXPORT_SYMBOL_GPL(ata_sff_dma_pause); EXPORT_SYMBOL_GPL(ata_sff_dma_pause);
/**
* ata_sff_busy_sleep - sleep until BSY clears, or timeout
* @ap: port containing status register to be polled
* @tmout_pat: impatience timeout in msecs
* @tmout: overall timeout in msecs
*
* Sleep until ATA Status register bit BSY clears,
* or a timeout occurs.
*
* LOCKING:
* Kernel thread context (may sleep).
*
* RETURNS:
* 0 on success, -errno otherwise.
*/
int ata_sff_busy_sleep(struct ata_port *ap,
unsigned long tmout_pat, unsigned long tmout)
{
unsigned long timer_start, timeout;
u8 status;
status = ata_sff_busy_wait(ap, ATA_BUSY, 300);
timer_start = jiffies;
timeout = ata_deadline(timer_start, tmout_pat);
while (status != 0xff && (status & ATA_BUSY) &&
time_before(jiffies, timeout)) {
ata_msleep(ap, 50);
status = ata_sff_busy_wait(ap, ATA_BUSY, 3);
}
if (status != 0xff && (status & ATA_BUSY))
ata_port_warn(ap,
"port is slow to respond, please be patient (Status 0x%x)\n",
status);
timeout = ata_deadline(timer_start, tmout);
while (status != 0xff && (status & ATA_BUSY) &&
time_before(jiffies, timeout)) {
ata_msleep(ap, 50);
status = ap->ops->sff_check_status(ap);
}
if (status == 0xff)
return -ENODEV;
if (status & ATA_BUSY) {
ata_port_err(ap,
"port failed to respond (%lu secs, Status 0x%x)\n",
DIV_ROUND_UP(tmout, 1000), status);
return -EBUSY;
}
return 0;
}
EXPORT_SYMBOL_GPL(ata_sff_busy_sleep);
static int ata_sff_check_ready(struct ata_link *link) static int ata_sff_check_ready(struct ata_link *link)
{ {
u8 status = link->ap->ops->sff_check_status(link->ap); u8 status = link->ap->ops->sff_check_status(link->ap);
......
...@@ -114,6 +114,7 @@ extern int ata_scsi_add_hosts(struct ata_host *host, ...@@ -114,6 +114,7 @@ extern int ata_scsi_add_hosts(struct ata_host *host,
struct scsi_host_template *sht); struct scsi_host_template *sht);
extern void ata_scsi_scan_host(struct ata_port *ap, int sync); extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
extern int ata_scsi_offline_dev(struct ata_device *dev); extern int ata_scsi_offline_dev(struct ata_device *dev);
extern bool ata_scsi_sense_is_valid(u8 sk, u8 asc, u8 ascq);
extern void ata_scsi_set_sense(struct ata_device *dev, extern void ata_scsi_set_sense(struct ata_device *dev,
struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq); struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
extern void ata_scsi_set_sense_information(struct ata_device *dev, extern void ata_scsi_set_sense_information(struct ata_device *dev,
......
This diff is collapsed.
...@@ -931,8 +931,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev) ...@@ -931,8 +931,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
goto err_rel_gpio; goto err_rel_gpio;
} }
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ide_base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem_res);
ide_base = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(ide_base)) { if (IS_ERR(ide_base)) {
err = PTR_ERR(ide_base); err = PTR_ERR(ide_base);
goto err_rel_gpio; goto err_rel_gpio;
......
...@@ -560,7 +560,7 @@ static const struct of_device_id pata_ftide010_of_match[] = { ...@@ -560,7 +560,7 @@ static const struct of_device_id pata_ftide010_of_match[] = {
static struct platform_driver pata_ftide010_driver = { static struct platform_driver pata_ftide010_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = of_match_ptr(pata_ftide010_of_match), .of_match_table = pata_ftide010_of_match,
}, },
.probe = pata_ftide010_probe, .probe = pata_ftide010_probe,
.remove = pata_ftide010_remove, .remove = pata_ftide010_remove,
......
...@@ -731,7 +731,7 @@ static int mpc52xx_ata_probe(struct platform_device *op) ...@@ -731,7 +731,7 @@ static int mpc52xx_ata_probe(struct platform_device *op)
udma_mask = ATA_UDMA2 & ((1 << (*prop + 1)) - 1); udma_mask = ATA_UDMA2 & ((1 << (*prop + 1)) - 1);
ata_irq = irq_of_parse_and_map(op->dev.of_node, 0); ata_irq = irq_of_parse_and_map(op->dev.of_node, 0);
if (ata_irq == NO_IRQ) { if (!ata_irq) {
dev_err(&op->dev, "error mapping irq\n"); dev_err(&op->dev, "error mapping irq\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -42,10 +42,6 @@ ...@@ -42,10 +42,6 @@
#define sata_dwc_writel(a, v) writel_relaxed(v, a) #define sata_dwc_writel(a, v) writel_relaxed(v, a)
#define sata_dwc_readl(a) readl_relaxed(a) #define sata_dwc_readl(a) readl_relaxed(a)
#ifndef NO_IRQ
#define NO_IRQ 0
#endif
#define AHB_DMA_BRST_DFLT 64 /* 16 data items burst length */ #define AHB_DMA_BRST_DFLT 64 /* 16 data items burst length */
enum { enum {
...@@ -242,7 +238,7 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev, ...@@ -242,7 +238,7 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
/* Get SATA DMA interrupt number */ /* Get SATA DMA interrupt number */
hsdev->dma->irq = irq_of_parse_and_map(np, 1); hsdev->dma->irq = irq_of_parse_and_map(np, 1);
if (hsdev->dma->irq == NO_IRQ) { if (!hsdev->dma->irq) {
dev_err(dev, "no SATA DMA irq\n"); dev_err(dev, "no SATA DMA irq\n");
return -ENODEV; return -ENODEV;
} }
...@@ -472,7 +468,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) ...@@ -472,7 +468,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
unsigned long flags; unsigned long flags;
u8 status, tag; u8 status, tag;
int handled, num_processed, port = 0; int handled, port = 0;
uint intpr, sactive, sactive2, tag_mask; uint intpr, sactive, sactive2, tag_mask;
struct sata_dwc_device_port *hsdevp; struct sata_dwc_device_port *hsdevp;
hsdev->sactive_issued = 0; hsdev->sactive_issued = 0;
...@@ -618,9 +614,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) ...@@ -618,9 +614,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
dev_dbg(ap->dev, "%s ATA status register=0x%x\n", __func__, status); dev_dbg(ap->dev, "%s ATA status register=0x%x\n", __func__, status);
tag = 0; tag = 0;
num_processed = 0;
while (tag_mask) { while (tag_mask) {
num_processed++;
while (!(tag_mask & 0x00000001)) { while (!(tag_mask & 0x00000001)) {
tag++; tag++;
tag_mask <<= 1; tag_mask <<= 1;
...@@ -1180,7 +1174,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1180,7 +1174,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Get SATA interrupt number */ /* Get SATA interrupt number */
irq = irq_of_parse_and_map(np, 0); irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) { if (!irq) {
dev_err(dev, "no SATA DMA irq\n"); dev_err(dev, "no SATA DMA irq\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -421,7 +421,7 @@ static const struct of_device_id gemini_sata_of_match[] = { ...@@ -421,7 +421,7 @@ static const struct of_device_id gemini_sata_of_match[] = {
static struct platform_driver gemini_sata_driver = { static struct platform_driver gemini_sata_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = of_match_ptr(gemini_sata_of_match), .of_match_table = gemini_sata_of_match,
}, },
.probe = gemini_sata_probe, .probe = gemini_sata_probe,
.remove = gemini_sata_remove, .remove = gemini_sata_remove,
......
...@@ -2185,7 +2185,7 @@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis) ...@@ -2185,7 +2185,7 @@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)
if (!fis) if (!fis)
return; return;
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
return; return;
if (fis & NV_SWNCQ_IRQ_HOTPLUG) { if (fis & NV_SWNCQ_IRQ_HOTPLUG) {
......
...@@ -817,7 +817,7 @@ static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class, ...@@ -817,7 +817,7 @@ static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class,
static void pdc_error_handler(struct ata_port *ap) static void pdc_error_handler(struct ata_port *ap)
{ {
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
pdc_reset_port(ap); pdc_reset_port(ap);
ata_sff_error_handler(ap); ata_sff_error_handler(ap);
......
...@@ -855,7 +855,7 @@ static int pdc_softreset(struct ata_link *link, unsigned int *class, ...@@ -855,7 +855,7 @@ static int pdc_softreset(struct ata_link *link, unsigned int *class,
static void pdc_error_handler(struct ata_port *ap) static void pdc_error_handler(struct ata_port *ap)
{ {
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
pdc_reset_port(ap); pdc_reset_port(ap);
ata_sff_error_handler(ap); ata_sff_error_handler(ap);
......
...@@ -101,7 +101,7 @@ static void sas_ata_task_done(struct sas_task *task) ...@@ -101,7 +101,7 @@ static void sas_ata_task_done(struct sas_task *task)
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
/* check if we lost the race with libata/sas_ata_post_internal() */ /* check if we lost the race with libata/sas_ata_post_internal() */
if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) { if (unlikely(ata_port_is_frozen(ap))) {
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
if (qc->scsicmd) if (qc->scsicmd)
goto qc_already_gone; goto qc_already_gone;
......
...@@ -615,15 +615,6 @@ static inline bool ata_id_has_flush(const u16 *id) ...@@ -615,15 +615,6 @@ static inline bool ata_id_has_flush(const u16 *id)
return id[ATA_ID_COMMAND_SET_2] & (1 << 12); return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
} }
static inline bool ata_id_flush_enabled(const u16 *id)
{
if (ata_id_has_flush(id) == 0)
return false;
if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
return false;
return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
}
static inline bool ata_id_has_flush_ext(const u16 *id) static inline bool ata_id_has_flush_ext(const u16 *id)
{ {
if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
...@@ -631,19 +622,6 @@ static inline bool ata_id_has_flush_ext(const u16 *id) ...@@ -631,19 +622,6 @@ static inline bool ata_id_has_flush_ext(const u16 *id)
return id[ATA_ID_COMMAND_SET_2] & (1 << 13); return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
} }
static inline bool ata_id_flush_ext_enabled(const u16 *id)
{
if (ata_id_has_flush_ext(id) == 0)
return false;
if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
return false;
/*
* some Maxtor disks have bit 13 defined incorrectly
* so check bit 10 too
*/
return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400;
}
static inline u32 ata_id_logical_sector_size(const u16 *id) static inline u32 ata_id_logical_sector_size(const u16 *id)
{ {
/* T13/1699-D Revision 6a, Sep 6, 2008. Page 128. /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
...@@ -698,15 +676,6 @@ static inline bool ata_id_has_lba48(const u16 *id) ...@@ -698,15 +676,6 @@ static inline bool ata_id_has_lba48(const u16 *id)
return id[ATA_ID_COMMAND_SET_2] & (1 << 10); return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
} }
static inline bool ata_id_lba48_enabled(const u16 *id)
{
if (ata_id_has_lba48(id) == 0)
return false;
if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
return false;
return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
}
static inline bool ata_id_hpa_enabled(const u16 *id) static inline bool ata_id_hpa_enabled(const u16 *id)
{ {
/* Yes children, word 83 valid bits cover word 82 data */ /* Yes children, word 83 valid bits cover word 82 data */
......
...@@ -1043,6 +1043,11 @@ static inline int ata_port_is_dummy(struct ata_port *ap) ...@@ -1043,6 +1043,11 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
return ap->ops == &ata_dummy_port_ops; return ap->ops == &ata_dummy_port_ops;
} }
static inline bool ata_port_is_frozen(const struct ata_port *ap)
{
return ap->pflags & ATA_PFLAG_FROZEN;
}
extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
int (*check_ready)(struct ata_link *link)); int (*check_ready)(struct ata_link *link));
...@@ -1913,8 +1918,6 @@ extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device); ...@@ -1913,8 +1918,6 @@ extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
extern u8 ata_sff_check_status(struct ata_port *ap); extern u8 ata_sff_check_status(struct ata_port *ap);
extern void ata_sff_pause(struct ata_port *ap); extern void ata_sff_pause(struct ata_port *ap);
extern void ata_sff_dma_pause(struct ata_port *ap); extern void ata_sff_dma_pause(struct ata_port *ap);
extern int ata_sff_busy_sleep(struct ata_port *ap,
unsigned long timeout_pat, unsigned long timeout);
extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline); extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
......
...@@ -205,10 +205,10 @@ enum sam_status { ...@@ -205,10 +205,10 @@ enum sam_status {
}; };
#define STATUS_MASK 0xfe #define STATUS_MASK 0xfe
/* /*
* SENSE KEYS * SENSE KEYS
*/ */
#define NO_SENSE 0x00 #define NO_SENSE 0x00
#define RECOVERED_ERROR 0x01 #define RECOVERED_ERROR 0x01
#define NOT_READY 0x02 #define NOT_READY 0x02
...@@ -223,7 +223,7 @@ enum sam_status { ...@@ -223,7 +223,7 @@ enum sam_status {
#define ABORTED_COMMAND 0x0b #define ABORTED_COMMAND 0x0b
#define VOLUME_OVERFLOW 0x0d #define VOLUME_OVERFLOW 0x0d
#define MISCOMPARE 0x0e #define MISCOMPARE 0x0e
#define COMPLETED 0x0f
/* /*
* DEVICE TYPES * DEVICE TYPES
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment