From: Hannes Reinecke <hare@suse.de>
To: Damien Le Moal <dlemoal@fastmail.com>,
Niklas Cassel <nks@flawful.org>, Jens Axboe <axboe@kernel.dk>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
Christoph Hellwig <hch@lst.de>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
linux-block@vger.kernel.org,
Niklas Cassel <niklas.cassel@wdc.com>
Subject: Re: [PATCH v5 08/19] scsi: detect support for command duration limits
Date: Wed, 5 Apr 2023 08:26:00 +0200 [thread overview]
Message-ID: <c94c94f7-1a22-72b0-bcf6-a6de6c61a3ec@suse.de> (raw)
In-Reply-To: <d25d8427-1313-5696-8e23-87eadc4e6d6b@fastmail.com>
On 4/5/23 01:27, Damien Le Moal wrote:
> On 4/5/23 03:48, Hannes Reinecke wrote:
>> On 4/4/23 20:24, Niklas Cassel wrote:
>>> From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>>>
>>> Introduce the function scsi_cdl_check() to detect if a device supports
>>> command duration limits (CDL). Support for the READ 16, WRITE 16,
>>> READ 32 and WRITE 32 commands are checked using the function
>>> scsi_report_opcode() to probe the rwcdlp and cdlp bits as they indicate
>>> the mode page defining the command duration limits descriptors that
>>> apply to the command being tested.
>>>
>>> If any of these commands support CDL, the field cdl_supported of
>>> struct scsi_device is set to 1 to indicate that the device supports CDL.
>>>
>>> Support for CDL for a device is advertizes through sysfs using the new
>>> cdl_supported device attribute. This attribute value is 1 for a device
>>> supporting CDL and 0 otherwise.
>>>
>>> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>>> Co-developed-by: Niklas Cassel <niklas.cassel@wdc.com>
>>> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
>>> ---
>>> Documentation/ABI/testing/sysfs-block-device | 9 +++
>>> drivers/scsi/scsi.c | 81 ++++++++++++++++++++
>>> drivers/scsi/scsi_scan.c | 3 +
>>> drivers/scsi/scsi_sysfs.c | 2 +
>>> include/scsi/scsi_device.h | 3 +
>>> 5 files changed, 98 insertions(+)
>>>
>>> diff --git a/Documentation/ABI/testing/sysfs-block-device b/Documentation/ABI/testing/sysfs-block-device
>>> index 7ac7b19b2f72..ee3610a25845 100644
>>> --- a/Documentation/ABI/testing/sysfs-block-device
>>> +++ b/Documentation/ABI/testing/sysfs-block-device
>>> @@ -95,3 +95,12 @@ Description:
>>> This file does not exist if the HBA driver does not implement
>>> support for the SATA NCQ priority feature, regardless of the
>>> device support for this feature.
>>> +
>>> +
>>> +What: /sys/block/*/device/cdl_supported
>>> +Date: Mar, 2023
>>> +KernelVersion: v6.4
>>> +Contact: linux-scsi@vger.kernel.org
>>> +Description:
>>> + (RO) Indicates if the device supports the command duration
>>> + limits feature found in some ATA and SCSI devices.
>>> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
>>> index 62d9472e08e9..c03814ce23ca 100644
>>> --- a/drivers/scsi/scsi.c
>>> +++ b/drivers/scsi/scsi.c
>>> @@ -570,6 +570,87 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
>>> }
>>> EXPORT_SYMBOL(scsi_report_opcode);
>>>
>>> +#define SCSI_CDL_CHECK_BUF_LEN 64
>>> +
>>> +static bool scsi_cdl_check_cmd(struct scsi_device *sdev, u8 opcode, u16 sa,
>>> + unsigned char *buf)
>>> +{
>>> + int ret;
>>> + u8 cdlp;
>>> +
>>> + /* Check operation code */
>>> + ret = scsi_report_opcode(sdev, buf, SCSI_CDL_CHECK_BUF_LEN, opcode, sa);
>>> + if (ret <= 0)
>>> + return false;
>>> +
>>> + if ((buf[1] & 0x03) != 0x03)
>>> + return false;
>>> +
>>> + /* See SPC-6, one command format of REPORT SUPPORTED OPERATION CODES */
>>> + cdlp = (buf[1] & 0x18) >> 3;
>>> + if (buf[0] & 0x01) {
>>> + /* rwcdlp == 1 */
>>> + switch (cdlp) {
>>> + case 0x01:
>>> + /* T2A page */
>>> + return true;
>>> + case 0x02:
>>> + /* T2B page */
>>> + return true;
>>> + }
>>> + } else {
>>> + /* rwcdlp == 0 */
>>> + switch (cdlp) {
>>> + case 0x01:
>>> + /* A page */
>>> + return true;
>>> + case 0x02:
>>> + /* B page */
>>> + return true;
>>> + }
>>> + }
>>> +
>>> + return false;
>>> +}
>>> +
>> Why do we need to check this when writing to sysfs? Shouldn't we detect
>> this during startup / revalidate?
>
> Hmm, I think you missed the call chain on this one (the patch starting with the
> sys attribute doc changes is a little confusing).
>
> scsi_cdl_check_cmd() is called from scsi_cdl_check(), which is itself called
> from scsi_add_lun() (for initial device scan) and scsi_rescan_device() for
> revalidate. scsi_cdl_check() will set sdev->cdl_supported to 1 for devices
> supporting CDL, which is what sysfs cdl_supported show method uses, and later,
> the cdl_enable attribute show/store method use that too. That function is not
> called from sysfs attributes methods.
>
> Note that this function was moved from sd.c to scsi.c as CDL is defined is SPC,
> not SBC.
>
Indeed, you are right.
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman
next prev parent reply other threads:[~2023-04-05 6:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 18:24 [PATCH v5 00/19] Add Command Duration Limits support Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 01/19] ioprio: cleanup interface definition Niklas Cassel
2023-04-04 18:39 ` Hannes Reinecke
2023-04-04 18:24 ` [PATCH v5 02/19] block: introduce ioprio hints Niklas Cassel
2023-04-04 18:45 ` Hannes Reinecke
2023-04-04 18:24 ` [PATCH v5 03/19] block: introduce BLK_STS_DURATION_LIMIT Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 04/19] scsi: core: allow libata to complete successful commands via EH Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 05/19] scsi: rename and move get_scsi_ml_byte() Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 06/19] scsi: support retrieving sub-pages of mode pages Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 07/19] scsi: support service action in scsi_report_opcode() Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 08/19] scsi: detect support for command duration limits Niklas Cassel
2023-04-04 18:48 ` Hannes Reinecke
2023-04-04 23:27 ` Damien Le Moal
2023-04-05 6:26 ` Hannes Reinecke [this message]
2023-04-04 18:24 ` [PATCH v5 09/19] scsi: allow enabling and disabling " Niklas Cassel
2023-04-04 19:28 ` Igor Pylypiv
2023-04-04 23:18 ` Damien Le Moal
2023-04-04 18:24 ` [PATCH v5 10/19] scsi: sd: set read/write commands CDL index Niklas Cassel
2023-04-04 18:50 ` Hannes Reinecke
2023-04-04 18:24 ` [PATCH v5 11/19] scsi: sd: handle read/write CDL timeout failures Niklas Cassel
2023-04-04 18:56 ` Hannes Reinecke
2023-04-04 18:24 ` [PATCH v5 12/19] ata: libata-scsi: remove unnecessary !cmd checks Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 13/19] ata: libata: change ata_eh_request_sense() to not set CHECK_CONDITION Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 14/19] ata: libata: detect support for command duration limits Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 15/19] ata: libata-scsi: handle CDL bits in ata_scsiop_maint_in() Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 16/19] ata: libata-scsi: add support for CDL pages mode sense Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 17/19] ata: libata: add ATA feature control sub-page translation Niklas Cassel
2023-04-04 18:24 ` [PATCH v5 18/19] ata: libata: set read/write commands CDL index Niklas Cassel
2023-04-05 18:26 ` Igor Pylypiv
2023-04-05 22:29 ` Damien Le Moal
2023-04-04 18:24 ` [PATCH v5 19/19] ata: libata: handle completion of CDL commands using policy 0xD Niklas Cassel
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=c94c94f7-1a22-72b0-bcf6-a6de6c61a3ec@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=dlemoal@fastmail.com \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=niklas.cassel@wdc.com \
--cc=nks@flawful.org \
/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;
as well as URLs for NNTP newsgroup(s).