ata: libata-sata: Add link_power_management_supported sysfs attribute
Damien Le Moal
maintainerPATCH 1/1 ata: libata-sata: Add link_power_management_supported sysfs attribute
A port link power management (LPM) policy can be controlled using the link_power_management_policy sysfs host attribute. However, this attribute exists also for hosts that do not support LPM and in such case, attempting to change the LPM policy for the host (port) will fail with -EOPNOTSUPP.
Introduce the new sysfs link_power_management_supported host attribute to indicate to the user if a the port and the devices connected to the port for the host support LPM, which implies that the link_power_management_policy attribute can be used.
Since checking that a port and its devices support LPM is common between the new ata_scsi_lpm_supported_show() function and the existing ata_scsi_lpm_store() function, the new helper ata_scsi_lpm_supported() is introduced.
--- drivers/ata/ata_piix.c | 1 + drivers/ata/libahci.c | 1 + drivers/ata/libata-sata.c | 53 ++++++++++++++++++++++++++++++--------- include/linux/libata.h | 1 + 4 files changed, 44 insertions(+), 12 deletions(-)
drivers/ata/ata_piix.c +1 -0
@@ -1089,6 +1089,7 @@ static struct ata_port_operations ich_pata_ops = { };static struct attribute *piix_sidpr_shost_attrs[] = { + &dev_attr_link_power_management_supported.attr, &dev_attr_link_power_management_policy.attr,NULL };
drivers/ata/libahci.c +1 -0
@@ -111,6 +111,7 @@ static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO, static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);static struct attribute *ahci_shost_attrs[] = { + &dev_attr_link_power_management_supported.attr, &dev_attr_link_power_management_policy.attr, &dev_attr_em_message_type.attr, &dev_attr_em_message.attr,
drivers/ata/libata-sata.c +41 -12
75 lines not on this page · raw message
include/linux/libata.h +1 -0
@@ -547,6 +547,7 @@ typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes)extern struct device_attribute dev_attr_unload_heads;#ifdef CONFIG_SATA_HOST +extern struct device_attribute dev_attr_link_power_management_supported;extern struct device_attribute dev_attr_link_power_management_policy;extern struct device_attribute dev_attr_ncq_prio_supported;extern struct device_attribute dev_attr_ncq_prio_enable;
Signature · 1 line
2.50.1
Damien,
Quoted 5 lines
A port link power management (LPM) policy can be controlled using the
link_power_management_policysysfs host attribute. However, this attribute exists also for hosts that do not support LPM and in such case, attempting to change the LPM policy for the host (port) will fail with-EOPNOTSUPP.
Looks OK to me.
Signature · 1 line
Martin K. Petersen