diff mbox series

[05/10] ata: libata-sata: Disallow changing LPM state if not supported

Message ID 20250630062637.258329-6-dlemoal@kernel.org
State New
Headers show
Series Improve link power management | expand

Commit Message

Damien Le Moal June 30, 2025, 6:26 a.m. UTC
Modify ata_scsi_lpm_store() to return an error if a user attempts to set
a link power management policy for a port that does not support LPM,
that is, ports flagged with ATA_FLAG_NO_LPM.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/ata/libata-sata.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Niklas Cassel June 30, 2025, 2:49 p.m. UTC | #1
On Mon, Jun 30, 2025 at 03:26:32PM +0900, Damien Le Moal wrote:
> Modify ata_scsi_lpm_store() to return an error if a user attempts to set
> a link power management policy for a port that does not support LPM,
> that is, ports flagged with ATA_FLAG_NO_LPM.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>

Reviewed-by: Niklas Cassel <cassel@kernel.org>
Hannes Reinecke July 1, 2025, 6:23 a.m. UTC | #2
On 6/30/25 08:26, Damien Le Moal wrote:
> Modify ata_scsi_lpm_store() to return an error if a user attempts to set
> a link power management policy for a port that does not support LPM,
> that is, ports flagged with ATA_FLAG_NO_LPM.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   drivers/ata/libata-sata.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> index cb46ce276bb1..47169c469f43 100644
> --- a/drivers/ata/libata-sata.c
> +++ b/drivers/ata/libata-sata.c
> @@ -924,6 +924,11 @@ static ssize_t ata_scsi_lpm_store(struct device *device,
>   
>   	spin_lock_irqsave(ap->lock, flags);
>   
> +	if (ap->flags & ATA_FLAG_NO_LPM) {
> +		count = -EOPNOTSUPP;
> +		goto out_unlock;
> +	}
> +
>   	ata_for_each_link(link, ap, EDGE) {
>   		ata_for_each_dev(dev, &ap->link, ENABLED) {
>   			if (dev->quirks & ATA_QUIRK_NOLPM) {

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index cb46ce276bb1..47169c469f43 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -924,6 +924,11 @@  static ssize_t ata_scsi_lpm_store(struct device *device,
 
 	spin_lock_irqsave(ap->lock, flags);
 
+	if (ap->flags & ATA_FLAG_NO_LPM) {
+		count = -EOPNOTSUPP;
+		goto out_unlock;
+	}
+
 	ata_for_each_link(link, ap, EDGE) {
 		ata_for_each_dev(dev, &ap->link, ENABLED) {
 			if (dev->quirks & ATA_QUIRK_NOLPM) {