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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull ata updates from Damien Le Moal:

- Replace the ATA_DFLAG_ZAC device flag with the helper function
ata_dev_is_zac() testing directly the device class and device zoned
mode (me)

- Some small cleanup of ata_scsi_offline_dev() code (me)

- Improve the description of the link power management (LPM) policies
in Kconfig and in the comments defining these. Together with this,
clarify the description of the ahci driver mobile_lpm_policy module
parameter (me)

- Various code refactoring of libata LPM handling (ata_eh_set_lpm()
renaming, introduce ata_dev_config_lpm(), LPM related quirk handling,
and LPM related feature advertizing on device scan) (me)

- Avoid unnecessary device reset when revalidating after an error when
LPM is used (me)

- Do not allow setting a port/link LPM policy if LPM is not supported,
either because the controller does not support partial, slumber nor
devsleep, or when the port is an external port with hotplug
capability (me)

- Make sure that device initiated power management (DIPM) is not
enabled if the host (controller) lacks support for this feature (me)

- Improve messages and debug messages related to LPM, in particular,
reduce the number of messages signaling the lack of LPM support (me)

- Cache in memory a device general purpose log directory to avoid
having to access this log for every log page access. The intent here
is to reduce the number of read log commands when scanning or
revalidating a device (me)

- Change ata_dev_cleanup_cdl_resources() to be a static function (me)

- Rename and simplify the mode setting functions (me)

- Introduce the helper function ata_port_eh_scheduled() to check if EH
is pending or running for a port (me)

- Improve ata_eh_set_pending() (return bool instead of int) (me)

- Use sysfs_emit() instead of scnprintf() for libata-transport
attributes (Jonathan)

- Use the existing macro definiton of RDC vendor ID instead of
hardcoding it in the pata_rdc driver (Andy)

- Rework how EH is called for a port to avoid needing to pass along the
prereset, softreset, hardreset and postreset operations. The driver
API documentation for this is also updated (me)

* tag 'ata-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: (28 commits)
Documentation: driver-api: Update libata error handler information
ata: libata-eh: Simplify reset operation management
ata: libata-eh: Remove ata_do_eh()
ata: pata_rdc: Use registered definition for the RDC vendor
ata: libata-eh: Make ata_eh_followup_srst_needed() return a bool
ata: libata-transport: replace scnprintf with sysfs_emit for simple attributes
ata: libata-eh: use bool for fastdrain in ata_eh_set_pending()
ata: libata: Introduce ata_port_eh_scheduled()
ata: libata-core: Rename ata_do_set_mode()
ata: libata-eh: Rename and make ata_set_mode() static
ata: libata-core: Make ata_dev_cleanup_cdl_resources() static
ata: libata-core: Cache the general purpose log directory
ata: libata_eh: Add debug messages to ata_eh_link_set_lpm()
ata: libata-core: Reduce the number of messages signaling broken LPM
ata: ahci: Disallow LPM policy control if not supported
ata: ahci: Disallow LPM policy control for external ports
ata: ahci: Disable DIPM if host lacks support
ata: libata-sata: Disallow changing LPM state if not supported
ata: libata-eh: Avoid unnecessary resets when revalidating devices
ata: libata-core: Advertize device support for DIPM and HIPM features
...

