aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2016-04-04 05:43:55 -0400
committerTejun Heo <tj@kernel.org>2016-04-04 12:07:40 -0400
commite87fd28cf9a2d9018ac4b6dd92f0b417714bc18d (patch)
tree768ef4257ff8ae50cdb54e63a05919c14bf29e1c /drivers/ata
parent5b01e4b9efa0b78672cbbea830c9fbcc7f239e29 (diff)
libata: Implement support for sense data reporting
ACS-4 defines a sense data reporting feature set. This patch implements support for it. tj: Cosmetic formatting updates. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c20
-rw-r--r--drivers/ata/libata-eh.c68
2 files changed, 83 insertions, 5 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 55e257c268dd..f991f786227e 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2148,6 +2148,24 @@ static int ata_dev_config_ncq(struct ata_device *dev,
2148 return 0; 2148 return 0;
2149} 2149}
2150 2150
2151static void ata_dev_config_sense_reporting(struct ata_device *dev)
2152{
2153 unsigned int err_mask;
2154
2155 if (!ata_id_has_sense_reporting(dev->id))
2156 return;
2157
2158 if (ata_id_sense_reporting_enabled(dev->id))
2159 return;
2160
2161 err_mask = ata_dev_set_feature(dev, SETFEATURE_SENSE_DATA, 0x1);
2162 if (err_mask) {
2163 ata_dev_dbg(dev,
2164 "failed to enable Sense Data Reporting, Emask 0x%x\n",
2165 err_mask);
2166 }
2167}
2168
2151/** 2169/**
2152 * ata_dev_configure - Configure the specified ATA/ATAPI device 2170 * ata_dev_configure - Configure the specified ATA/ATAPI device
2153 * @dev: Target device to configure 2171 * @dev: Target device to configure
@@ -2370,7 +2388,7 @@ int ata_dev_configure(struct ata_device *dev)
2370 dev->devslp_timing[i] = sata_setting[j]; 2388 dev->devslp_timing[i] = sata_setting[j];
2371 } 2389 }
2372 } 2390 }
2373 2391 ata_dev_config_sense_reporting(dev);
2374 dev->cdb_len = 16; 2392 dev->cdb_len = 16;
2375 } 2393 }
2376 2394
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8c8355f0792e..170e891e79af 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1638,6 +1638,56 @@ unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key)
1638} 1638}
1639 1639
1640/** 1640/**
1641 * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT
1642 * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to
1643 * @cmd: scsi command for which the sense code should be set
1644 *
1645 * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK
1646 * SENSE. This function is an EH helper.
1647 *
1648 * LOCKING:
1649 * Kernel thread context (may sleep).
1650 */
1651static void ata_eh_request_sense(struct ata_queued_cmd *qc,
1652 struct scsi_cmnd *cmd)
1653{
1654 struct ata_device *dev = qc->dev;
1655 struct ata_taskfile tf;
1656 unsigned int err_mask;
1657
1658 if (qc->ap->pflags & ATA_PFLAG_FROZEN) {
1659 ata_dev_warn(dev, "sense data available but port frozen\n");
1660 return;
1661 }
1662
1663 if (!cmd)
1664 return;
1665
1666 if (!ata_id_sense_reporting_enabled(dev->id)) {
1667 ata_dev_warn(qc->dev, "sense data reporting disabled\n");
1668 return;
1669 }
1670
1671 DPRINTK("ATA request sense\n");
1672
1673 ata_tf_init(dev, &tf);
1674 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1675 tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1676 tf.command = ATA_CMD_REQ_SENSE_DATA;
1677 tf.protocol = ATA_PROT_NODATA;
1678
1679 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1680 /* Ignore err_mask; ATA_ERR might be set */
1681 if (tf.command & ATA_SENSE) {
1682 ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal);
1683 qc->flags |= ATA_QCFLAG_SENSE_VALID;
1684 } else {
1685 ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
1686 tf.command, err_mask);
1687 }
1688}
1689
1690/**
1641 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE 1691 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1642 * @dev: device to perform REQUEST_SENSE to 1692 * @dev: device to perform REQUEST_SENSE to
1643 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1693 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
@@ -1838,14 +1888,23 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1838 return ATA_EH_RESET; 1888 return ATA_EH_RESET;
1839 } 1889 }
1840 1890
1841 if (stat & (ATA_ERR | ATA_DF)) 1891 if (stat & (ATA_ERR | ATA_DF)) {
1842 qc->err_mask |= AC_ERR_DEV; 1892 qc->err_mask |= AC_ERR_DEV;
1843 else 1893 /*
1894 * Sense data reporting does not work if the
1895 * device fault bit is set.
1896 */
1897 if (stat & ATA_DF)
1898 stat &= ~ATA_SENSE;
1899 } else {
1844 return 0; 1900 return 0;
1901 }
1845 1902
1846 switch (qc->dev->class) { 1903 switch (qc->dev->class) {
1847 case ATA_DEV_ATA: 1904 case ATA_DEV_ATA:
1848 case ATA_DEV_ZAC: 1905 case ATA_DEV_ZAC:
1906 if (stat & ATA_SENSE)
1907 ata_eh_request_sense(qc, qc->scsicmd);
1849 if (err & ATA_ICRC) 1908 if (err & ATA_ICRC)
1850 qc->err_mask |= AC_ERR_ATA_BUS; 1909 qc->err_mask |= AC_ERR_ATA_BUS;
1851 if (err & (ATA_UNC | ATA_AMNF)) 1910 if (err & (ATA_UNC | ATA_AMNF))
@@ -2581,14 +2640,15 @@ static void ata_eh_link_report(struct ata_link *link)
2581 2640
2582#ifdef CONFIG_ATA_VERBOSE_ERROR 2641#ifdef CONFIG_ATA_VERBOSE_ERROR
2583 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2642 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2584 ATA_ERR)) { 2643 ATA_SENSE | ATA_ERR)) {
2585 if (res->command & ATA_BUSY) 2644 if (res->command & ATA_BUSY)
2586 ata_dev_err(qc->dev, "status: { Busy }\n"); 2645 ata_dev_err(qc->dev, "status: { Busy }\n");
2587 else 2646 else
2588 ata_dev_err(qc->dev, "status: { %s%s%s%s}\n", 2647 ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n",
2589 res->command & ATA_DRDY ? "DRDY " : "", 2648 res->command & ATA_DRDY ? "DRDY " : "",
2590 res->command & ATA_DF ? "DF " : "", 2649 res->command & ATA_DF ? "DF " : "",
2591 res->command & ATA_DRQ ? "DRQ " : "", 2650 res->command & ATA_DRQ ? "DRQ " : "",
2651 res->command & ATA_SENSE ? "SENSE " : "",
2592 res->command & ATA_ERR ? "ERR " : ""); 2652 res->command & ATA_ERR ? "ERR " : "");
2593 } 2653 }
2594 2654