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

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

Pull ata fixes from Damien Le Moal:

- Cleanup whitespace in messages in libata-core and the pata_pdc2027x,
pata_macio drivers (Colin)

- Fix ata_to_sense_error() to avoid seeing nonsensical sense data for
rare cases where we fail to get sense data from the drive. The
complementary fix to this is to ensure that we always return the
generic "ABORTED COMMAND" sense data for a failed command for which
we have no status or error fields

- The recent changes to link power management (LPM) which now prevent
the user from attempting to set an LPM policy through the
link_power_management_policy caused some regressions in test
environments because of the error that is now returned when writing
to that attribute when LPM is not supported. To allow users to not
trip on this, introduce the new link_power_management_supported
attribute to allow simple testing of a port/device LPM support (me)

* tag 'ata-6.17-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
ata: pata_pdc2027x: Remove space before newline and abbreviations
ata: pata_macio: Remove space before newline
ata: libata-core: Remove space before newline
ata: libata-sata: Add link_power_management_supported sysfs attribute
ata: libata-scsi: Return aborted command when missing sense and result TF
ata: libata-scsi: Fix ata_to_sense_error() status handling

+71 -39
+1
drivers/ata/ata_piix.c
··· 1089 1089 }; 1090 1090 1091 1091 static struct attribute *piix_sidpr_shost_attrs[] = { 1092 + &dev_attr_link_power_management_supported.attr, 1092 1093 &dev_attr_link_power_management_policy.attr, 1093 1094 NULL 1094 1095 };
+1
drivers/ata/libahci.c
··· 111 111 static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL); 112 112 113 113 static struct attribute *ahci_shost_attrs[] = { 114 + &dev_attr_link_power_management_supported.attr, 114 115 &dev_attr_link_power_management_policy.attr, 115 116 &dev_attr_em_message_type.attr, 116 117 &dev_attr_em_message.attr,
+1 -1
drivers/ata/libata-core.c
··· 4602 4602 return AC_ERR_INVALID; 4603 4603 4604 4604 /* set up init dev params taskfile */ 4605 - ata_dev_dbg(dev, "init dev params \n"); 4605 + ata_dev_dbg(dev, "init dev params\n"); 4606 4606 4607 4607 ata_tf_init(dev, &tf); 4608 4608 tf.command = ATA_CMD_INIT_DEV_PARAMS;
+41 -12
drivers/ata/libata-sata.c
··· 900 900 [ATA_LPM_MIN_POWER] = "min_power", 901 901 }; 902 902 903 + /* 904 + * Check if a port supports link power management. 905 + * Must be called with the port locked. 906 + */ 907 + static bool ata_scsi_lpm_supported(struct ata_port *ap) 908 + { 909 + struct ata_link *link; 910 + struct ata_device *dev; 911 + 912 + if (ap->flags & ATA_FLAG_NO_LPM) 913 + return false; 914 + 915 + ata_for_each_link(link, ap, EDGE) { 916 + ata_for_each_dev(dev, &ap->link, ENABLED) { 917 + if (dev->quirks & ATA_QUIRK_NOLPM) 918 + return false; 919 + } 920 + } 921 + 922 + return true; 923 + } 924 + 925 + static ssize_t ata_scsi_lpm_supported_show(struct device *dev, 926 + struct device_attribute *attr, char *buf) 927 + { 928 + struct Scsi_Host *shost = class_to_shost(dev); 929 + struct ata_port *ap = ata_shost_to_port(shost); 930 + unsigned long flags; 931 + bool supported; 932 + 933 + spin_lock_irqsave(ap->lock, flags); 934 + supported = ata_scsi_lpm_supported(ap); 935 + spin_unlock_irqrestore(ap->lock, flags); 936 + 937 + return sysfs_emit(buf, "%d\n", supported); 938 + } 939 + DEVICE_ATTR(link_power_management_supported, S_IRUGO, 940 + ata_scsi_lpm_supported_show, NULL); 941 + EXPORT_SYMBOL_GPL(dev_attr_link_power_management_supported); 942 + 903 943 static ssize_t ata_scsi_lpm_store(struct device *device, 904 944 struct device_attribute *attr, 905 945 const char *buf, size_t count) 906 946 { 907 947 struct Scsi_Host *shost = class_to_shost(device); 908 948 struct ata_port *ap = ata_shost_to_port(shost); 909 - struct ata_link *link; 910 - struct ata_device *dev; 911 949 enum ata_lpm_policy policy; 912 950 unsigned long flags; 913 951 ··· 962 924 963 925 spin_lock_irqsave(ap->lock, flags); 964 926 965 - if (ap->flags & ATA_FLAG_NO_LPM) { 927 + if (!ata_scsi_lpm_supported(ap)) { 966 928 count = -EOPNOTSUPP; 967 929 goto out_unlock; 968 - } 969 - 970 - ata_for_each_link(link, ap, EDGE) { 971 - ata_for_each_dev(dev, &ap->link, ENABLED) { 972 - if (dev->quirks & ATA_QUIRK_NOLPM) { 973 - count = -EOPNOTSUPP; 974 - goto out_unlock; 975 - } 976 - } 977 930 } 978 931 979 932 ap->target_lpm_policy = policy;
+19 -19
drivers/ata/libata-scsi.c
··· 859 859 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 860 860 }; 861 861 static const unsigned char stat_table[][4] = { 862 - /* Must be first because BUSY means no other bits valid */ 863 - {0x80, ABORTED_COMMAND, 0x47, 0x00}, 864 - // Busy, fake parity for now 865 - {0x40, ILLEGAL_REQUEST, 0x21, 0x04}, 866 - // Device ready, unaligned write command 867 - {0x20, HARDWARE_ERROR, 0x44, 0x00}, 868 - // Device fault, internal target failure 869 - {0x08, ABORTED_COMMAND, 0x47, 0x00}, 870 - // Timed out in xfer, fake parity for now 871 - {0x04, RECOVERED_ERROR, 0x11, 0x00}, 872 - // Recovered ECC error Medium error, recovered 873 - {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 862 + /* Busy: must be first because BUSY means no other bits valid */ 863 + { ATA_BUSY, ABORTED_COMMAND, 0x00, 0x00 }, 864 + /* Device fault: INTERNAL TARGET FAILURE */ 865 + { ATA_DF, HARDWARE_ERROR, 0x44, 0x00 }, 866 + /* Corrected data error */ 867 + { ATA_CORR, RECOVERED_ERROR, 0x00, 0x00 }, 868 + 869 + { 0xFF, 0xFF, 0xFF, 0xFF }, /* END mark */ 874 870 }; 875 871 876 872 /* ··· 938 942 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 939 943 ata_dev_dbg(dev, 940 944 "missing result TF: can't generate ATA PT sense data\n"); 945 + if (qc->err_mask) 946 + ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0); 941 947 return; 942 948 } 943 949 ··· 994 996 995 997 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 996 998 ata_dev_dbg(dev, 997 - "missing result TF: can't generate sense data\n"); 998 - return; 999 + "Missing result TF: reporting aborted command\n"); 1000 + goto aborted; 999 1001 } 1000 1002 1001 1003 /* Use ata_to_sense_error() to map status register bits ··· 1006 1008 ata_to_sense_error(tf->status, tf->error, 1007 1009 &sense_key, &asc, &ascq); 1008 1010 ata_scsi_set_sense(dev, cmd, sense_key, asc, ascq); 1009 - } else { 1010 - /* Could not decode error */ 1011 - ata_dev_warn(dev, "could not decode error status 0x%x err_mask 0x%x\n", 1012 - tf->status, qc->err_mask); 1013 - ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0); 1014 1011 return; 1015 1012 } 1013 + 1014 + /* Could not decode error */ 1015 + ata_dev_warn(dev, 1016 + "Could not decode error 0x%x, status 0x%x (err_mask=0x%x)\n", 1017 + tf->error, tf->status, qc->err_mask); 1018 + aborted: 1019 + ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0); 1016 1020 } 1017 1021 1018 1022 void ata_scsi_sdev_config(struct scsi_device *sdev)
+1 -1
drivers/ata/pata_macio.c
··· 758 758 759 759 static void pata_macio_reset_hw(struct pata_macio_priv *priv, int resume) 760 760 { 761 - dev_dbg(priv->dev, "Enabling & resetting... \n"); 761 + dev_dbg(priv->dev, "Enabling & resetting...\n"); 762 762 763 763 if (priv->mediabay) 764 764 return;
+6 -6
drivers/ata/pata_pdc2027x.c
··· 295 295 } 296 296 297 297 /* Set the PIO timing registers using value table for 133MHz */ 298 - ata_port_dbg(ap, "Set pio regs... \n"); 298 + ata_port_dbg(ap, "Set PIO regs...\n"); 299 299 300 300 ctcr0 = ioread32(dev_mmio(ap, adev, PDC_CTCR0)); 301 301 ctcr0 &= 0xffff0000; ··· 308 308 ctcr1 |= (pdc2027x_pio_timing_tbl[pio].value2 << 24); 309 309 iowrite32(ctcr1, dev_mmio(ap, adev, PDC_CTCR1)); 310 310 311 - ata_port_dbg(ap, "Set to pio mode[%u] \n", pio); 311 + ata_port_dbg(ap, "Set to PIO mode[%u]\n", pio); 312 312 } 313 313 314 314 /** ··· 341 341 iowrite32(ctcr1 & ~(1 << 7), dev_mmio(ap, adev, PDC_CTCR1)); 342 342 } 343 343 344 - ata_port_dbg(ap, "Set udma regs... \n"); 344 + ata_port_dbg(ap, "Set UDMA regs...\n"); 345 345 346 346 ctcr1 = ioread32(dev_mmio(ap, adev, PDC_CTCR1)); 347 347 ctcr1 &= 0xff000000; ··· 350 350 (pdc2027x_udma_timing_tbl[udma_mode].value2 << 16); 351 351 iowrite32(ctcr1, dev_mmio(ap, adev, PDC_CTCR1)); 352 352 353 - ata_port_dbg(ap, "Set to udma mode[%u] \n", udma_mode); 353 + ata_port_dbg(ap, "Set to UDMA mode[%u]\n", udma_mode); 354 354 355 355 } else if ((dma_mode >= XFER_MW_DMA_0) && 356 356 (dma_mode <= XFER_MW_DMA_2)) { 357 357 /* Set the MDMA timing registers with value table for 133MHz */ 358 358 unsigned int mdma_mode = dma_mode & 0x07; 359 359 360 - ata_port_dbg(ap, "Set mdma regs... \n"); 360 + ata_port_dbg(ap, "Set MDMA regs...\n"); 361 361 ctcr0 = ioread32(dev_mmio(ap, adev, PDC_CTCR0)); 362 362 363 363 ctcr0 &= 0x0000ffff; ··· 366 366 367 367 iowrite32(ctcr0, dev_mmio(ap, adev, PDC_CTCR0)); 368 368 369 - ata_port_dbg(ap, "Set to mdma mode[%u] \n", mdma_mode); 369 + ata_port_dbg(ap, "Set to MDMA mode[%u]\n", mdma_mode); 370 370 } else { 371 371 ata_port_err(ap, "Unknown dma mode [%u] ignored\n", dma_mode); 372 372 }
+1
include/linux/libata.h
··· 545 545 546 546 extern struct device_attribute dev_attr_unload_heads; 547 547 #ifdef CONFIG_SATA_HOST 548 + extern struct device_attribute dev_attr_link_power_management_supported; 548 549 extern struct device_attribute dev_attr_link_power_management_policy; 549 550 extern struct device_attribute dev_attr_ncq_prio_supported; 550 551 extern struct device_attribute dev_attr_ncq_prio_enable;