+563 -442
+16 -9
Documentation/driver-api/libata.rst
··· 283 283 284 284 ``->error_handler()`` is a driver's hook into probe, hotplug, and recovery 285 285 and other exceptional conditions. The primary responsibility of an 286 - implementation is to call :c:func:`ata_do_eh` or :c:func:`ata_bmdma_drive_eh` 287 - with a set of EH hooks as arguments: 286 + implementation is to call :c:func:`ata_std_error_handler`. 288 287 289 - 'prereset' hook (may be NULL) is called during an EH reset, before any 290 - other actions are taken. 288 + :c:func:`ata_std_error_handler` will perform a standard error handling sequence 289 + to resurect failed devices, detach lost devices and add new devices (if any). 290 + This function will call the various reset operations for a port, as needed. 291 + These operations are as follows. 291 292 292 - 'postreset' hook (may be NULL) is called after the EH reset is 293 - performed. Based on existing conditions, severity of the problem, and 294 - hardware capabilities, 293 + * The 'prereset' operation (which may be NULL) is called during an EH reset, 294 + before any other action is taken. 295 295 296 - Either 'softreset' (may be NULL) or 'hardreset' (may be NULL) will be 297 - called to perform the low-level EH reset. 296 + * The 'postreset' hook (which may be NULL) is called after the EH reset is 297 + performed. Based on existing conditions, severity of the problem, and hardware 298 + capabilities, 299 + 300 + * Either the 'softreset' operation or the 'hardreset' operation will be called 301 + to perform the low-level EH reset. If both operations are defined, 302 + 'hardreset' is preferred and used. If both are not defined, no low-level reset 303 + is performed and EH assumes that an ATA class device is connected through the 304 + link. 298 305 299 306 :: 300 307
+24 -8
drivers/ata/Kconfig
··· 117 117 118 118 config SATA_MOBILE_LPM_POLICY 119 119 int "Default SATA Link Power Management policy" 120 - range 0 4 120 + range 0 5 121 121 default 3 122 122 depends on SATA_AHCI 123 123 help 124 124 Select the Default SATA Link Power Management (LPM) policy to use 125 125 for chipsets / "South Bridges" supporting low-power modes. Such 126 126 chipsets are ubiquitous across laptops, desktops and servers. 127 + Each policy combines power saving states and features: 128 + - Partial: The Phy logic is powered but is in a reduced power 129 + state. The exit latency from this state is no longer than 130 + 10us). 131 + - Slumber: The Phy logic is powered but is in an even lower power 132 + state. The exit latency from this state is potentially 133 + longer, but no longer than 10ms. 134 + - DevSleep: The Phy logic may be powered down. The exit latency from 135 + this state is no longer than 20 ms, unless otherwise 136 + specified by DETO in the device Identify Device Data log. 137 + - HIPM: Host Initiated Power Management (host automatically 138 + transitions to partial and slumber). 139 + - DIPM: Device Initiated Power Management (device automatically 140 + transitions to partial and slumber). 127 141 128 - The value set has the following meanings: 142 + The possible values for the default SATA link power management 143 + policies are: 129 144 0 => Keep firmware settings 130 - 1 => Maximum performance 131 - 2 => Medium power 132 - 3 => Medium power with Device Initiated PM enabled 133 - 4 => Minimum power 145 + 1 => No power savings (maximum performance) 146 + 2 => HIPM (Partial) 147 + 3 => HIPM (Partial) and DIPM (Partial and Slumber) 148 + 4 => HIPM (Partial and DevSleep) and DIPM (Partial and Slumber) 149 + 5 => HIPM (Slumber and DevSleep) and DIPM (Partial and Slumber) 134 150 135 - Note "Minimum power" is known to cause issues, including disk 136 - corruption, with some disks and should not be used. 151 + Excluding the value 0, higher values represent policies with higher 152 + power savings. 137 153 138 154 config SATA_AHCI_PLATFORM 139 155 tristate "Platform AHCI SATA support"
+19 -6
drivers/ata/ahci.c
··· 110 110 111 111 static struct ata_port_operations ahci_vt8251_ops = { 112 112 .inherits = &ahci_ops, 113 - .hardreset = ahci_vt8251_hardreset, 113 + .reset.hardreset = ahci_vt8251_hardreset, 114 114 }; 115 115 116 116 static struct ata_port_operations ahci_p5wdh_ops = { 117 117 .inherits = &ahci_ops, 118 - .hardreset = ahci_p5wdh_hardreset, 118 + .reset.hardreset = ahci_p5wdh_hardreset, 119 119 }; 120 120 121 121 static struct ata_port_operations ahci_avn_ops = { 122 122 .inherits = &ahci_ops, 123 - .hardreset = ahci_avn_hardreset, 123 + .reset.hardreset = ahci_avn_hardreset, 124 124 }; 125 125 126 126 static const struct ata_port_info ahci_port_info[] = { ··· 674 674 675 675 static int mobile_lpm_policy = -1; 676 676 module_param(mobile_lpm_policy, int, 0644); 677 - MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); 677 + MODULE_PARM_DESC(mobile_lpm_policy, 678 + "Default LPM policy. Despite its name, this parameter applies " 679 + "to all chipsets, including desktop and server chipsets"); 678 680 679 681 static char *ahci_mask_port_map; 680 682 module_param_named(mask_port_map, ahci_mask_port_map, charp, 0444); ··· 1776 1774 * LPM if the port advertises itself as an external port. 1777 1775 */ 1778 1776 if (ap->pflags & ATA_PFLAG_EXTERNAL) { 1779 - ata_port_dbg(ap, "external port, not enabling LPM\n"); 1777 + ap->flags |= ATA_FLAG_NO_LPM; 1778 + ap->target_lpm_policy = ATA_LPM_MAX_POWER; 1780 1779 return; 1780 + } 1781 + 1782 + /* If no Partial or no Slumber, we cannot support DIPM. */ 1783 + if ((ap->host->flags & ATA_HOST_NO_PART) || 1784 + (ap->host->flags & ATA_HOST_NO_SSC)) { 1785 + ata_port_dbg(ap, "Host does not support DIPM\n"); 1786 + ap->flags |= ATA_FLAG_NO_DIPM; 1781 1787 } 1782 1788 1783 1789 /* If no LPM states are supported by the HBA, do not bother with LPM */ 1784 1790 if ((ap->host->flags & ATA_HOST_NO_PART) && 1785 1791 (ap->host->flags & ATA_HOST_NO_SSC) && 1786 1792 (ap->host->flags & ATA_HOST_NO_DEVSLP)) { 1787 - ata_port_dbg(ap, "no LPM states supported, not enabling LPM\n"); 1793 + ata_port_dbg(ap, 1794 + "No LPM states supported, forcing LPM max_power\n"); 1795 + ap->flags |= ATA_FLAG_NO_LPM; 1796 + ap->target_lpm_policy = ATA_LPM_MAX_POWER; 1788 1797 return; 1789 1798 } 1790 1799
+3 -3
drivers/ata/ahci_da850.c
··· 137 137 138 138 static struct ata_port_operations ahci_da850_port_ops = { 139 139 .inherits = &ahci_platform_ops, 140 - .softreset = ahci_da850_softreset, 140 + .reset.softreset = ahci_da850_softreset, 141 141 /* 142 142 * No need to override .pmp_softreset - it's only used for actual 143 143 * PMP-enabled ports. 144 144 */ 145 - .hardreset = ahci_da850_hardreset, 146 - .pmp_hardreset = ahci_da850_hardreset, 145 + .reset.hardreset = ahci_da850_hardreset, 146 + .pmp_reset.hardreset = ahci_da850_hardreset, 147 147 }; 148 148 149 149 static const struct ata_port_info ahci_da850_port_info = {
+1 -1
drivers/ata/ahci_dm816.c
··· 124 124 125 125 static struct ata_port_operations ahci_dm816_port_ops = { 126 126 .inherits = &ahci_platform_ops, 127 - .softreset = ahci_dm816_softreset, 127 + .reset.softreset = ahci_dm816_softreset, 128 128 }; 129 129 130 130 static const struct ata_port_info ahci_dm816_port_info = {
+7 -6
drivers/ata/ahci_imx.c
··· 642 642 int ret; 643 643 644 644 if (imxpriv->type == AHCI_IMX53) 645 - ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline); 645 + ret = ahci_pmp_retry_srst_ops.reset.softreset(link, class, 646 + deadline); 646 647 else 647 - ret = ahci_ops.softreset(link, class, deadline); 648 + ret = ahci_ops.reset.softreset(link, class, deadline); 648 649 649 650 return ret; 650 651 } 651 652 652 653 static struct ata_port_operations ahci_imx_ops = { 653 - .inherits = &ahci_ops, 654 - .host_stop = ahci_imx_host_stop, 655 - .error_handler = ahci_imx_error_handler, 656 - .softreset = ahci_imx_softreset, 654 + .inherits = &ahci_ops, 655 + .host_stop = ahci_imx_host_stop, 656 + .error_handler = ahci_imx_error_handler, 657 + .reset.softreset = ahci_imx_softreset, 657 658 }; 658 659 659 660 static const struct ata_port_info ahci_imx_port_info = {
+2 -2
drivers/ata/ahci_qoriq.c
··· 146 146 } 147 147 148 148 static struct ata_port_operations ahci_qoriq_ops = { 149 - .inherits = &ahci_ops, 150 - .hardreset = ahci_qoriq_hardreset, 149 + .inherits = &ahci_ops, 150 + .reset.hardreset = ahci_qoriq_hardreset, 151 151 }; 152 152 153 153 static const struct ata_port_info ahci_qoriq_port_info = {
+4 -4
drivers/ata/ahci_xgene.c
··· 613 613 static struct ata_port_operations xgene_ahci_v1_ops = { 614 614 .inherits = &ahci_ops, 615 615 .host_stop = xgene_ahci_host_stop, 616 - .hardreset = xgene_ahci_hardreset, 616 + .reset.hardreset = xgene_ahci_hardreset, 617 + .reset.softreset = xgene_ahci_softreset, 618 + .pmp_reset.softreset = xgene_ahci_pmp_softreset, 617 619 .read_id = xgene_ahci_read_id, 618 620 .qc_issue = xgene_ahci_qc_issue, 619 - .softreset = xgene_ahci_softreset, 620 - .pmp_softreset = xgene_ahci_pmp_softreset 621 621 }; 622 622 623 623 static const struct ata_port_info xgene_ahci_v1_port_info = { ··· 630 630 static struct ata_port_operations xgene_ahci_v2_ops = { 631 631 .inherits = &ahci_ops, 632 632 .host_stop = xgene_ahci_host_stop, 633 - .hardreset = xgene_ahci_hardreset, 633 + .reset.hardreset = xgene_ahci_hardreset, 634 634 .read_id = xgene_ahci_read_id, 635 635 }; 636 636
+2 -2
drivers/ata/ata_piix.c
··· 1074 1074 .cable_detect = ata_cable_40wire, 1075 1075 .set_piomode = piix_set_piomode, 1076 1076 .set_dmamode = piix_set_dmamode, 1077 - .prereset = piix_pata_prereset, 1077 + .reset.prereset = piix_pata_prereset, 1078 1078 }; 1079 1079 1080 1080 static struct ata_port_operations piix_vmw_ops = { ··· 1102 1102 1103 1103 static struct ata_port_operations piix_sidpr_sata_ops = { 1104 1104 .inherits = &piix_sata_ops, 1105 - .hardreset = sata_std_hardreset, 1105 + .reset.hardreset = sata_std_hardreset, 1106 1106 .scr_read = piix_sidpr_scr_read, 1107 1107 .scr_write = piix_sidpr_scr_write, 1108 1108 .set_lpm = piix_sidpr_set_lpm,
+5 -5
drivers/ata/libahci.c
··· 162 162 163 163 .freeze = ahci_freeze, 164 164 .thaw = ahci_thaw, 165 - .softreset = ahci_softreset, 166 - .hardreset = ahci_hardreset, 167 - .postreset = ahci_postreset, 168 - .pmp_softreset = ahci_softreset, 165 + .reset.softreset = ahci_softreset, 166 + .reset.hardreset = ahci_hardreset, 167 + .reset.postreset = ahci_postreset, 168 + .pmp_reset.softreset = ahci_softreset, 169 169 .error_handler = ahci_error_handler, 170 170 .post_internal_cmd = ahci_post_internal_cmd, 171 171 .dev_config = ahci_dev_config, ··· 192 192 193 193 struct ata_port_operations ahci_pmp_retry_srst_ops = { 194 194 .inherits = &ahci_ops, 195 - .softreset = ahci_pmp_retry_softreset, 195 + .reset.softreset = ahci_pmp_retry_softreset, 196 196 }; 197 197 EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops); 198 198
+99 -38
drivers/ata/libata-core.c
··· 65 65 #include "libata-transport.h" 66 66 67 67 const struct ata_port_operations ata_base_port_ops = { 68 - .prereset = ata_std_prereset, 69 - .postreset = ata_std_postreset, 68 + .reset.prereset = ata_std_prereset, 69 + .reset.postreset = ata_std_postreset, 70 70 .error_handler = ata_std_error_handler, 71 71 .sched_eh = ata_std_sched_eh, 72 72 .end_eh = ata_std_end_eh, ··· 2154 2154 return err_mask; 2155 2155 } 2156 2156 2157 + static inline void ata_clear_log_directory(struct ata_device *dev) 2158 + { 2159 + memset(dev->gp_log_dir, 0, ATA_SECT_SIZE); 2160 + } 2161 + 2162 + static int ata_read_log_directory(struct ata_device *dev) 2163 + { 2164 + u16 version; 2165 + 2166 + /* If the log page is already cached, do nothing. */ 2167 + version = get_unaligned_le16(&dev->gp_log_dir[0]); 2168 + if (version == 0x0001) 2169 + return 0; 2170 + 2171 + if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, dev->gp_log_dir, 1)) { 2172 + ata_clear_log_directory(dev); 2173 + return -EIO; 2174 + } 2175 + 2176 + version = get_unaligned_le16(&dev->gp_log_dir[0]); 2177 + if (version != 0x0001) { 2178 + ata_dev_err(dev, "Invalid log directory version 0x%04x\n", 2179 + version); 2180 + ata_clear_log_directory(dev); 2181 + dev->quirks |= ATA_QUIRK_NO_LOG_DIR; 2182 + return -EINVAL; 2183 + } 2184 + 2185 + return 0; 2186 + } 2187 + 2157 2188 static int ata_log_supported(struct ata_device *dev, u8 log) 2158 2189 { 2159 2190 if (dev->quirks & ATA_QUIRK_NO_LOG_DIR) 2160 2191 return 0; 2161 2192 2162 - if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, dev->sector_buf, 1)) 2193 + if (ata_read_log_directory(dev)) 2163 2194 return 0; 2164 - return get_unaligned_le16(&dev->sector_buf[log * 2]); 2195 + 2196 + return get_unaligned_le16(&dev->gp_log_dir[log * 2]); 2165 2197 } 2166 2198 2167 2199 static bool ata_identify_page_supported(struct ata_device *dev, u8 page) ··· 2453 2421 dev->zac_zones_optimal_nonseq = U32_MAX; 2454 2422 dev->zac_zones_max_open = U32_MAX; 2455 2423 2456 - /* 2457 - * Always set the 'ZAC' flag for Host-managed devices. 2458 - */ 2459 - if (dev->class == ATA_DEV_ZAC) 2460 - dev->flags |= ATA_DFLAG_ZAC; 2461 - else if (ata_id_zoned_cap(dev->id) == 0x01) 2462 - /* 2463 - * Check for host-aware devices. 2464 - */ 2465 - dev->flags |= ATA_DFLAG_ZAC; 2466 - 2467 - if (!(dev->flags & ATA_DFLAG_ZAC)) 2424 + if (!ata_dev_is_zac(dev)) 2468 2425 return; 2469 2426 2470 2427 if (!ata_identify_page_supported(dev, ATA_LOG_ZONED_INFORMATION)) { ··· 2516 2495 dev->flags |= ATA_DFLAG_TRUSTED; 2517 2496 } 2518 2497 2519 - void ata_dev_cleanup_cdl_resources(struct ata_device *dev) 2498 + static void ata_dev_cleanup_cdl_resources(struct ata_device *dev) 2520 2499 { 2521 2500 kfree(dev->cdl); 2522 2501 dev->cdl = NULL; ··· 2822 2801 kfree(buf); 2823 2802 } 2824 2803 2804 + /* 2805 + * Configure features related to link power management. 2806 + */ 2807 + static void ata_dev_config_lpm(struct ata_device *dev) 2808 + { 2809 + struct ata_port *ap = dev->link->ap; 2810 + unsigned int err_mask; 2811 + 2812 + if (ap->flags & ATA_FLAG_NO_LPM) { 2813 + /* 2814 + * When the port does not support LPM, we cannot support it on 2815 + * the device either. 2816 + */ 2817 + dev->quirks |= ATA_QUIRK_NOLPM; 2818 + } else { 2819 + /* 2820 + * Some WD SATA-1 drives have issues with LPM, turn on NOLPM for 2821 + * them. 2822 + */ 2823 + if ((dev->quirks & ATA_QUIRK_WD_BROKEN_LPM) && 2824 + (dev->id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2) 2825 + dev->quirks |= ATA_QUIRK_NOLPM; 2826 + 2827 + /* ATI specific quirk */ 2828 + if ((dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI) && 2829 + ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI)) 2830 + dev->quirks |= ATA_QUIRK_NOLPM; 2831 + } 2832 + 2833 + if (dev->quirks & ATA_QUIRK_NOLPM && 2834 + ap->target_lpm_policy != ATA_LPM_MAX_POWER) { 2835 + ata_dev_warn(dev, "LPM support broken, forcing max_power\n"); 2836 + ap->target_lpm_policy = ATA_LPM_MAX_POWER; 2837 + } 2838 + 2839 + /* 2840 + * Device Initiated Power Management (DIPM) is normally disabled by 2841 + * default on a device. However, DIPM may have been enabled and that 2842 + * setting kept even after COMRESET because of the Software Settings 2843 + * Preservation feature. So if the port does not support DIPM and the 2844 + * device does, disable DIPM on the device. 2845 + */ 2846 + if (ap->flags & ATA_FLAG_NO_DIPM && ata_id_has_dipm(dev->id)) { 2847 + err_mask = ata_dev_set_feature(dev, 2848 + SETFEATURES_SATA_DISABLE, SATA_DIPM); 2849 + if (err_mask && err_mask != AC_ERR_DEV) 2850 + ata_dev_err(dev, "Disable DIPM failed, Emask 0x%x\n", 2851 + err_mask); 2852 + } 2853 + } 2854 + 2825 2855 static void ata_dev_print_features(struct ata_device *dev) 2826 2856 { 2827 2857 if (!(dev->flags & ATA_DFLAG_FEATURES_MASK)) 2828 2858 return; 2829 2859 2830 2860 ata_dev_info(dev, 2831 - "Features:%s%s%s%s%s%s%s%s\n", 2861 + "Features:%s%s%s%s%s%s%s%s%s%s\n", 2832 2862 dev->flags & ATA_DFLAG_FUA ? " FUA" : "", 2833 2863 dev->flags & ATA_DFLAG_TRUSTED ? " Trust" : "", 2834 2864 dev->flags & ATA_DFLAG_DA ? " Dev-Attention" : "", 2835 2865 dev->flags & ATA_DFLAG_DEVSLP ? " Dev-Sleep" : "", 2866 + ata_id_has_hipm(dev->id) ? " HIPM" : "", 2867 + ata_id_has_dipm(dev->id) ? " DIPM" : "", 2836 2868 dev->flags & ATA_DFLAG_NCQ_SEND_RECV ? " NCQ-sndrcv" : "", 2837 2869 dev->flags & ATA_DFLAG_NCQ_PRIO ? " NCQ-prio" : "", 2838 2870 dev->flags & ATA_DFLAG_CDL ? " CDL" : "", ··· 2922 2848 return 0; 2923 2849 } 2924 2850 2851 + /* Clear the general purpose log directory cache. */ 2852 + ata_clear_log_directory(dev); 2853 + 2925 2854 /* Set quirks */ 2926 2855 dev->quirks |= ata_dev_quirks(dev); 2927 2856 ata_force_quirks(dev); ··· 2947 2870 rc = ata_do_link_spd_quirk(dev); 2948 2871 if (rc) 2949 2872 return rc; 2950 - 2951 - /* some WD SATA-1 drives have issues with LPM, turn on NOLPM for them */ 2952 - if ((dev->quirks & ATA_QUIRK_WD_BROKEN_LPM) && 2953 - (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2) 2954 - dev->quirks |= ATA_QUIRK_NOLPM; 2955 - 2956 - if (dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI && 2957 - ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI)) 2958 - dev->quirks |= ATA_QUIRK_NOLPM; 2959 - 2960 - if (ap->flags & ATA_FLAG_NO_LPM) 2961 - dev->quirks |= ATA_QUIRK_NOLPM; 2962 - 2963 - if (dev->quirks & ATA_QUIRK_NOLPM) { 2964 - ata_dev_warn(dev, "LPM support broken, forcing max_power\n"); 2965 - dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER; 2966 - } 2967 2873 2968 2874 /* let ACPI work its magic */ 2969 2875 rc = ata_acpi_on_devcfg(dev); ··· 3034 2974 ata_dev_config_chs(dev); 3035 2975 } 3036 2976 2977 + ata_dev_config_lpm(dev); 3037 2978 ata_dev_config_fua(dev); 3038 2979 ata_dev_config_devslp(dev); 3039 2980 ata_dev_config_sense_reporting(dev); ··· 3510 3449 } 3511 3450 3512 3451 /** 3513 - * ata_do_set_mode - Program timings and issue SET FEATURES - XFER 3452 + * ata_set_mode - Program timings and issue SET FEATURES - XFER 3514 3453 * @link: link on which timings will be programmed 3515 3454 * @r_failed_dev: out parameter for failed device 3516 3455 * ··· 3526 3465 * 0 on success, negative errno otherwise 3527 3466 */ 3528 3467 3529 - int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) 3468 + int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) 3530 3469 { 3531 3470 struct ata_port *ap = link->ap; 3532 3471 struct ata_device *dev; ··· 3607 3546 *r_failed_dev = dev; 3608 3547 return rc; 3609 3548 } 3610 - EXPORT_SYMBOL_GPL(ata_do_set_mode); 3549 + EXPORT_SYMBOL_GPL(ata_set_mode); 3611 3550 3612 3551 /** 3613 3552 * ata_wait_ready - wait for link to become ready
+220 -213
drivers/ata/libata-eh.c
··· 153 153 #undef CMDS 154 154 155 155 static void __ata_port_freeze(struct ata_port *ap); 156 - static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, 157 - struct ata_device **r_failed_dev); 158 156 #ifdef CONFIG_PM 159 157 static void ata_eh_handle_port_suspend(struct ata_port *ap); 160 158 static void ata_eh_handle_port_resume(struct ata_port *ap); ··· 823 825 retry: 824 826 spin_lock_irqsave(ap->lock, flags); 825 827 826 - while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { 828 + while (ata_port_eh_scheduled(ap)) { 827 829 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); 828 830 spin_unlock_irqrestore(ap->lock, flags); 829 831 schedule(); ··· 907 909 * LOCKING: 908 910 * spin_lock_irqsave(host lock) 909 911 */ 910 - static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) 912 + static void ata_eh_set_pending(struct ata_port *ap, bool fastdrain) 911 913 { 912 914 unsigned int cnt; 913 915 ··· 947 949 struct ata_port *ap = qc->ap; 948 950 949 951 qc->flags |= ATA_QCFLAG_EH; 950 - ata_eh_set_pending(ap, 1); 952 + ata_eh_set_pending(ap, true); 951 953 952 954 /* The following will fail if timeout has already expired. 953 955 * ata_scsi_error() takes care of such scmds on EH entry. ··· 969 971 if (ap->pflags & ATA_PFLAG_INITIALIZING) 970 972 return; 971 973 972 - ata_eh_set_pending(ap, 1); 974 + ata_eh_set_pending(ap, true); 973 975 scsi_schedule_eh(ap->scsi_host); 974 976 975 977 trace_ata_std_sched_eh(ap); ··· 1020 1022 int tag, nr_aborted = 0; 1021 1023 1022 1024 /* we're gonna abort all commands, no need for fast drain */ 1023 - ata_eh_set_pending(ap, 0); 1025 + ata_eh_set_pending(ap, false); 1024 1026 1025 1027 /* include internal tag in iteration */ 1026 1028 ata_qc_for_each_with_internal(ap, qc, tag) { ··· 2071 2073 ata_eh_done(link, dev, ATA_EH_GET_SUCCESS_SENSE); 2072 2074 } 2073 2075 2076 + /* 2077 + * Check if a link is established. This is a relaxed version of 2078 + * ata_phys_link_online() which accounts for the fact that this is potentially 2079 + * called after changing the link power management policy, which may not be 2080 + * reflected immediately in the SSTAUS register (e.g., we may still be seeing 2081 + * the PHY in partial, slumber or devsleep Partial power management state. 2082 + * So check that: 2083 + * - A device is still present, that is, DET is 1h (Device presence detected 2084 + * but Phy communication not established) or 3h (Device presence detected and 2085 + * Phy communication established) 2086 + * - Communication is established, that is, IPM is not 0h, indicating that PHY 2087 + * is online or in a low power state. 2088 + */ 2089 + static bool ata_eh_link_established(struct ata_link *link) 2090 + { 2091 + u32 sstatus; 2092 + u8 det, ipm; 2093 + 2094 + if (sata_scr_read(link, SCR_STATUS, &sstatus)) 2095 + return false; 2096 + 2097 + det = sstatus & 0x0f; 2098 + ipm = (sstatus >> 8) & 0x0f; 2099 + 2100 + return (det & 0x01) && ipm; 2101 + } 2102 + 2103 + /** 2104 + * ata_eh_link_set_lpm - configure SATA interface power management 2105 + * @link: link to configure 2106 + * @policy: the link power management policy 2107 + * @r_failed_dev: out parameter for failed device 2108 + * 2109 + * Enable SATA Interface power management. This will enable 2110 + * Device Interface Power Management (DIPM) for min_power and 2111 + * medium_power_with_dipm policies, and then call driver specific 2112 + * callbacks for enabling Host Initiated Power management. 2113 + * 2114 + * LOCKING: 2115 + * EH context. 2116 + * 2117 + * RETURNS: 2118 + * 0 on success, -errno on failure. 2119 + */ 2120 + static int ata_eh_link_set_lpm(struct ata_link *link, 2121 + enum ata_lpm_policy policy, 2122 + struct ata_device **r_failed_dev) 2123 + { 2124 + struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; 2125 + struct ata_eh_context *ehc = &link->eh_context; 2126 + struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; 2127 + enum ata_lpm_policy old_policy = link->lpm_policy; 2128 + bool host_has_dipm = !(link->ap->flags & ATA_FLAG_NO_DIPM); 2129 + unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; 2130 + unsigned int err_mask; 2131 + int rc; 2132 + 2133 + /* if the link or host doesn't do LPM, noop */ 2134 + if (!IS_ENABLED(CONFIG_SATA_HOST) || 2135 + (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) 2136 + return 0; 2137 + 2138 + /* 2139 + * This function currently assumes that it will never be supplied policy 2140 + * ATA_LPM_UNKNOWN. 2141 + */ 2142 + if (WARN_ON_ONCE(policy == ATA_LPM_UNKNOWN)) 2143 + return 0; 2144 + 2145 + ata_link_dbg(link, "Set LPM policy: %d -> %d\n", old_policy, policy); 2146 + 2147 + /* 2148 + * DIPM is enabled only for ATA_LPM_MIN_POWER, 2149 + * ATA_LPM_MIN_POWER_WITH_PARTIAL, and ATA_LPM_MED_POWER_WITH_DIPM, as 2150 + * some devices misbehave when the host NACKs transition to SLUMBER. 2151 + */ 2152 + ata_for_each_dev(dev, link, ENABLED) { 2153 + bool dev_has_hipm = ata_id_has_hipm(dev->id); 2154 + bool dev_has_dipm = ata_id_has_dipm(dev->id); 2155 + 2156 + /* find the first enabled and LPM enabled devices */ 2157 + if (!link_dev) 2158 + link_dev = dev; 2159 + 2160 + if (!lpm_dev && 2161 + (dev_has_hipm || (dev_has_dipm && host_has_dipm))) 2162 + lpm_dev = dev; 2163 + 2164 + hints &= ~ATA_LPM_EMPTY; 2165 + if (!dev_has_hipm) 2166 + hints &= ~ATA_LPM_HIPM; 2167 + 2168 + /* disable DIPM before changing link config */ 2169 + if (dev_has_dipm) { 2170 + err_mask = ata_dev_set_feature(dev, 2171 + SETFEATURES_SATA_DISABLE, SATA_DIPM); 2172 + if (err_mask && err_mask != AC_ERR_DEV) { 2173 + ata_dev_warn(dev, 2174 + "failed to disable DIPM, Emask 0x%x\n", 2175 + err_mask); 2176 + rc = -EIO; 2177 + goto fail; 2178 + } 2179 + } 2180 + } 2181 + 2182 + if (ap) { 2183 + rc = ap->ops->set_lpm(link, policy, hints); 2184 + if (!rc && ap->slave_link) 2185 + rc = ap->ops->set_lpm(ap->slave_link, policy, hints); 2186 + } else 2187 + rc = sata_pmp_set_lpm(link, policy, hints); 2188 + 2189 + /* 2190 + * Attribute link config failure to the first (LPM) enabled 2191 + * device on the link. 2192 + */ 2193 + if (rc) { 2194 + if (rc == -EOPNOTSUPP) { 2195 + link->flags |= ATA_LFLAG_NO_LPM; 2196 + return 0; 2197 + } 2198 + dev = lpm_dev ? lpm_dev : link_dev; 2199 + goto fail; 2200 + } 2201 + 2202 + /* 2203 + * Low level driver acked the transition. Issue DIPM command 2204 + * with the new policy set. 2205 + */ 2206 + link->lpm_policy = policy; 2207 + if (ap && ap->slave_link) 2208 + ap->slave_link->lpm_policy = policy; 2209 + 2210 + /* 2211 + * Host config updated, enable DIPM if transitioning to 2212 + * ATA_LPM_MIN_POWER, ATA_LPM_MIN_POWER_WITH_PARTIAL, or 2213 + * ATA_LPM_MED_POWER_WITH_DIPM. 2214 + */ 2215 + ata_for_each_dev(dev, link, ENABLED) { 2216 + bool dev_has_dipm = ata_id_has_dipm(dev->id); 2217 + 2218 + if (policy >= ATA_LPM_MED_POWER_WITH_DIPM && host_has_dipm && 2219 + dev_has_dipm) { 2220 + err_mask = ata_dev_set_feature(dev, 2221 + SETFEATURES_SATA_ENABLE, SATA_DIPM); 2222 + if (err_mask && err_mask != AC_ERR_DEV) { 2223 + ata_dev_warn(dev, 2224 + "failed to enable DIPM, Emask 0x%x\n", 2225 + err_mask); 2226 + rc = -EIO; 2227 + goto fail; 2228 + } 2229 + } 2230 + } 2231 + 2232 + link->last_lpm_change = jiffies; 2233 + link->flags |= ATA_LFLAG_CHANGED; 2234 + 2235 + return 0; 2236 + 2237 + fail: 2238 + /* restore the old policy */ 2239 + link->lpm_policy = old_policy; 2240 + if (ap && ap->slave_link) 2241 + ap->slave_link->lpm_policy = old_policy; 2242 + 2243 + /* if no device or only one more chance is left, disable LPM */ 2244 + if (!dev || ehc->tries[dev->devno] <= 2) { 2245 + ata_link_warn(link, "disabling LPM on the link\n"); 2246 + link->flags |= ATA_LFLAG_NO_LPM; 2247 + } 2248 + if (r_failed_dev) 2249 + *r_failed_dev = dev; 2250 + return rc; 2251 + } 2252 + 2074 2253 /** 2075 2254 * ata_eh_link_autopsy - analyze error and determine recovery action 2076 2255 * @link: host link to perform autopsy on ··· 2781 2606 return reset(link, classes, deadline); 2782 2607 } 2783 2608 2784 - static int ata_eh_followup_srst_needed(struct ata_link *link, int rc) 2609 + static bool ata_eh_followup_srst_needed(struct ata_link *link, int rc) 2785 2610 { 2786 2611 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) 2787 - return 0; 2612 + return false; 2788 2613 if (rc == -EAGAIN) 2789 - return 1; 2614 + return true; 2790 2615 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) 2791 - return 1; 2792 - return 0; 2616 + return true; 2617 + return false; 2793 2618 } 2794 2619 2795 2620 int ata_eh_reset(struct ata_link *link, int classify, 2796 - ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 2797 - ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) 2621 + struct ata_reset_operations *reset_ops) 2798 2622 { 2799 2623 struct ata_port *ap = link->ap; 2800 2624 struct ata_link *slave = ap->slave_link; 2801 2625 struct ata_eh_context *ehc = &link->eh_context; 2802 2626 struct ata_eh_context *sehc = slave ? &slave->eh_context : NULL; 2627 + ata_reset_fn_t hardreset = reset_ops->hardreset; 2628 + ata_reset_fn_t softreset = reset_ops->softreset; 2629 + ata_prereset_fn_t prereset = reset_ops->prereset; 2630 + ata_postreset_fn_t postreset = reset_ops->postreset; 2803 2631 unsigned int *classes = ehc->classes; 2804 2632 unsigned int lflags = link->flags; 2805 2633 int verbose = !(ehc->i.flags & ATA_EHI_QUIET); ··· 3301 3123 * to ap->target_lpm_policy after revalidation is done. 3302 3124 */ 3303 3125 if (link->lpm_policy > ATA_LPM_MAX_POWER) { 3304 - rc = ata_eh_set_lpm(link, ATA_LPM_MAX_POWER, 3305 - r_failed_dev); 3126 + rc = ata_eh_link_set_lpm(link, ATA_LPM_MAX_POWER, 3127 + r_failed_dev); 3306 3128 if (rc) 3307 3129 goto err; 3308 3130 } 3309 3131 3310 - if (ata_phys_link_offline(ata_dev_phys_link(dev))) { 3132 + if (!ata_eh_link_established(ata_dev_phys_link(dev))) { 3311 3133 rc = -EIO; 3312 3134 goto err; 3313 3135 } ··· 3411 3233 } 3412 3234 3413 3235 /** 3414 - * ata_set_mode - Program timings and issue SET FEATURES - XFER 3236 + * ata_eh_set_mode - Program timings and issue SET FEATURES - XFER 3415 3237 * @link: link on which timings will be programmed 3416 3238 * @r_failed_dev: out parameter for failed device 3417 3239 * 3418 3240 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If 3419 - * ata_set_mode() fails, pointer to the failing device is 3241 + * ata_eh_set_mode() fails, pointer to the failing device is 3420 3242 * returned in @r_failed_dev. 3421 3243 * 3422 3244 * LOCKING: ··· 3425 3247 * RETURNS: 3426 3248 * 0 on success, negative errno otherwise 3427 3249 */ 3428 - int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) 3250 + static int ata_eh_set_mode(struct ata_link *link, 3251 + struct ata_device **r_failed_dev) 3429 3252 { 3430 3253 struct ata_port *ap = link->ap; 3431 3254 struct ata_device *dev; ··· 3447 3268 if (ap->ops->set_mode) 3448 3269 rc = ap->ops->set_mode(link, r_failed_dev); 3449 3270 else 3450 - rc = ata_do_set_mode(link, r_failed_dev); 3271 + rc = ata_set_mode(link, r_failed_dev); 3451 3272 3452 3273 /* if transfer mode has changed, set DUBIOUS_XFER on device */ 3453 3274 ata_for_each_dev(dev, link, ENABLED) { ··· 3584 3405 rc = 0; 3585 3406 } 3586 3407 } 3587 - return rc; 3588 - } 3589 - 3590 - /** 3591 - * ata_eh_set_lpm - configure SATA interface power management 3592 - * @link: link to configure power management 3593 - * @policy: the link power management policy 3594 - * @r_failed_dev: out parameter for failed device 3595 - * 3596 - * Enable SATA Interface power management. This will enable 3597 - * Device Interface Power Management (DIPM) for min_power and 3598 - * medium_power_with_dipm policies, and then call driver specific 3599 - * callbacks for enabling Host Initiated Power management. 3600 - * 3601 - * LOCKING: 3602 - * EH context. 3603 - * 3604 - * RETURNS: 3605 - * 0 on success, -errno on failure. 3606 - */ 3607 - static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, 3608 - struct ata_device **r_failed_dev) 3609 - { 3610 - struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; 3611 - struct ata_eh_context *ehc = &link->eh_context; 3612 - struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; 3613 - enum ata_lpm_policy old_policy = link->lpm_policy; 3614 - bool host_has_dipm = !(link->ap->flags & ATA_FLAG_NO_DIPM); 3615 - unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; 3616 - unsigned int err_mask; 3617 - int rc; 3618 - 3619 - /* if the link or host doesn't do LPM, noop */ 3620 - if (!IS_ENABLED(CONFIG_SATA_HOST) || 3621 - (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) 3622 - return 0; 3623 - 3624 - /* 3625 - * This function currently assumes that it will never be supplied policy 3626 - * ATA_LPM_UNKNOWN. 3627 - */ 3628 - if (WARN_ON_ONCE(policy == ATA_LPM_UNKNOWN)) 3629 - return 0; 3630 - 3631 - /* 3632 - * DIPM is enabled only for ATA_LPM_MIN_POWER, 3633 - * ATA_LPM_MIN_POWER_WITH_PARTIAL, and ATA_LPM_MED_POWER_WITH_DIPM, as 3634 - * some devices misbehave when the host NACKs transition to SLUMBER. 3635 - */ 3636 - ata_for_each_dev(dev, link, ENABLED) { 3637 - bool dev_has_hipm = ata_id_has_hipm(dev->id); 3638 - bool dev_has_dipm = ata_id_has_dipm(dev->id); 3639 - 3640 - /* find the first enabled and LPM enabled devices */ 3641 - if (!link_dev) 3642 - link_dev = dev; 3643 - 3644 - if (!lpm_dev && 3645 - (dev_has_hipm || (dev_has_dipm && host_has_dipm))) 3646 - lpm_dev = dev; 3647 - 3648 - hints &= ~ATA_LPM_EMPTY; 3649 - if (!dev_has_hipm) 3650 - hints &= ~ATA_LPM_HIPM; 3651 - 3652 - /* disable DIPM before changing link config */ 3653 - if (dev_has_dipm) { 3654 - err_mask = ata_dev_set_feature(dev, 3655 - SETFEATURES_SATA_DISABLE, SATA_DIPM); 3656 - if (err_mask && err_mask != AC_ERR_DEV) { 3657 - ata_dev_warn(dev, 3658 - "failed to disable DIPM, Emask 0x%x\n", 3659 - err_mask); 3660 - rc = -EIO; 3661 - goto fail; 3662 - } 3663 - } 3664 - } 3665 - 3666 - if (ap) { 3667 - rc = ap->ops->set_lpm(link, policy, hints); 3668 - if (!rc && ap->slave_link) 3669 - rc = ap->ops->set_lpm(ap->slave_link, policy, hints); 3670 - } else 3671 - rc = sata_pmp_set_lpm(link, policy, hints); 3672 - 3673 - /* 3674 - * Attribute link config failure to the first (LPM) enabled 3675 - * device on the link. 3676 - */ 3677 - if (rc) { 3678 - if (rc == -EOPNOTSUPP) { 3679 - link->flags |= ATA_LFLAG_NO_LPM; 3680 - return 0; 3681 - } 3682 - dev = lpm_dev ? lpm_dev : link_dev; 3683 - goto fail; 3684 - } 3685 - 3686 - /* 3687 - * Low level driver acked the transition. Issue DIPM command 3688 - * with the new policy set. 3689 - */ 3690 - link->lpm_policy = policy; 3691 - if (ap && ap->slave_link) 3692 - ap->slave_link->lpm_policy = policy; 3693 - 3694 - /* 3695 - * Host config updated, enable DIPM if transitioning to 3696 - * ATA_LPM_MIN_POWER, ATA_LPM_MIN_POWER_WITH_PARTIAL, or 3697 - * ATA_LPM_MED_POWER_WITH_DIPM. 3698 - */ 3699 - ata_for_each_dev(dev, link, ENABLED) { 3700 - bool dev_has_dipm = ata_id_has_dipm(dev->id); 3701 - 3702 - if (policy >= ATA_LPM_MED_POWER_WITH_DIPM && host_has_dipm && 3703 - dev_has_dipm) { 3704 - err_mask = ata_dev_set_feature(dev, 3705 - SETFEATURES_SATA_ENABLE, SATA_DIPM); 3706 - if (err_mask && err_mask != AC_ERR_DEV) { 3707 - ata_dev_warn(dev, 3708 - "failed to enable DIPM, Emask 0x%x\n", 3709 - err_mask); 3710 - rc = -EIO; 3711 - goto fail; 3712 - } 3713 - } 3714 - } 3715 - 3716 - link->last_lpm_change = jiffies; 3717 - link->flags |= ATA_LFLAG_CHANGED; 3718 - 3719 - return 0; 3720 - 3721 - fail: 3722 - /* restore the old policy */ 3723 - link->lpm_policy = old_policy; 3724 - if (ap && ap->slave_link) 3725 - ap->slave_link->lpm_policy = old_policy; 3726 - 3727 - /* if no device or only one more chance is left, disable LPM */ 3728 - if (!dev || ehc->tries[dev->devno] <= 2) { 3729 - ata_link_warn(link, "disabling LPM on the link\n"); 3730 - link->flags |= ATA_LFLAG_NO_LPM; 3731 - } 3732 - if (r_failed_dev) 3733 - *r_failed_dev = dev; 3734 3408 return rc; 3735 3409 } 3736 3410 ··· 3759 3727 /** 3760 3728 * ata_eh_recover - recover host port after error 3761 3729 * @ap: host port to recover 3762 - * @prereset: prereset method (can be NULL) 3763 - * @softreset: softreset method (can be NULL) 3764 - * @hardreset: hardreset method (can be NULL) 3765 - * @postreset: postreset method (can be NULL) 3730 + * @reset_ops: The set of reset operations to use 3766 3731 * @r_failed_link: out parameter for failed link 3767 3732 * 3768 3733 * This is the alpha and omega, eum and yang, heart and soul of ··· 3775 3746 * RETURNS: 3776 3747 * 0 on success, -errno on failure. 3777 3748 */ 3778 - int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, 3779 - ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 3780 - ata_postreset_fn_t postreset, 3749 + int ata_eh_recover(struct ata_port *ap, struct ata_reset_operations *reset_ops, 3781 3750 struct ata_link **r_failed_link) 3782 3751 { 3783 3752 struct ata_link *link; ··· 3843 3816 if (!(ehc->i.action & ATA_EH_RESET)) 3844 3817 continue; 3845 3818 3846 - rc = ata_eh_reset(link, ata_link_nr_vacant(link), 3847 - prereset, softreset, hardreset, postreset); 3819 + rc = ata_eh_reset(link, ata_link_nr_vacant(link), reset_ops); 3848 3820 if (rc) { 3849 3821 ata_link_err(link, "reset failed, giving up\n"); 3850 3822 goto out; ··· 3924 3898 3925 3899 /* configure transfer mode if necessary */ 3926 3900 if (ehc->i.flags & ATA_EHI_SETMODE) { 3927 - rc = ata_set_mode(link, &dev); 3901 + rc = ata_eh_set_mode(link, &dev); 3928 3902 if (rc) 3929 3903 goto rest_fail; 3930 3904 ehc->i.flags &= ~ATA_EHI_SETMODE; ··· 3969 3943 config_lpm: 3970 3944 /* configure link power saving */ 3971 3945 if (link->lpm_policy != ap->target_lpm_policy) { 3972 - rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); 3946 + rc = ata_eh_link_set_lpm(link, ap->target_lpm_policy, 3947 + &dev); 3973 3948 if (rc) 3974 3949 goto rest_fail; 3975 3950 } ··· 4064 4037 } 4065 4038 4066 4039 /** 4067 - * ata_do_eh - do standard error handling 4040 + * ata_std_error_handler - standard error handler 4068 4041 * @ap: host port to handle error for 4069 - * 4070 - * @prereset: prereset method (can be NULL) 4071 - * @softreset: softreset method (can be NULL) 4072 - * @hardreset: hardreset method (can be NULL) 4073 - * @postreset: postreset method (can be NULL) 4074 4042 * 4075 4043 * Perform standard error handling sequence. 4076 4044 * 4077 4045 * LOCKING: 4078 4046 * Kernel thread context (may sleep). 4079 4047 */ 4080 - void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 4081 - ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 4082 - ata_postreset_fn_t postreset) 4048 + void ata_std_error_handler(struct ata_port *ap) 4083 4049 { 4084 - struct ata_device *dev; 4050 + struct ata_reset_operations *reset_ops = &ap->ops->reset; 4051 + struct ata_link *link = &ap->link; 4085 4052 int rc; 4053 + 4054 + /* Ignore built-in hardresets if SCR access is not available */ 4055 + if ((reset_ops->hardreset == sata_std_hardreset || 4056 + reset_ops->hardreset == sata_sff_hardreset) && 4057 + !sata_scr_valid(link)) 4058 + link->flags |= ATA_LFLAG_NO_HRST; 4086 4059 4087 4060 ata_eh_autopsy(ap); 4088 4061 ata_eh_report(ap); 4089 4062 4090 - rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, 4091 - NULL); 4063 + rc = ata_eh_recover(ap, reset_ops, NULL); 4092 4064 if (rc) { 4093 - ata_for_each_dev(dev, &ap->link, ALL) 4065 + struct ata_device *dev; 4066 + 4067 + ata_for_each_dev(dev, link, ALL) 4094 4068 ata_dev_disable(dev); 4095 4069 } 4096 4070 4097 4071 ata_eh_finish(ap); 4098 - } 4099 - 4100 - /** 4101 - * ata_std_error_handler - standard error handler 4102 - * @ap: host port to handle error for 4103 - * 4104 - * Standard error handler 4105 - * 4106 - * LOCKING: 4107 - * Kernel thread context (may sleep). 4108 - */ 4109 - void ata_std_error_handler(struct ata_port *ap) 4110 - { 4111 - struct ata_port_operations *ops = ap->ops; 4112 - ata_reset_fn_t hardreset = ops->hardreset; 4113 - 4114 - /* ignore built-in hardreset if SCR access is not available */ 4115 - if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) 4116 - hardreset = NULL; 4117 - 4118 - ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); 4119 4072 } 4120 4073 EXPORT_SYMBOL_GPL(ata_std_error_handler); 4121 4074
+9 -17
drivers/ata/libata-pmp.c
··· 15 15 16 16 const struct ata_port_operations sata_pmp_port_ops = { 17 17 .inherits = &sata_port_ops, 18 - .pmp_prereset = ata_std_prereset, 19 - .pmp_hardreset = sata_std_hardreset, 20 - .pmp_postreset = ata_std_postreset, 18 + .pmp_reset.prereset = ata_std_prereset, 19 + .pmp_reset.hardreset = sata_std_hardreset, 20 + .pmp_reset.postreset = ata_std_postreset, 21 21 .error_handler = sata_pmp_error_handler, 22 22 }; 23 23 ··· 727 727 /** 728 728 * sata_pmp_eh_recover_pmp - recover PMP 729 729 * @ap: ATA port PMP is attached to 730 - * @prereset: prereset method (can be NULL) 731 - * @softreset: softreset method 732 - * @hardreset: hardreset method 733 - * @postreset: postreset method (can be NULL) 730 + * @reset_ops: The set of reset operations to use 734 731 * 735 732 * Recover PMP attached to @ap. Recovery procedure is somewhat 736 733 * similar to that of ata_eh_recover() except that reset should ··· 741 744 * 0 on success, -errno on failure. 742 745 */ 743 746 static int sata_pmp_eh_recover_pmp(struct ata_port *ap, 744 - ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 745 - ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) 747 + struct ata_reset_operations *reset_ops) 746 748 { 747 749 struct ata_link *link = &ap->link; 748 750 struct ata_eh_context *ehc = &link->eh_context; ··· 763 767 struct ata_link *tlink; 764 768 765 769 /* reset */ 766 - rc = ata_eh_reset(link, 0, prereset, softreset, hardreset, 767 - postreset); 770 + rc = ata_eh_reset(link, 0, reset_ops); 768 771 if (rc) { 769 772 ata_link_err(link, "failed to reset PMP, giving up\n"); 770 773 goto fail; ··· 927 932 retry: 928 933 /* PMP attached? */ 929 934 if (!sata_pmp_attached(ap)) { 930 - rc = ata_eh_recover(ap, ops->prereset, ops->softreset, 931 - ops->hardreset, ops->postreset, NULL); 935 + rc = ata_eh_recover(ap, &ops->reset, NULL); 932 936 if (rc) { 933 937 ata_for_each_dev(dev, &ap->link, ALL) 934 938 ata_dev_disable(dev); ··· 945 951 } 946 952 947 953 /* recover pmp */ 948 - rc = sata_pmp_eh_recover_pmp(ap, ops->prereset, ops->softreset, 949 - ops->hardreset, ops->postreset); 954 + rc = sata_pmp_eh_recover_pmp(ap, &ops->reset); 950 955 if (rc) 951 956 goto pmp_fail; 952 957 ··· 971 978 goto pmp_fail; 972 979 973 980 /* recover links */ 974 - rc = ata_eh_recover(ap, ops->pmp_prereset, ops->pmp_softreset, 975 - ops->pmp_hardreset, ops->pmp_postreset, &link); 981 + rc = ata_eh_recover(ap, &ops->pmp_reset, &link); 976 982 if (rc) 977 983 goto link_fail; 978 984
+6 -1
drivers/ata/libata-sata.c
··· 924 924 925 925 spin_lock_irqsave(ap->lock, flags); 926 926 927 + if (ap->flags & ATA_FLAG_NO_LPM) { 928 + count = -EOPNOTSUPP; 929 + goto out_unlock; 930 + } 931 + 927 932 ata_for_each_link(link, ap, EDGE) { 928 933 ata_for_each_dev(dev, &ap->link, ENABLED) { 929 934 if (dev->quirks & ATA_QUIRK_NOLPM) { ··· 1704 1699 .inherits = &ata_base_port_ops, 1705 1700 1706 1701 .qc_defer = ata_std_qc_defer, 1707 - .hardreset = sata_std_hardreset, 1702 + .reset.hardreset = sata_std_hardreset, 1708 1703 }; 1709 1704 EXPORT_SYMBOL_GPL(sata_port_ops);
+12 -13
drivers/ata/libata-scsi.c
··· 1923 1923 }; 1924 1924 1925 1925 for (i = 0; i < sizeof(pages); i++) { 1926 - if (pages[i] == 0xb6 && 1927 - !(dev->flags & ATA_DFLAG_ZAC)) 1926 + if (pages[i] == 0xb6 && !ata_dev_is_zac(dev)) 1928 1927 continue; 1929 1928 rbuf[num_pages + 4] = pages[i]; 1930 1929 num_pages++; ··· 2180 2181 static unsigned int ata_scsiop_inq_b6(struct ata_device *dev, 2181 2182 struct scsi_cmnd *cmd, u8 *rbuf) 2182 2183 { 2183 - if (!(dev->flags & ATA_DFLAG_ZAC)) { 2184 + if (!ata_dev_is_zac(dev)) { 2184 2185 ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); 2185 2186 return 0; 2186 2187 } ··· 4316 4317 * scsi_queue_rq() will defer commands if scsi_host_in_recovery(). 4317 4318 * However, this check is done without holding the ap->lock (a libata 4318 4319 * specific lock), so we can have received an error irq since then, 4319 - * therefore we must check if EH is pending, while holding ap->lock. 4320 + * therefore we must check if EH is pending or running, while holding 4321 + * ap->lock. 4320 4322 */ 4321 - if (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) 4323 + if (ata_port_eh_scheduled(ap)) 4322 4324 return SCSI_MLQUEUE_DEVICE_BUSY; 4323 4325 4324 4326 if (unlikely(!scmd->cmd_len)) ··· 4634 4634 * ata_scsi_offline_dev - offline attached SCSI device 4635 4635 * @dev: ATA device to offline attached SCSI device for 4636 4636 * 4637 - * This function is called from ata_eh_hotplug() and responsible 4638 - * for taking the SCSI device attached to @dev offline. This 4639 - * function is called with host lock which protects dev->sdev 4640 - * against clearing. 4637 + * This function is called from ata_eh_detach_dev() and is responsible for 4638 + * taking the SCSI device attached to @dev offline. This function is 4639 + * called with host lock which protects dev->sdev against clearing. 4641 4640 * 4642 4641 * LOCKING: 4643 4642 * spin_lock_irqsave(host lock) 4644 4643 * 4645 4644 * RETURNS: 4646 - * 1 if attached SCSI device exists, 0 otherwise. 4645 + * true if attached SCSI device exists, false otherwise. 4647 4646 */ 4648 - int ata_scsi_offline_dev(struct ata_device *dev) 4647 + bool ata_scsi_offline_dev(struct ata_device *dev) 4649 4648 { 4650 4649 if (dev->sdev) { 4651 4650 scsi_device_set_state(dev->sdev, SDEV_OFFLINE); 4652 - return 1; 4651 + return true; 4653 4652 } 4654 - return 0; 4653 + return false; 4655 4654 } 4656 4655 4657 4656 /**
+5 -13
drivers/ata/libata-sff.c
··· 31 31 32 32 .freeze = ata_sff_freeze, 33 33 .thaw = ata_sff_thaw, 34 - .prereset = ata_sff_prereset, 35 - .softreset = ata_sff_softreset, 36 - .hardreset = sata_sff_hardreset, 37 - .postreset = ata_sff_postreset, 34 + .reset.prereset = ata_sff_prereset, 35 + .reset.softreset = ata_sff_softreset, 36 + .reset.hardreset = sata_sff_hardreset, 37 + .reset.postreset = ata_sff_postreset, 38 38 .error_handler = ata_sff_error_handler, 39 39 40 40 .sff_dev_select = ata_sff_dev_select, ··· 2054 2054 */ 2055 2055 void ata_sff_error_handler(struct ata_port *ap) 2056 2056 { 2057 - ata_reset_fn_t softreset = ap->ops->softreset; 2058 - ata_reset_fn_t hardreset = ap->ops->hardreset; 2059 2057 struct ata_queued_cmd *qc; 2060 2058 unsigned long flags; 2061 2059 ··· 2075 2077 2076 2078 spin_unlock_irqrestore(ap->lock, flags); 2077 2079 2078 - /* ignore built-in hardresets if SCR access is not available */ 2079 - if ((hardreset == sata_std_hardreset || 2080 - hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link)) 2081 - hardreset = NULL; 2082 - 2083 - ata_do_eh(ap, ap->ops->prereset, softreset, hardreset, 2084 - ap->ops->postreset); 2080 + ata_std_error_handler(ap); 2085 2081 } 2086 2082 EXPORT_SYMBOL_GPL(ata_sff_error_handler); 2087 2083
+2 -2
drivers/ata/libata-transport.c
··· 202 202 { \ 203 203 struct ata_port *ap = transport_class_to_port(dev); \ 204 204 \ 205 - return scnprintf(buf, 20, format_string, cast ap->field); \ 205 + return sysfs_emit(buf, format_string, cast ap->field); \ 206 206 } 207 207 208 208 #define ata_port_simple_attr(field, name, format_string, type) \ ··· 389 389 { \ 390 390 struct ata_device *ata_dev = transport_class_to_dev(dev); \ 391 391 \ 392 - return scnprintf(buf, 20, format_string, cast ata_dev->field); \ 392 + return sysfs_emit(buf, format_string, cast ata_dev->field); \ 393 393 } 394 394 395 395 #define ata_dev_simple_attr(field, format_string, type) \
+16 -8
drivers/ata/libata.h
··· 44 44 return (sstatus & 0xf) == 0x3; 45 45 } 46 46 47 + static inline bool ata_dev_is_zac(struct ata_device *dev) 48 + { 49 + /* Host managed device or host aware device */ 50 + return dev->class == ATA_DEV_ZAC || 51 + ata_id_zoned_cap(dev->id) == 0x01; 52 + } 53 + 54 + static inline bool ata_port_eh_scheduled(struct ata_port *ap) 55 + { 56 + return ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS); 57 + } 58 + 47 59 #ifdef CONFIG_ATA_FORCE 48 60 extern void ata_force_cbl(struct ata_port *ap); 49 61 #else ··· 102 90 extern const char *sata_spd_string(unsigned int spd); 103 91 extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, 104 92 u8 page, void *buf, unsigned int sectors); 105 - void ata_dev_cleanup_cdl_resources(struct ata_device *dev); 106 93 107 94 #define to_ata_port(d) container_of(d, struct ata_port, tdev) 108 95 ··· 148 137 extern int ata_scsi_add_hosts(struct ata_host *host, 149 138 const struct scsi_host_template *sht); 150 139 extern void ata_scsi_scan_host(struct ata_port *ap, int sync); 151 - extern int ata_scsi_offline_dev(struct ata_device *dev); 140 + extern bool ata_scsi_offline_dev(struct ata_device *dev); 152 141 extern bool ata_scsi_sense_is_valid(u8 sk, u8 asc, u8 ascq); 153 142 extern void ata_scsi_set_sense(struct ata_device *dev, 154 143 struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq); ··· 180 169 const char *ata_get_cmd_name(u8 command); 181 170 extern void ata_eh_report(struct ata_port *ap); 182 171 extern int ata_eh_reset(struct ata_link *link, int classify, 183 - ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 184 - ata_reset_fn_t hardreset, ata_postreset_fn_t postreset); 185 - extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 186 - extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, 187 - ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 188 - ata_postreset_fn_t postreset, 172 + struct ata_reset_operations *reset_ops); 173 + extern int ata_eh_recover(struct ata_port *ap, 174 + struct ata_reset_operations *reset_ops, 189 175 struct ata_link **r_failed_disk); 190 176 extern void ata_eh_finish(struct ata_port *ap); 191 177 extern int ata_ering_map(struct ata_ering *ering,
+1 -1
drivers/ata/pata_acpi.c
··· 216 216 .mode_filter = pacpi_mode_filter, 217 217 .set_piomode = pacpi_set_piomode, 218 218 .set_dmamode = pacpi_set_dmamode, 219 - .prereset = pacpi_pre_reset, 219 + .reset.prereset = pacpi_pre_reset, 220 220 .port_start = pacpi_port_start, 221 221 }; 222 222
+5 -5
drivers/ata/pata_ali.c
··· 392 392 * Port operations for DMA capable ALi with cable detect 393 393 */ 394 394 static struct ata_port_operations ali_c2_port_ops = { 395 - .inherits = &ali_dma_base_ops, 396 - .check_atapi_dma = ali_check_atapi_dma, 397 - .cable_detect = ali_c2_cable_detect, 398 - .dev_config = ali_lock_sectors, 399 - .postreset = ali_c2_c3_postreset, 395 + .inherits = &ali_dma_base_ops, 396 + .check_atapi_dma = ali_check_atapi_dma, 397 + .cable_detect = ali_c2_cable_detect, 398 + .dev_config = ali_lock_sectors, 399 + .reset.postreset = ali_c2_c3_postreset, 400 400 }; 401 401 402 402 /*
+2 -2
drivers/ata/pata_amd.c
··· 394 394 395 395 static const struct ata_port_operations amd_base_port_ops = { 396 396 .inherits = &ata_bmdma32_port_ops, 397 - .prereset = amd_pre_reset, 397 + .reset.prereset = amd_pre_reset, 398 398 }; 399 399 400 400 static struct ata_port_operations amd33_port_ops = { ··· 429 429 .inherits = &ata_bmdma_port_ops, 430 430 .cable_detect = ata_cable_ignore, 431 431 .mode_filter = nv_mode_filter, 432 - .prereset = nv_pre_reset, 432 + .reset.prereset = nv_pre_reset, 433 433 .host_stop = nv_host_stop, 434 434 }; 435 435
+2 -2
drivers/ata/pata_artop.c
··· 301 301 .cable_detect = ata_cable_40wire, 302 302 .set_piomode = artop6210_set_piomode, 303 303 .set_dmamode = artop6210_set_dmamode, 304 - .prereset = artop62x0_pre_reset, 304 + .reset.prereset = artop62x0_pre_reset, 305 305 .qc_defer = artop6210_qc_defer, 306 306 }; 307 307 ··· 310 310 .cable_detect = artop6260_cable_detect, 311 311 .set_piomode = artop6260_set_piomode, 312 312 .set_dmamode = artop6260_set_dmamode, 313 - .prereset = artop62x0_pre_reset, 313 + .reset.prereset = artop62x0_pre_reset, 314 314 }; 315 315 316 316 static void atp8xx_fixup(struct pci_dev *pdev)
+1 -1
drivers/ata/pata_atiixp.c
··· 264 264 .bmdma_start = atiixp_bmdma_start, 265 265 .bmdma_stop = atiixp_bmdma_stop, 266 266 267 - .prereset = atiixp_prereset, 267 + .reset.prereset = atiixp_prereset, 268 268 .cable_detect = atiixp_cable_detect, 269 269 .set_piomode = atiixp_set_piomode, 270 270 .set_dmamode = atiixp_set_dmamode,
+1 -1
drivers/ata/pata_efar.c
··· 243 243 .cable_detect = efar_cable_detect, 244 244 .set_piomode = efar_set_piomode, 245 245 .set_dmamode = efar_set_dmamode, 246 - .prereset = efar_pre_reset, 246 + .reset.prereset = efar_pre_reset, 247 247 }; 248 248 249 249
+2 -2
drivers/ata/pata_ep93xx.c
··· 879 879 static struct ata_port_operations ep93xx_pata_port_ops = { 880 880 .inherits = &ata_bmdma_port_ops, 881 881 882 - .softreset = ep93xx_pata_softreset, 883 - .hardreset = ATA_OP_NULL, 882 + .reset.softreset = ep93xx_pata_softreset, 883 + .reset.hardreset = ATA_OP_NULL, 884 884 885 885 .sff_dev_select = ep93xx_pata_dev_select, 886 886 .sff_set_devctl = ep93xx_pata_set_devctl,
+1 -1
drivers/ata/pata_hpt366.c
··· 322 322 323 323 static struct ata_port_operations hpt366_port_ops = { 324 324 .inherits = &ata_bmdma_port_ops, 325 - .prereset = hpt366_prereset, 325 + .reset.prereset = hpt366_prereset, 326 326 .cable_detect = hpt36x_cable_detect, 327 327 .mode_filter = hpt366_filter, 328 328 .set_piomode = hpt366_set_piomode,
+2 -2
drivers/ata/pata_hpt37x.c
··· 543 543 .cable_detect = hpt37x_cable_detect, 544 544 .set_piomode = hpt37x_set_piomode, 545 545 .set_dmamode = hpt37x_set_dmamode, 546 - .prereset = hpt37x_pre_reset, 546 + .reset.prereset = hpt37x_pre_reset, 547 547 }; 548 548 549 549 /* ··· 567 567 .cable_detect = hpt37x_cable_detect, 568 568 .set_piomode = hpt37x_set_piomode, 569 569 .set_dmamode = hpt37x_set_dmamode, 570 - .prereset = hpt37x_pre_reset, 570 + .reset.prereset = hpt37x_pre_reset, 571 571 }; 572 572 573 573 /*
+1 -1
drivers/ata/pata_hpt3x2n.c
··· 356 356 .cable_detect = hpt3x2n_cable_detect, 357 357 .set_piomode = hpt3x2n_set_piomode, 358 358 .set_dmamode = hpt3x2n_set_dmamode, 359 - .prereset = hpt3x2n_pre_reset, 359 + .reset.prereset = hpt3x2n_pre_reset, 360 360 }; 361 361 362 362 /*
+1 -1
drivers/ata/pata_icside.c
··· 336 336 337 337 .cable_detect = ata_cable_40wire, 338 338 .set_dmamode = pata_icside_set_dmamode, 339 - .postreset = pata_icside_postreset, 339 + .reset.postreset = pata_icside_postreset, 340 340 341 341 .port_start = ATA_OP_NULL, /* don't need PRD table */ 342 342 };
+1 -1
drivers/ata/pata_it8213.c
··· 238 238 .cable_detect = it8213_cable_detect, 239 239 .set_piomode = it8213_set_piomode, 240 240 .set_dmamode = it8213_set_dmamode, 241 - .prereset = it8213_pre_reset, 241 + .reset.prereset = it8213_pre_reset, 242 242 }; 243 243 244 244
+1 -1
drivers/ata/pata_jmicron.c
··· 113 113 114 114 static struct ata_port_operations jmicron_ops = { 115 115 .inherits = &ata_bmdma_port_ops, 116 - .prereset = jmicron_pre_reset, 116 + .reset.prereset = jmicron_pre_reset, 117 117 }; 118 118 119 119
+1 -1
drivers/ata/pata_marvell.c
··· 99 99 static struct ata_port_operations marvell_ops = { 100 100 .inherits = &ata_bmdma_port_ops, 101 101 .cable_detect = marvell_cable_detect, 102 - .prereset = marvell_pre_reset, 102 + .reset.prereset = marvell_pre_reset, 103 103 }; 104 104 105 105
+1 -1
drivers/ata/pata_mpiix.c
··· 145 145 .qc_issue = mpiix_qc_issue, 146 146 .cable_detect = ata_cable_40wire, 147 147 .set_piomode = mpiix_set_piomode, 148 - .prereset = mpiix_pre_reset, 148 + .reset.prereset = mpiix_pre_reset, 149 149 .sff_data_xfer = ata_sff_data_xfer32, 150 150 }; 151 151
+1 -1
drivers/ata/pata_ns87410.c
··· 123 123 .qc_issue = ns87410_qc_issue, 124 124 .cable_detect = ata_cable_40wire, 125 125 .set_piomode = ns87410_set_piomode, 126 - .prereset = ns87410_pre_reset, 126 + .reset.prereset = ns87410_pre_reset, 127 127 }; 128 128 129 129 static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+1 -1
drivers/ata/pata_octeon_cf.c
··· 941 941 /* 16 bit but not True IDE */ 942 942 base = cs0 + 0x800; 943 943 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16; 944 - octeon_cf_ops.softreset = octeon_cf_softreset16; 944 + octeon_cf_ops.reset.softreset = octeon_cf_softreset16; 945 945 octeon_cf_ops.sff_check_status = octeon_cf_check_status16; 946 946 octeon_cf_ops.sff_tf_read = octeon_cf_tf_read16; 947 947 octeon_cf_ops.sff_tf_load = octeon_cf_tf_load16;
+1 -1
drivers/ata/pata_oldpiix.c
··· 214 214 .cable_detect = ata_cable_40wire, 215 215 .set_piomode = oldpiix_set_piomode, 216 216 .set_dmamode = oldpiix_set_dmamode, 217 - .prereset = oldpiix_pre_reset, 217 + .reset.prereset = oldpiix_pre_reset, 218 218 }; 219 219 220 220
+1 -1
drivers/ata/pata_opti.c
··· 156 156 .inherits = &ata_sff_port_ops, 157 157 .cable_detect = ata_cable_40wire, 158 158 .set_piomode = opti_set_piomode, 159 - .prereset = opti_pre_reset, 159 + .reset.prereset = opti_pre_reset, 160 160 }; 161 161 162 162 static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+4 -2
drivers/ata/pata_optidma.c
··· 322 322 u8 r; 323 323 int nybble = 4 * ap->port_no; 324 324 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 325 - int rc = ata_do_set_mode(link, r_failed); 325 + int rc; 326 + 327 + rc = ata_set_mode(link, r_failed); 326 328 if (rc == 0) { 327 329 pci_read_config_byte(pdev, 0x43, &r); 328 330 ··· 346 344 .set_piomode = optidma_set_pio_mode, 347 345 .set_dmamode = optidma_set_dma_mode, 348 346 .set_mode = optidma_set_mode, 349 - .prereset = optidma_pre_reset, 347 + .reset.prereset = optidma_pre_reset, 350 348 }; 351 349 352 350 static struct ata_port_operations optiplus_port_ops = {
+2 -2
drivers/ata/pata_parport/pata_parport.c
··· 321 321 static struct ata_port_operations pata_parport_port_ops = { 322 322 .inherits = &ata_sff_port_ops, 323 323 324 - .softreset = pata_parport_softreset, 325 - .hardreset = NULL, 324 + .reset.softreset = pata_parport_softreset, 325 + .reset.hardreset = NULL, 326 326 327 327 .sff_dev_select = pata_parport_dev_select, 328 328 .sff_set_devctl = pata_parport_set_devctl,
+2 -2
drivers/ata/pata_pcmcia.c
··· 46 46 struct ata_device *slave = &link->device[1]; 47 47 48 48 if (!ata_dev_enabled(master) || !ata_dev_enabled(slave)) 49 - return ata_do_set_mode(link, r_failed_dev); 49 + return ata_set_mode(link, r_failed_dev); 50 50 51 51 if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, 52 52 ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) { ··· 58 58 ata_dev_disable(slave); 59 59 } 60 60 } 61 - return ata_do_set_mode(link, r_failed_dev); 61 + return ata_set_mode(link, r_failed_dev); 62 62 } 63 63 64 64 /**
+2 -2
drivers/ata/pata_pdc2027x.c
··· 130 130 .inherits = &ata_bmdma_port_ops, 131 131 .check_atapi_dma = pdc2027x_check_atapi_dma, 132 132 .cable_detect = pdc2027x_cable_detect, 133 - .prereset = pdc2027x_prereset, 133 + .reset.prereset = pdc2027x_prereset, 134 134 }; 135 135 136 136 static struct ata_port_operations pdc2027x_pata133_ops = { ··· 387 387 struct ata_device *dev; 388 388 int rc; 389 389 390 - rc = ata_do_set_mode(link, r_failed); 390 + rc = ata_set_mode(link, r_failed); 391 391 if (rc < 0) 392 392 return rc; 393 393
+3 -3
drivers/ata/pata_rdc.c
··· 276 276 .cable_detect = rdc_pata_cable_detect, 277 277 .set_piomode = rdc_set_piomode, 278 278 .set_dmamode = rdc_set_dmamode, 279 - .prereset = rdc_pata_prereset, 279 + .reset.prereset = rdc_pata_prereset, 280 280 }; 281 281 282 282 static const struct ata_port_info rdc_port_info = { ··· 359 359 } 360 360 361 361 static const struct pci_device_id rdc_pci_tbl[] = { 362 - { PCI_DEVICE(0x17F3, 0x1011), }, 363 - { PCI_DEVICE(0x17F3, 0x1012), }, 362 + { PCI_VDEVICE(RDC, 0x1011) }, 363 + { PCI_VDEVICE(RDC, 0x1012) }, 364 364 { } /* terminate list */ 365 365 }; 366 366
+1 -1
drivers/ata/pata_sis.c
··· 552 552 553 553 static struct ata_port_operations sis_base_ops = { 554 554 .inherits = &ata_bmdma_port_ops, 555 - .prereset = sis_pre_reset, 555 + .reset.prereset = sis_pre_reset, 556 556 }; 557 557 558 558 static struct ata_port_operations sis_133_ops = {
+1 -1
drivers/ata/pata_sl82c105.c
··· 248 248 .bmdma_stop = sl82c105_bmdma_stop, 249 249 .cable_detect = ata_cable_40wire, 250 250 .set_piomode = sl82c105_set_piomode, 251 - .prereset = sl82c105_pre_reset, 251 + .reset.prereset = sl82c105_pre_reset, 252 252 .sff_irq_check = sl82c105_sff_irq_check, 253 253 }; 254 254
+1 -1
drivers/ata/pata_triflex.c
··· 170 170 .bmdma_stop = triflex_bmdma_stop, 171 171 .cable_detect = ata_cable_40wire, 172 172 .set_piomode = triflex_set_piomode, 173 - .prereset = triflex_prereset, 173 + .reset.prereset = triflex_prereset, 174 174 }; 175 175 176 176 static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+1 -1
drivers/ata/pata_via.c
··· 451 451 .cable_detect = via_cable_detect, 452 452 .set_piomode = via_set_piomode, 453 453 .set_dmamode = via_set_dmamode, 454 - .prereset = via_pre_reset, 454 + .reset.prereset = via_pre_reset, 455 455 .sff_tf_load = via_tf_load, 456 456 .port_start = via_port_start, 457 457 .mode_filter = via_mode_filter,
+1 -1
drivers/ata/pdc_adma.c
··· 140 140 141 141 .freeze = adma_freeze, 142 142 .thaw = adma_thaw, 143 - .prereset = adma_prereset, 143 + .reset.prereset = adma_prereset, 144 144 145 145 .port_start = adma_port_start, 146 146 .port_stop = adma_port_stop,
+1 -1
drivers/ata/sata_dwc_460ex.c
··· 1097 1097 .inherits = &ata_sff_port_ops, 1098 1098 1099 1099 .error_handler = sata_dwc_error_handler, 1100 - .hardreset = sata_dwc_hardreset, 1100 + .reset.hardreset = sata_dwc_hardreset, 1101 1101 1102 1102 .qc_issue = sata_dwc_qc_issue, 1103 1103
+3 -3
drivers/ata/sata_fsl.c
··· 1395 1395 1396 1396 .freeze = sata_fsl_freeze, 1397 1397 .thaw = sata_fsl_thaw, 1398 - .softreset = sata_fsl_softreset, 1399 - .hardreset = sata_fsl_hardreset, 1400 - .pmp_softreset = sata_fsl_softreset, 1398 + .reset.softreset = sata_fsl_softreset, 1399 + .reset.hardreset = sata_fsl_hardreset, 1400 + .pmp_reset.softreset = sata_fsl_softreset, 1401 1401 .error_handler = sata_fsl_error_handler, 1402 1402 .post_internal_cmd = sata_fsl_post_internal_cmd, 1403 1403
+1 -1
drivers/ata/sata_highbank.c
··· 428 428 429 429 static struct ata_port_operations ahci_highbank_ops = { 430 430 .inherits = &ahci_ops, 431 - .hardreset = ahci_highbank_hardreset, 431 + .reset.hardreset = ahci_highbank_hardreset, 432 432 .transmit_led_message = ecx_transmit_led_message, 433 433 }; 434 434
+1 -1
drivers/ata/sata_inic162x.c
··· 730 730 731 731 .freeze = inic_freeze, 732 732 .thaw = inic_thaw, 733 - .hardreset = inic_hardreset, 733 + .reset.hardreset = inic_hardreset, 734 734 .error_handler = inic_error_handler, 735 735 .post_internal_cmd = inic_post_internal_cmd, 736 736
+5 -5
drivers/ata/sata_mv.c
··· 687 687 688 688 .freeze = mv_eh_freeze, 689 689 .thaw = mv_eh_thaw, 690 - .hardreset = mv_hardreset, 690 + .reset.hardreset = mv_hardreset, 691 691 692 692 .scr_read = mv5_scr_read, 693 693 .scr_write = mv5_scr_write, ··· 709 709 710 710 .freeze = mv_eh_freeze, 711 711 .thaw = mv_eh_thaw, 712 - .hardreset = mv_hardreset, 713 - .softreset = mv_softreset, 714 - .pmp_hardreset = mv_pmp_hardreset, 715 - .pmp_softreset = mv_softreset, 712 + .reset.hardreset = mv_hardreset, 713 + .reset.softreset = mv_softreset, 714 + .pmp_reset.hardreset = mv_pmp_hardreset, 715 + .pmp_reset.softreset = mv_softreset, 716 716 .error_handler = mv_pmp_error_handler, 717 717 718 718 .scr_read = mv_scr_read,
+1 -1
drivers/ata/sata_nv.c
··· 462 462 .lost_interrupt = ATA_OP_NULL, 463 463 .scr_read = nv_scr_read, 464 464 .scr_write = nv_scr_write, 465 - .hardreset = nv_hardreset, 465 + .reset.hardreset = nv_hardreset, 466 466 }; 467 467 468 468 static struct ata_port_operations nv_nf2_ops = {
+2 -2
drivers/ata/sata_promise.c
··· 188 188 .scr_read = pdc_sata_scr_read, 189 189 .scr_write = pdc_sata_scr_write, 190 190 .port_start = pdc_sata_port_start, 191 - .hardreset = pdc_sata_hardreset, 191 + .reset.hardreset = pdc_sata_hardreset, 192 192 }; 193 193 194 194 /* First-generation chips need a more restrictive ->check_atapi_dma op, ··· 206 206 .freeze = pdc_freeze, 207 207 .thaw = pdc_thaw, 208 208 .port_start = pdc_common_port_start, 209 - .softreset = pdc_pata_softreset, 209 + .reset.softreset = pdc_pata_softreset, 210 210 }; 211 211 212 212 static const struct ata_port_info pdc_port_info[] = {
+2 -2
drivers/ata/sata_qstor.c
··· 123 123 124 124 .freeze = qs_freeze, 125 125 .thaw = qs_thaw, 126 - .prereset = qs_prereset, 127 - .softreset = ATA_OP_NULL, 126 + .reset.prereset = qs_prereset, 127 + .reset.softreset = ATA_OP_NULL, 128 128 .error_handler = qs_error_handler, 129 129 .lost_interrupt = ATA_OP_NULL, 130 130
+1 -1
drivers/ata/sata_rcar.c
··· 624 624 625 625 .freeze = sata_rcar_freeze, 626 626 .thaw = sata_rcar_thaw, 627 - .softreset = sata_rcar_softreset, 627 + .reset.softreset = sata_rcar_softreset, 628 628 629 629 .scr_read = sata_rcar_scr_read, 630 630 .scr_write = sata_rcar_scr_write,
+1 -1
drivers/ata/sata_sil.c
··· 351 351 u32 tmp, dev_mode[2] = { }; 352 352 int rc; 353 353 354 - rc = ata_do_set_mode(link, r_failed); 354 + rc = ata_set_mode(link, r_failed); 355 355 if (rc) 356 356 return rc; 357 357
+4 -4
drivers/ata/sata_sil24.c
··· 393 393 394 394 .freeze = sil24_freeze, 395 395 .thaw = sil24_thaw, 396 - .softreset = sil24_softreset, 397 - .hardreset = sil24_hardreset, 398 - .pmp_softreset = sil24_softreset, 399 - .pmp_hardreset = sil24_pmp_hardreset, 396 + .reset.softreset = sil24_softreset, 397 + .reset.hardreset = sil24_hardreset, 398 + .pmp_reset.softreset = sil24_softreset, 399 + .pmp_reset.hardreset = sil24_pmp_hardreset, 400 400 .error_handler = sil24_error_handler, 401 401 .post_internal_cmd = sil24_post_internal_cmd, 402 402 .dev_config = sil24_dev_config,
+2 -2
drivers/ata/sata_svw.c
··· 340 340 341 341 static struct ata_port_operations k2_sata_ops = { 342 342 .inherits = &ata_bmdma_port_ops, 343 - .softreset = k2_sata_softreset, 344 - .hardreset = k2_sata_hardreset, 343 + .reset.softreset = k2_sata_softreset, 344 + .reset.hardreset = k2_sata_hardreset, 345 345 .sff_tf_load = k2_sata_tf_load, 346 346 .sff_tf_read = k2_sata_tf_read, 347 347 .sff_check_status = k2_stat_check_status,
+1 -1
drivers/ata/sata_sx4.c
··· 241 241 242 242 .freeze = pdc_freeze, 243 243 .thaw = pdc_thaw, 244 - .softreset = pdc_softreset, 244 + .reset.softreset = pdc_softreset, 245 245 .error_handler = pdc_error_handler, 246 246 .lost_interrupt = ATA_OP_NULL, 247 247 .post_internal_cmd = pdc_post_internal_cmd,
+1 -1
drivers/ata/sata_uli.c
··· 67 67 .inherits = &ata_bmdma_port_ops, 68 68 .scr_read = uli_scr_read, 69 69 .scr_write = uli_scr_write, 70 - .hardreset = ATA_OP_NULL, 70 + .reset.hardreset = ATA_OP_NULL, 71 71 }; 72 72 73 73 static const struct ata_port_info uli_port_info = {
+2 -2
drivers/ata/sata_via.c
··· 120 120 static struct ata_port_operations vt6420_sata_ops = { 121 121 .inherits = &svia_base_ops, 122 122 .freeze = svia_noop_freeze, 123 - .prereset = vt6420_prereset, 123 + .reset.prereset = vt6420_prereset, 124 124 .bmdma_start = vt6420_bmdma_start, 125 125 }; 126 126 ··· 140 140 141 141 static struct ata_port_operations vt8251_ops = { 142 142 .inherits = &svia_base_ops, 143 - .hardreset = sata_std_hardreset, 143 + .reset.hardreset = sata_std_hardreset, 144 144 .scr_read = vt8251_scr_read, 145 145 .scr_write = vt8251_scr_write, 146 146 };
+2 -2
drivers/scsi/libsas/sas_ata.c
··· 559 559 } 560 560 561 561 static struct ata_port_operations sas_sata_ops = { 562 - .prereset = sas_ata_prereset, 563 - .hardreset = sas_ata_hard_reset, 562 + .reset.prereset = sas_ata_prereset, 563 + .reset.hardreset = sas_ata_hard_reset, 564 564 .error_handler = ata_std_error_handler, 565 565 .post_internal_cmd = sas_ata_post_internal, 566 566 .qc_defer = ata_std_qc_defer,
+36 -18
include/linux/libata.h
··· 144 144 ATA_DFLAG_DEVSLP = (1 << 27), /* device supports Device Sleep */ 145 145 ATA_DFLAG_ACPI_DISABLED = (1 << 28), /* ACPI for the device is disabled */ 146 146 ATA_DFLAG_D_SENSE = (1 << 29), /* Descriptor sense requested */ 147 - ATA_DFLAG_ZAC = (1 << 30), /* ZAC device */ 148 147 149 148 ATA_DFLAG_FEATURES_MASK = (ATA_DFLAG_TRUSTED | ATA_DFLAG_DA | \ 150 149 ATA_DFLAG_DEVSLP | ATA_DFLAG_NCQ_SEND_RECV | \ ··· 499 500 }; 500 501 501 502 /* 502 - * Link power management policy: If you alter this, you also need to 503 - * alter libata-sata.c (for the ascii descriptions) 503 + * Link Power Management (LPM) policies. 504 + * 505 + * The default LPM policy to use for a device link is defined using these values 506 + * with the CONFIG_SATA_MOBILE_LPM_POLICY config option and applied through the 507 + * target_lpm_policy field of struct ata_port. 508 + * 509 + * If you alter this, you also need to alter the policy names used with the 510 + * sysfs attribute link_power_management_policy defined in libata-sata.c. 504 511 */ 505 512 enum ata_lpm_policy { 513 + /* Keep firmware settings */ 506 514 ATA_LPM_UNKNOWN, 515 + /* No power savings (maximum performance) */ 507 516 ATA_LPM_MAX_POWER, 517 + /* HIPM (Partial) */ 508 518 ATA_LPM_MED_POWER, 509 - ATA_LPM_MED_POWER_WITH_DIPM, /* Med power + DIPM as win IRST does */ 510 - ATA_LPM_MIN_POWER_WITH_PARTIAL, /* Min Power + partial and slumber */ 511 - ATA_LPM_MIN_POWER, /* Min power + no partial (slumber only) */ 519 + /* HIPM (Partial) and DIPM (Partial and Slumber) */ 520 + ATA_LPM_MED_POWER_WITH_DIPM, 521 + /* HIPM (Partial and DevSleep) and DIPM (Partial and Slumber) */ 522 + ATA_LPM_MIN_POWER_WITH_PARTIAL, 523 + /* HIPM (Slumber and DevSleep) and DIPM (Partial and Slumber) */ 524 + ATA_LPM_MIN_POWER, 512 525 }; 513 526 514 527 enum ata_lpm_hints { ··· 761 750 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ 762 751 } ____cacheline_aligned; 763 752 753 + /* General Purpose Log Directory log page */ 754 + u8 gp_log_dir[ATA_SECT_SIZE] ____cacheline_aligned; 755 + 764 756 /* DEVSLP Timing Variables from Identify Device Data Log */ 765 757 u8 devslp_timing[ATA_LOG_DEVSLP_SIZE]; 766 758 ··· 944 930 */ 945 931 #define ATA_OP_NULL (void *)(unsigned long)(-ENOENT) 946 932 933 + struct ata_reset_operations { 934 + ata_prereset_fn_t prereset; 935 + ata_reset_fn_t softreset; 936 + ata_reset_fn_t hardreset; 937 + ata_postreset_fn_t postreset; 938 + }; 939 + 947 940 struct ata_port_operations { 948 941 /* 949 942 * Command execution ··· 977 956 978 957 void (*freeze)(struct ata_port *ap); 979 958 void (*thaw)(struct ata_port *ap); 980 - ata_prereset_fn_t prereset; 981 - ata_reset_fn_t softreset; 982 - ata_reset_fn_t hardreset; 983 - ata_postreset_fn_t postreset; 984 - ata_prereset_fn_t pmp_prereset; 985 - ata_reset_fn_t pmp_softreset; 986 - ata_reset_fn_t pmp_hardreset; 987 - ata_postreset_fn_t pmp_postreset; 959 + struct ata_reset_operations reset; 960 + struct ata_reset_operations pmp_reset; 988 961 void (*error_handler)(struct ata_port *ap); 989 962 void (*lost_interrupt)(struct ata_port *ap); 990 963 void (*post_internal_cmd)(struct ata_queued_cmd *qc); ··· 1219 1204 extern int ata_ncq_prio_enable(struct ata_port *ap, struct scsi_device *sdev, 1220 1205 bool enable); 1221 1206 extern struct ata_device *ata_dev_pair(struct ata_device *adev); 1222 - extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1207 + int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1223 1208 extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap); 1224 1209 extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q); 1225 1210 ··· 1413 1398 extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); 1414 1399 extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); 1415 1400 1416 - extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 1417 - ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1418 - ata_postreset_fn_t postreset); 1419 1401 extern void ata_std_error_handler(struct ata_port *ap); 1420 1402 extern void ata_std_sched_eh(struct ata_port *ap); 1421 1403 extern void ata_std_end_eh(struct ata_port *ap); ··· 2149 2137 ata_port_dbg(ap, "abnormal Status 0x%X\n", status); 2150 2138 2151 2139 return status; 2140 + } 2141 + #else /* CONFIG_ATA_SFF */ 2142 + static inline int sata_sff_hardreset(struct ata_link *link, unsigned int *class, 2143 + unsigned long deadline) 2144 + { 2145 + return -EOPNOTSUPP; 2152 2146 } 2153 2147 #endif /* CONFIG_ATA_SFF */ 2154 2148