diff options
author | Hannes Reinecke <hare@suse.de> | 2015-03-27 11:46:36 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-03-27 11:59:22 -0400 |
commit | fe7173c206de63fc28475ee6ae42ff95c05692de (patch) | |
tree | db025adb8d7ee04592640035537add3f7c8dbe4d /drivers | |
parent | 42b966fbf35da9c87f08d98f9b8978edf9e717cf (diff) |
libata: Implement support for sense data reporting
ACS-4 defines a sense data reporting feature set.
This patch implements support for it.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/libata-core.c | 20 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 86 |
2 files changed, 102 insertions, 4 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4c35f0822d06..aebb7e305874 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2144,6 +2144,24 @@ static int ata_dev_config_ncq(struct ata_device *dev, | |||
2144 | return 0; | 2144 | return 0; |
2145 | } | 2145 | } |
2146 | 2146 | ||
2147 | static void ata_dev_config_sense_reporting(struct ata_device *dev) | ||
2148 | { | ||
2149 | unsigned int err_mask; | ||
2150 | |||
2151 | if (!ata_id_has_sense_reporting(dev->id)) | ||
2152 | return; | ||
2153 | |||
2154 | if (ata_id_sense_reporting_enabled(dev->id)) | ||
2155 | return; | ||
2156 | |||
2157 | err_mask = ata_dev_set_feature(dev, SETFEATURE_SENSE_DATA, 0x1); | ||
2158 | if (err_mask) { | ||
2159 | ata_dev_dbg(dev, | ||
2160 | "failed to enable Sense Data Reporting, Emask 0x%x\n", | ||
2161 | err_mask); | ||
2162 | } | ||
2163 | } | ||
2164 | |||
2147 | /** | 2165 | /** |
2148 | * ata_dev_configure - Configure the specified ATA/ATAPI device | 2166 | * ata_dev_configure - Configure the specified ATA/ATAPI device |
2149 | * @dev: Target device to configure | 2167 | * @dev: Target device to configure |
@@ -2366,7 +2384,7 @@ int ata_dev_configure(struct ata_device *dev) | |||
2366 | dev->devslp_timing[i] = sata_setting[j]; | 2384 | dev->devslp_timing[i] = sata_setting[j]; |
2367 | } | 2385 | } |
2368 | } | 2386 | } |
2369 | 2387 | ata_dev_config_sense_reporting(dev); | |
2370 | dev->cdb_len = 16; | 2388 | dev->cdb_len = 16; |
2371 | } | 2389 | } |
2372 | 2390 | ||
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index c9b19949708c..9fa81d91f6ad 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1618,6 +1618,70 @@ unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key) | |||
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | /** | 1620 | /** |
1621 | * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT | ||
1622 | * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to | ||
1623 | * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) | ||
1624 | * @dfl_sense_key: default sense key to use | ||
1625 | * | ||
1626 | * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK | ||
1627 | * SENSE. This function is EH helper. | ||
1628 | * | ||
1629 | * LOCKING: | ||
1630 | * Kernel thread context (may sleep). | ||
1631 | * | ||
1632 | * RETURNS: | ||
1633 | * encoded sense data on success, 0 on failure or if sense data | ||
1634 | * is not available. | ||
1635 | */ | ||
1636 | static u32 ata_eh_request_sense(struct ata_queued_cmd *qc, | ||
1637 | struct scsi_cmnd *cmd) | ||
1638 | { | ||
1639 | struct ata_device *dev = qc->dev; | ||
1640 | struct ata_taskfile tf; | ||
1641 | unsigned int err_mask; | ||
1642 | |||
1643 | if (!cmd) | ||
1644 | return 0; | ||
1645 | |||
1646 | DPRINTK("ATA request sense\n"); | ||
1647 | ata_dev_warn(dev, "request sense\n"); | ||
1648 | if (!ata_id_sense_reporting_enabled(dev->id)) { | ||
1649 | ata_dev_warn(qc->dev, "sense data reporting disabled\n"); | ||
1650 | return 0; | ||
1651 | } | ||
1652 | ata_tf_init(dev, &tf); | ||
1653 | |||
1654 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1655 | tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; | ||
1656 | tf.command = ATA_CMD_REQ_SENSE_DATA; | ||
1657 | tf.protocol = ATA_PROT_NODATA; | ||
1658 | |||
1659 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); | ||
1660 | /* | ||
1661 | * ACS-4 states: | ||
1662 | * The device may set the SENSE DATA AVAILABLE bit to one in the | ||
1663 | * STATUS field and clear the ERROR bit to zero in the STATUS field | ||
1664 | * to indicate that the command returned completion without an error | ||
1665 | * and the sense data described in table 306 is available. | ||
1666 | * | ||
1667 | * IOW the 'ATA_SENSE' bit might not be set even though valid | ||
1668 | * sense data is available. | ||
1669 | * So check for both. | ||
1670 | */ | ||
1671 | if ((tf.command & ATA_SENSE) || | ||
1672 | tf.lbah != 0 || tf.lbam != 0 || tf.lbal != 0) { | ||
1673 | ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal); | ||
1674 | qc->flags |= ATA_QCFLAG_SENSE_VALID; | ||
1675 | ata_dev_warn(dev, "sense data %02x/%02x/%02x\n", | ||
1676 | tf.lbah, tf.lbam, tf.lbal); | ||
1677 | } else { | ||
1678 | ata_dev_warn(dev, "request sense failed stat %02x emask %x\n", | ||
1679 | tf.command, err_mask); | ||
1680 | } | ||
1681 | return err_mask; | ||
1682 | } | ||
1683 | |||
1684 | /** | ||
1621 | * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE | 1685 | * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE |
1622 | * @dev: device to perform REQUEST_SENSE to | 1686 | * @dev: device to perform REQUEST_SENSE to |
1623 | * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) | 1687 | * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) |
@@ -1820,7 +1884,22 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, | |||
1820 | return ATA_EH_RESET; | 1884 | return ATA_EH_RESET; |
1821 | } | 1885 | } |
1822 | 1886 | ||
1823 | /* Set by NCQ autosense */ | 1887 | /* |
1888 | * Sense data reporting does not work if the | ||
1889 | * device fault bit is set. | ||
1890 | */ | ||
1891 | if ((stat & ATA_SENSE) && !(stat & ATA_DF) && | ||
1892 | !(qc->flags & ATA_QCFLAG_SENSE_VALID)) { | ||
1893 | if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { | ||
1894 | tmp = ata_eh_request_sense(qc, qc->scsicmd); | ||
1895 | if (tmp) | ||
1896 | qc->err_mask |= tmp; | ||
1897 | } else { | ||
1898 | ata_dev_warn(qc->dev, "sense data available but port frozen\n"); | ||
1899 | } | ||
1900 | } | ||
1901 | |||
1902 | /* Set by NCQ autosense or request sense above */ | ||
1824 | if (qc->flags & ATA_QCFLAG_SENSE_VALID) | 1903 | if (qc->flags & ATA_QCFLAG_SENSE_VALID) |
1825 | return 0; | 1904 | return 0; |
1826 | 1905 | ||
@@ -2566,14 +2645,15 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2566 | 2645 | ||
2567 | #ifdef CONFIG_ATA_VERBOSE_ERROR | 2646 | #ifdef CONFIG_ATA_VERBOSE_ERROR |
2568 | if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | | 2647 | if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | |
2569 | ATA_ERR)) { | 2648 | ATA_SENSE | ATA_ERR)) { |
2570 | if (res->command & ATA_BUSY) | 2649 | if (res->command & ATA_BUSY) |
2571 | ata_dev_err(qc->dev, "status: { Busy }\n"); | 2650 | ata_dev_err(qc->dev, "status: { Busy }\n"); |
2572 | else | 2651 | else |
2573 | ata_dev_err(qc->dev, "status: { %s%s%s%s}\n", | 2652 | ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", |
2574 | res->command & ATA_DRDY ? "DRDY " : "", | 2653 | res->command & ATA_DRDY ? "DRDY " : "", |
2575 | res->command & ATA_DF ? "DF " : "", | 2654 | res->command & ATA_DF ? "DF " : "", |
2576 | res->command & ATA_DRQ ? "DRQ " : "", | 2655 | res->command & ATA_DRQ ? "DRQ " : "", |
2656 | res->command & ATA_SENSE ? "SENSE " : "", | ||
2577 | res->command & ATA_ERR ? "ERR " : ""); | 2657 | res->command & ATA_ERR ? "ERR " : ""); |
2578 | } | 2658 | } |
2579 | 2659 | ||