Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-4.2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata

Pull libata fixes from Tejun Heo:
"Three minor device-specific fixes and revert of NCQ autosense added
during this -rc1.

It turned out that NCQ autosense as currently implemented interferes
with the usual error handling behavior. It will be revisited in the
near future"

* 'for-4.2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
ata: ahci_brcmstb: Fix misuse of IS_ENABLED
sata_sx4: Check return code from pdc20621_i2c_read()
Revert "libata: Implement NCQ autosense"
Revert "libata: Implement support for sense data reporting"
Revert "libata-eh: Set 'information' field for autosense"
ata: ahci_brcmstb: Fix warnings with CONFIG_PM_SLEEP=n

+24 -204
+4 -2
drivers/ata/ahci_brcmstb.c
··· 92 92 * Other architectures (e.g., ARM) either do not support big endian, or 93 93 * else leave I/O in little endian mode. 94 94 */ 95 - if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 95 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) 96 96 return __raw_readl(addr); 97 97 else 98 98 return readl_relaxed(addr); ··· 101 101 static inline void brcm_sata_writereg(u32 val, void __iomem *addr) 102 102 { 103 103 /* See brcm_sata_readreg() comments */ 104 - if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 104 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) 105 105 __raw_writel(val, addr); 106 106 else 107 107 writel_relaxed(val, addr); ··· 209 209 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 210 210 } 211 211 212 + #ifdef CONFIG_PM_SLEEP 212 213 static int brcm_ahci_suspend(struct device *dev) 213 214 { 214 215 struct ata_host *host = dev_get_drvdata(dev); ··· 232 231 brcm_sata_phys_enable(priv); 233 232 return ahci_platform_resume(dev); 234 233 } 234 + #endif 235 235 236 236 static struct scsi_host_template ahci_platform_sht = { 237 237 AHCI_SHT(DRV_NAME),
+3 -21
drivers/ata/libata-core.c
··· 694 694 * RETURNS: 695 695 * Block address read from @tf. 696 696 */ 697 - u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) 697 + u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev) 698 698 { 699 699 u64 block = 0; 700 700 701 - if (!dev || tf->flags & ATA_TFLAG_LBA) { 701 + if (tf->flags & ATA_TFLAG_LBA) { 702 702 if (tf->flags & ATA_TFLAG_LBA48) { 703 703 block |= (u64)tf->hob_lbah << 40; 704 704 block |= (u64)tf->hob_lbam << 32; ··· 2147 2147 return 0; 2148 2148 } 2149 2149 2150 - static 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 2151 * ata_dev_configure - Configure the specified ATA/ATAPI device 2170 2152 * @dev: Target device to configure ··· 2369 2387 dev->devslp_timing[i] = sata_setting[j]; 2370 2388 } 2371 2389 } 2372 - ata_dev_config_sense_reporting(dev); 2390 + 2373 2391 dev->cdb_len = 16; 2374 2392 } 2375 2393
+2 -103
drivers/ata/libata-eh.c
··· 1592 1592 tf->hob_lbah = buf[10]; 1593 1593 tf->nsect = buf[12]; 1594 1594 tf->hob_nsect = buf[13]; 1595 - if (ata_id_has_ncq_autosense(dev->id)) 1596 - tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16]; 1597 1595 1598 1596 return 0; 1599 1597 } ··· 1624 1626 err_mask = ata_exec_internal(dev, &tf, cdb, DMA_NONE, NULL, 0, 0); 1625 1627 if (err_mask == AC_ERR_DEV) 1626 1628 *r_sense_key = tf.feature >> 4; 1627 - return err_mask; 1628 - } 1629 - 1630 - /** 1631 - * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT 1632 - * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to 1633 - * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1634 - * @dfl_sense_key: default sense key to use 1635 - * 1636 - * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK 1637 - * SENSE. This function is EH helper. 1638 - * 1639 - * LOCKING: 1640 - * Kernel thread context (may sleep). 1641 - * 1642 - * RETURNS: 1643 - * encoded sense data on success, 0 on failure or if sense data 1644 - * is not available. 1645 - */ 1646 - static u32 ata_eh_request_sense(struct ata_queued_cmd *qc, 1647 - struct scsi_cmnd *cmd) 1648 - { 1649 - struct ata_device *dev = qc->dev; 1650 - struct ata_taskfile tf; 1651 - unsigned int err_mask; 1652 - 1653 - if (!cmd) 1654 - return 0; 1655 - 1656 - DPRINTK("ATA request sense\n"); 1657 - ata_dev_warn(dev, "request sense\n"); 1658 - if (!ata_id_sense_reporting_enabled(dev->id)) { 1659 - ata_dev_warn(qc->dev, "sense data reporting disabled\n"); 1660 - return 0; 1661 - } 1662 - ata_tf_init(dev, &tf); 1663 - 1664 - tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 1665 - tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; 1666 - tf.command = ATA_CMD_REQ_SENSE_DATA; 1667 - tf.protocol = ATA_PROT_NODATA; 1668 - 1669 - err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1670 - /* 1671 - * ACS-4 states: 1672 - * The device may set the SENSE DATA AVAILABLE bit to one in the 1673 - * STATUS field and clear the ERROR bit to zero in the STATUS field 1674 - * to indicate that the command returned completion without an error 1675 - * and the sense data described in table 306 is available. 1676 - * 1677 - * IOW the 'ATA_SENSE' bit might not be set even though valid 1678 - * sense data is available. 1679 - * So check for both. 1680 - */ 1681 - if ((tf.command & ATA_SENSE) || 1682 - tf.lbah != 0 || tf.lbam != 0 || tf.lbal != 0) { 1683 - ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal); 1684 - qc->flags |= ATA_QCFLAG_SENSE_VALID; 1685 - ata_dev_warn(dev, "sense data %02x/%02x/%02x\n", 1686 - tf.lbah, tf.lbam, tf.lbal); 1687 - } else { 1688 - ata_dev_warn(dev, "request sense failed stat %02x emask %x\n", 1689 - tf.command, err_mask); 1690 - } 1691 1629 return err_mask; 1692 1630 } 1693 1631 ··· 1789 1855 memcpy(&qc->result_tf, &tf, sizeof(tf)); 1790 1856 qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48; 1791 1857 qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; 1792 - if (qc->result_tf.auxiliary) { 1793 - char sense_key, asc, ascq; 1794 - 1795 - sense_key = (qc->result_tf.auxiliary >> 16) & 0xff; 1796 - asc = (qc->result_tf.auxiliary >> 8) & 0xff; 1797 - ascq = qc->result_tf.auxiliary & 0xff; 1798 - ata_dev_dbg(dev, "NCQ Autosense %02x/%02x/%02x\n", 1799 - sense_key, asc, ascq); 1800 - ata_scsi_set_sense(qc->scsicmd, sense_key, asc, ascq); 1801 - ata_scsi_set_sense_information(qc->scsicmd, &qc->result_tf); 1802 - qc->flags |= ATA_QCFLAG_SENSE_VALID; 1803 - } 1804 - 1805 1858 ehc->i.err_mask &= ~AC_ERR_DEV; 1806 1859 } 1807 1860 ··· 1817 1896 qc->err_mask |= AC_ERR_HSM; 1818 1897 return ATA_EH_RESET; 1819 1898 } 1820 - 1821 - /* 1822 - * Sense data reporting does not work if the 1823 - * device fault bit is set. 1824 - */ 1825 - if ((stat & ATA_SENSE) && !(stat & ATA_DF) && 1826 - !(qc->flags & ATA_QCFLAG_SENSE_VALID)) { 1827 - if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { 1828 - tmp = ata_eh_request_sense(qc, qc->scsicmd); 1829 - if (tmp) 1830 - qc->err_mask |= tmp; 1831 - else 1832 - ata_scsi_set_sense_information(qc->scsicmd, tf); 1833 - } else { 1834 - ata_dev_warn(qc->dev, "sense data available but port frozen\n"); 1835 - } 1836 - } 1837 - 1838 - /* Set by NCQ autosense or request sense above */ 1839 - if (qc->flags & ATA_QCFLAG_SENSE_VALID) 1840 - return 0; 1841 1899 1842 1900 if (stat & (ATA_ERR | ATA_DF)) 1843 1901 qc->err_mask |= AC_ERR_DEV; ··· 2561 2661 2562 2662 #ifdef CONFIG_ATA_VERBOSE_ERROR 2563 2663 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2564 - ATA_SENSE | ATA_ERR)) { 2664 + ATA_ERR)) { 2565 2665 if (res->command & ATA_BUSY) 2566 2666 ata_dev_err(qc->dev, "status: { Busy }\n"); 2567 2667 else 2568 - ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", 2668 + ata_dev_err(qc->dev, "status: { %s%s%s%s}\n", 2569 2669 res->command & ATA_DRDY ? "DRDY " : "", 2570 2670 res->command & ATA_DF ? "DF " : "", 2571 2671 res->command & ATA_DRQ ? "DRQ " : "", 2572 - res->command & ATA_SENSE ? "SENSE " : "", 2573 2672 res->command & ATA_ERR ? "ERR " : ""); 2574 2673 } 2575 2674
+2 -19
drivers/ata/libata-scsi.c
··· 270 270 ata_scsi_park_show, ata_scsi_park_store); 271 271 EXPORT_SYMBOL_GPL(dev_attr_unload_heads); 272 272 273 - void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) 273 + static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) 274 274 { 275 - if (!cmd) 276 - return; 277 - 278 275 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 279 276 280 277 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq); 281 - } 282 - 283 - void ata_scsi_set_sense_information(struct scsi_cmnd *cmd, 284 - const struct ata_taskfile *tf) 285 - { 286 - u64 information; 287 - 288 - if (!cmd) 289 - return; 290 - 291 - information = ata_tf_read_block(tf, NULL); 292 - scsi_set_sense_information(cmd->sense_buffer, information); 293 278 } 294 279 295 280 static ssize_t ··· 1777 1792 ((cdb[2] & 0x20) || need_sense)) { 1778 1793 ata_gen_passthru_sense(qc); 1779 1794 } else { 1780 - if (qc->flags & ATA_QCFLAG_SENSE_VALID) { 1781 - cmd->result = SAM_STAT_CHECK_CONDITION; 1782 - } else if (!need_sense) { 1795 + if (!need_sense) { 1783 1796 cmd->result = SAM_STAT_GOOD; 1784 1797 } else { 1785 1798 /* TODO: decide which descriptor format to use
+1 -5
drivers/ata/libata.h
··· 67 67 extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 68 68 u64 block, u32 n_block, unsigned int tf_flags, 69 69 unsigned int tag); 70 - extern u64 ata_tf_read_block(const struct ata_taskfile *tf, 71 - struct ata_device *dev); 70 + extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); 72 71 extern unsigned ata_exec_internal(struct ata_device *dev, 73 72 struct ata_taskfile *tf, const u8 *cdb, 74 73 int dma_dir, void *buf, unsigned int buflen, ··· 137 138 struct scsi_host_template *sht); 138 139 extern void ata_scsi_scan_host(struct ata_port *ap, int sync); 139 140 extern int ata_scsi_offline_dev(struct ata_device *dev); 140 - extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq); 141 - extern void ata_scsi_set_sense_information(struct scsi_cmnd *cmd, 142 - const struct ata_taskfile *tf); 143 141 extern void ata_scsi_media_change_notify(struct ata_device *dev); 144 142 extern void ata_scsi_hotplug(struct work_struct *work); 145 143 extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
+12 -4
drivers/ata/sata_sx4.c
··· 1238 1238 readl(mmio + PDC_SDRAM_CONTROL); 1239 1239 1240 1240 /* Turn on for ECC */ 1241 - pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1242 - PDC_DIMM_SPD_TYPE, &spd0); 1241 + if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1242 + PDC_DIMM_SPD_TYPE, &spd0)) { 1243 + pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n", 1244 + PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE); 1245 + return 1; 1246 + } 1243 1247 if (spd0 == 0x02) { 1244 1248 data |= (0x01 << 16); 1245 1249 writel(data, mmio + PDC_SDRAM_CONTROL); ··· 1384 1380 1385 1381 /* ECC initiliazation. */ 1386 1382 1387 - pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1388 - PDC_DIMM_SPD_TYPE, &spd0); 1383 + if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1384 + PDC_DIMM_SPD_TYPE, &spd0)) { 1385 + pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n", 1386 + PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE); 1387 + return 1; 1388 + } 1389 1389 if (spd0 == 0x02) { 1390 1390 void *buf; 1391 1391 VPRINTK("Start ECC initialization\n");
-31
drivers/scsi/scsi_error.c
··· 26 26 #include <linux/blkdev.h> 27 27 #include <linux/delay.h> 28 28 #include <linux/jiffies.h> 29 - #include <asm/unaligned.h> 30 29 31 30 #include <scsi/scsi.h> 32 31 #include <scsi/scsi_cmnd.h> ··· 2522 2523 } 2523 2524 } 2524 2525 EXPORT_SYMBOL(scsi_build_sense_buffer); 2525 - 2526 - /** 2527 - * scsi_set_sense_information - set the information field in a 2528 - * formatted sense data buffer 2529 - * @buf: Where to build sense data 2530 - * @info: 64-bit information value to be set 2531 - * 2532 - **/ 2533 - void scsi_set_sense_information(u8 *buf, u64 info) 2534 - { 2535 - if ((buf[0] & 0x7f) == 0x72) { 2536 - u8 *ucp, len; 2537 - 2538 - len = buf[7]; 2539 - ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0); 2540 - if (!ucp) { 2541 - buf[7] = len + 0xa; 2542 - ucp = buf + 8 + len; 2543 - } 2544 - ucp[0] = 0; 2545 - ucp[1] = 0xa; 2546 - ucp[2] = 0x80; /* Valid bit */ 2547 - ucp[3] = 0; 2548 - put_unaligned_be64(info, &ucp[4]); 2549 - } else if ((buf[0] & 0x7f) == 0x70) { 2550 - buf[0] |= 0x80; 2551 - put_unaligned_be64(info, &buf[3]); 2552 - } 2553 - } 2554 - EXPORT_SYMBOL(scsi_set_sense_information);
-18
include/linux/ata.h
··· 385 385 SATA_SSP = 0x06, /* Software Settings Preservation */ 386 386 SATA_DEVSLP = 0x09, /* Device Sleep */ 387 387 388 - SETFEATURE_SENSE_DATA = 0xC3, /* Sense Data Reporting feature */ 389 - 390 388 /* feature values for SET_MAX */ 391 389 ATA_SET_MAX_ADDR = 0x00, 392 390 ATA_SET_MAX_PASSWD = 0x01, ··· 528 530 #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) 529 531 #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4)) 530 532 #define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)) 531 - #define ata_id_has_ncq_autosense(id) \ 532 - ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7)) 533 533 534 534 static inline bool ata_id_has_hipm(const u16 *id) 535 535 { ··· 714 718 return true; 715 719 716 720 return false; 717 - } 718 - 719 - static inline bool ata_id_has_sense_reporting(const u16 *id) 720 - { 721 - if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15))) 722 - return false; 723 - return id[ATA_ID_COMMAND_SET_3] & (1 << 6); 724 - } 725 - 726 - static inline bool ata_id_sense_reporting_enabled(const u16 *id) 727 - { 728 - if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15))) 729 - return false; 730 - return id[ATA_ID_COMMAND_SET_4] & (1 << 6); 731 721 } 732 722 733 723 /**
-1
include/scsi/scsi_eh.h
··· 28 28 u64 * info_out); 29 29 30 30 extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); 31 - extern void scsi_set_sense_information(u8 *buf, u64 info); 32 31 33 32 extern int scsi_ioctl_reset(struct scsi_device *, int __user *); 34 33