public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org
Cc: Niklas Cassel <cassel@kernel.org>
Subject: [PATCH] scsi: core: Disabe CDL by default
Date: Thu,  6 Jun 2024 14:46:06 +0900	[thread overview]
Message-ID: <20240606054606.55624-1-dlemoal@kernel.org> (raw)

For scsi devices supporting the Command Duration Limits feature set, the
user can enable/disable this feature use through the sysfs device
attribute cdl_enable. This attribute modification triggers a call to
scsi_cdl_enable() to enable and disable the feature for ATA devices and
set the scsi device cdl_enable to the user provided bool value.

However, for ATA devices, a drive may spin-up with the CDL feature
either enabled or disabled by default, depending on the drive. But the
scsi device cdl_enable field is always initialized to false (CDL
disabled), regardless of the actual device CDL feature state.

Add a call to scsi_cdl_enable() in scsi_cdl_check() to make sure that
the device-side state of the CDL feature always matches the scsi device
cdl_enable field state, thus avoiding inconsistencies for devices that
have CDL enabled when first scanned. This implies that CDL will always
be disabled, as it should be, when the system first scans the devices.

Reported-by: Scott McCoy <scott.mccoy@wdc.com>
Fixes: 1b22cfb14142 ("scsi: core: Allow enabling and disabling command duration limits")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/scsi/scsi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 3e0c0381277a..9e9576066e8d 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -666,6 +666,13 @@ void scsi_cdl_check(struct scsi_device *sdev)
 		sdev->use_10_for_rw = 0;
 
 		sdev->cdl_supported = 1;
+
+		/*
+		 * If the device supports CDL, make sure that the current drive
+		 * feature status is consistent with the user controlled
+		 * cdl_enable state.
+		 */
+		scsi_cdl_enable(sdev, sdev->cdl_enable);
 	} else {
 		sdev->cdl_supported = 0;
 	}
-- 
2.45.2


             reply	other threads:[~2024-06-06  5:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  5:46 Damien Le Moal [this message]
2024-06-06  9:32 ` [PATCH] scsi: core: Disabe CDL by default Christoph Hellwig
2024-06-06 12:11   ` Damien Le Moal
2024-06-06 13:23 ` Niklas Cassel
2024-06-06 15:13   ` Niklas Cassel
2024-06-06 23:11   ` Damien Le Moal
2024-06-06 15:48 ` Bart Van Assche
2024-06-06 23:08   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240606054606.55624-1-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox