aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/libata-core.c20
-rw-r--r--drivers/ata/libata-eh.c86
-rw-r--r--include/linux/ata.h16
3 files changed, 4 insertions, 118 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 426bc12459de..19bcb80b2031 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2147,24 +2147,6 @@ static int ata_dev_config_ncq(struct ata_device *dev,
2147 return 0; 2147 return 0;
2148} 2148}
2149 2149
2150static void ata_dev_config_sense_reporting(struct ata_device *dev)
2151{
2152 unsigned int err_mask;
2153
2154 if (!ata_id_has_sense_reporting(dev->id))
2155 return;
2156
2157 if (ata_id_sense_reporting_enabled(dev->id))
2158 return;
2159
2160 err_mask = ata_dev_set_feature(dev, SETFEATURE_SENSE_DATA, 0x1);
2161 if (err_mask) {
2162 ata_dev_dbg(dev,
2163 "failed to enable Sense Data Reporting, Emask 0x%x\n",
2164 err_mask);
2165 }
2166}
2167
2168/** 2150/**
2169 * ata_dev_configure - Configure the specified ATA/ATAPI device 2151 * ata_dev_configure - Configure the specified ATA/ATAPI device
2170 * @dev: Target device to configure 2152 * @dev: Target device to configure
@@ -2387,7 +2369,7 @@ int ata_dev_configure(struct ata_device *dev)
2387 dev->devslp_timing[i] = sata_setting[j]; 2369 dev->devslp_timing[i] = sata_setting[j];
2388 } 2370 }
2389 } 2371 }
2390 ata_dev_config_sense_reporting(dev); 2372
2391 dev->cdb_len = 16; 2373 dev->cdb_len = 16;
2392 } 2374 }
2393 2375
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index af08d32af4e0..16125be34893 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1630,70 +1630,6 @@ unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key)
1630} 1630}
1631 1631
1632/** 1632/**
1633 * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT
1634 * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to
1635 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
1636 * @dfl_sense_key: default sense key to use
1637 *
1638 * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK
1639 * SENSE. This function is EH helper.
1640 *
1641 * LOCKING:
1642 * Kernel thread context (may sleep).
1643 *
1644 * RETURNS:
1645 * encoded sense data on success, 0 on failure or if sense data
1646 * is not available.
1647 */
1648static u32 ata_eh_request_sense(struct ata_queued_cmd *qc,
1649 struct scsi_cmnd *cmd)
1650{
1651 struct ata_device *dev = qc->dev;
1652 struct ata_taskfile tf;
1653 unsigned int err_mask;
1654
1655 if (!cmd)
1656 return 0;
1657
1658 DPRINTK("ATA request sense\n");
1659 ata_dev_warn(dev, "request sense\n");
1660 if (!ata_id_sense_reporting_enabled(dev->id)) {
1661 ata_dev_warn(qc->dev, "sense data reporting disabled\n");
1662 return 0;
1663 }
1664 ata_tf_init(dev, &tf);
1665
1666 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1667 tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1668 tf.command = ATA_CMD_REQ_SENSE_DATA;
1669 tf.protocol = ATA_PROT_NODATA;
1670
1671 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1672 /*
1673 * ACS-4 states:
1674 * The device may set the SENSE DATA AVAILABLE bit to one in the
1675 * STATUS field and clear the ERROR bit to zero in the STATUS field
1676 * to indicate that the command returned completion without an error
1677 * and the sense data described in table 306 is available.
1678 *
1679 * IOW the 'ATA_SENSE' bit might not be set even though valid
1680 * sense data is available.
1681 * So check for both.
1682 */
1683 if ((tf.command & ATA_SENSE) ||
1684 tf.lbah != 0 || tf.lbam != 0 || tf.lbal != 0) {
1685 ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal);
1686 qc->flags |= ATA_QCFLAG_SENSE_VALID;
1687 ata_dev_warn(dev, "sense data %02x/%02x/%02x\n",
1688 tf.lbah, tf.lbam, tf.lbal);
1689 } else {
1690 ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
1691 tf.command, err_mask);
1692 }
1693 return err_mask;
1694}
1695
1696/**
1697 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE 1633 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1698 * @dev: device to perform REQUEST_SENSE to 1634 * @dev: device to perform REQUEST_SENSE to
1699 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1635 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
@@ -1896,22 +1832,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1896 return ATA_EH_RESET; 1832 return ATA_EH_RESET;
1897 } 1833 }
1898 1834
1899 /* 1835 /* Set by NCQ autosense */
1900 * Sense data reporting does not work if the
1901 * device fault bit is set.
1902 */
1903 if ((stat & ATA_SENSE) && !(stat & ATA_DF) &&
1904 !(qc->flags & ATA_QCFLAG_SENSE_VALID)) {
1905 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1906 tmp = ata_eh_request_sense(qc, qc->scsicmd);
1907 if (tmp)
1908 qc->err_mask |= tmp;
1909 } else {
1910 ata_dev_warn(qc->dev, "sense data available but port frozen\n");
1911 }
1912 }
1913
1914 /* Set by NCQ autosense or request sense above */
1915 if (qc->flags & ATA_QCFLAG_SENSE_VALID) 1836 if (qc->flags & ATA_QCFLAG_SENSE_VALID)
1916 return 0; 1837 return 0;
1917 1838
@@ -2658,15 +2579,14 @@ static void ata_eh_link_report(struct ata_link *link)
2658 2579
2659#ifdef CONFIG_ATA_VERBOSE_ERROR 2580#ifdef CONFIG_ATA_VERBOSE_ERROR
2660 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2581 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2661 ATA_SENSE | ATA_ERR)) { 2582 ATA_ERR)) {
2662 if (res->command & ATA_BUSY) 2583 if (res->command & ATA_BUSY)
2663 ata_dev_err(qc->dev, "status: { Busy }\n"); 2584 ata_dev_err(qc->dev, "status: { Busy }\n");
2664 else 2585 else
2665 ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", 2586 ata_dev_err(qc->dev, "status: { %s%s%s%s}\n",
2666 res->command & ATA_DRDY ? "DRDY " : "", 2587 res->command & ATA_DRDY ? "DRDY " : "",
2667 res->command & ATA_DF ? "DF " : "", 2588 res->command & ATA_DF ? "DF " : "",
2668 res->command & ATA_DRQ ? "DRQ " : "", 2589 res->command & ATA_DRQ ? "DRQ " : "",
2669 res->command & ATA_SENSE ? "SENSE " : "",
2670 res->command & ATA_ERR ? "ERR " : ""); 2590 res->command & ATA_ERR ? "ERR " : "");
2671 } 2591 }
2672 2592
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 6c78956aa470..0e6a782575b5 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -385,8 +385,6 @@ enum {
385 SATA_SSP = 0x06, /* Software Settings Preservation */ 385 SATA_SSP = 0x06, /* Software Settings Preservation */
386 SATA_DEVSLP = 0x09, /* Device Sleep */ 386 SATA_DEVSLP = 0x09, /* Device Sleep */
387 387
388 SETFEATURE_SENSE_DATA = 0xC3, /* Sense Data Reporting feature */
389
390 /* feature values for SET_MAX */ 388 /* feature values for SET_MAX */
391 ATA_SET_MAX_ADDR = 0x00, 389 ATA_SET_MAX_ADDR = 0x00,
392 ATA_SET_MAX_PASSWD = 0x01, 390 ATA_SET_MAX_PASSWD = 0x01,
@@ -720,20 +718,6 @@ static inline bool ata_id_has_read_log_dma_ext(const u16 *id)
720 return false; 718 return false;
721} 719}
722 720
723static inline bool ata_id_has_sense_reporting(const u16 *id)
724{
725 if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
726 return false;
727 return id[ATA_ID_COMMAND_SET_3] & (1 << 6);
728}
729
730static inline bool ata_id_sense_reporting_enabled(const u16 *id)
731{
732 if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
733 return false;
734 return id[ATA_ID_COMMAND_SET_4] & (1 << 6);
735}
736
737/** 721/**
738 * ata_id_major_version - get ATA level of drive 722 * ata_id_major_version - get ATA level of drive
739 * @id: Identify data 723 * @id: Identify data