2019-10-29 09:25:59

by Can Guo

[permalink] [raw]
Subject: [PATCH v2 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD

Host sends MODE_SENSE_10 with caching mode page, to check if the device
supports the cache feature.
UFS JEDEC standards require DBD field to be set to 1.

This patch allows LLD to define the setting of DBD if required.

Signed-off-by: Can Guo <[email protected]>
---
drivers/scsi/sd.c | 6 +++++-
include/scsi/scsi_host.h | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index aab4ed8..6d8194f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2629,6 +2629,7 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
{
int len = 0, res;
struct scsi_device *sdp = sdkp->device;
+ struct Scsi_Host *host = sdp->host;

int dbd;
int modepage;
@@ -2660,7 +2661,10 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
dbd = 8;
} else {
modepage = 8;
- dbd = 0;
+ if (host->set_dbd_for_caching)
+ dbd = 8;
+ else
+ dbd = 0;
}

/* cautiously ask */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 2c3f0c5..3900987 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -650,6 +650,12 @@ struct Scsi_Host {
unsigned no_scsi2_lun_in_cdb:1;

/*
+ * Set "DBD" field in mode_sense caching mode page in case it is
+ * mandatory by LLD standard.
+ */
+ unsigned set_dbd_for_caching:1;
+
+ /*
* Optional work queue to be utilized by the transport
*/
char work_q_name[20];
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


2019-10-31 20:42:58

by Mark Salyzyn

[permalink] [raw]
Subject: Re: [PATCH v2 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD

On 10/28/19 8:10 PM, Can Guo wrote:
> Host sends MODE_SENSE_10 with caching mode page, to check if the device
> supports the cache feature.
> UFS JEDEC standards require DBD field to be set to 1.
>
> This patch allows LLD to define the setting of DBD if required.
>
> Signed-off-by: Can Guo <[email protected]>
> ---
> drivers/scsi/sd.c | 6 +++++-
> include/scsi/scsi_host.h | 6 ++++++
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index aab4ed8..6d8194f 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2629,6 +2629,7 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
> {
> int len = 0, res;
> struct scsi_device *sdp = sdkp->device;
> + struct Scsi_Host *host = sdp->host;
variable locality
> int dbd;
> int modepage;
> @@ -2660,7 +2661,10 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
> dbd = 8;
> } else {
> modepage = 8;
> - dbd = 0;
> + if (host->set_dbd_for_caching)
> + dbd = 8;
> + else
> + dbd = 0;
> }
>

This simplifies to:

-   } else if (sdp->type == TYPE_RBC) {

+    } else if (sdp->type == TYPE_RBC || sdp->host->set_dbd_for_caching) {

> /* cautiously ask */
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 2c3f0c5..3900987 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -650,6 +650,12 @@ struct Scsi_Host {
> unsigned no_scsi2_lun_in_cdb:1;
>
> /*
> + * Set "DBD" field in mode_sense caching mode page in case it is
> + * mandatory by LLD standard.
> + */
> + unsigned set_dbd_for_caching:1;
> +
> + /*
> * Optional work queue to be utilized by the transport
> */
> char work_q_name[20];


2019-10-31 21:00:24

by Mark Salyzyn

[permalink] [raw]
Subject: Re: [PATCH v2 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD

On 10/31/19 8:20 AM, Mark Salyzyn wrote:
> On 10/28/19 8:10 PM, Can Guo wrote:
>> Host sends MODE_SENSE_10 with caching mode page, to check if the device
>> supports the cache feature.
>> UFS JEDEC standards require DBD field to be set to 1.
>>
>> This patch allows LLD to define the setting of DBD if required.
>>
>> Signed-off-by: Can Guo <[email protected]>
>> ---
>>   drivers/scsi/sd.c        | 6 +++++-
>>   include/scsi/scsi_host.h | 6 ++++++
>>   2 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>> index aab4ed8..6d8194f 100644
>> --- a/drivers/scsi/sd.c
>> +++ b/drivers/scsi/sd.c
>> @@ -2629,6 +2629,7 @@ static int sd_try_rc16_first(struct scsi_device
>> *sdp)
>>   {
>>       int len = 0, res;
>>       struct scsi_device *sdp = sdkp->device;
>> +    struct Scsi_Host *host = sdp->host;
> variable locality
>>       int dbd;
>>       int modepage;
>> @@ -2660,7 +2661,10 @@ static int sd_try_rc16_first(struct
>> scsi_device *sdp)
>>           dbd = 8;
>>       } else {
>>           modepage = 8;
>> -        dbd = 0;
>> +        if (host->set_dbd_for_caching)
>> +            dbd = 8;
>> +        else
>> +            dbd = 0;
>>       }
>
> This simplifies to:
>
> -   } else if (sdp->type == TYPE_RBC) {
>
> +    } else if (sdp->type == TYPE_RBC || sdp->host->set_dbd_for_caching) {

IDK what happened with my mailer sending out an older infant copy (blame
on fumble fingers). My final copy was instead the simplification:

+    dbd = sdp->host->set_dbd_for_caching ? 8 : 0;

2019-11-01 02:10:40

by Can Guo

[permalink] [raw]
Subject: Re: [PATCH v2 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD

On 2019-10-31 23:40, Mark Salyzyn wrote:
> On 10/31/19 8:20 AM, Mark Salyzyn wrote:
>> On 10/28/19 8:10 PM, Can Guo wrote:
>>> Host sends MODE_SENSE_10 with caching mode page, to check if the
>>> device
>>> supports the cache feature.
>>> UFS JEDEC standards require DBD field to be set to 1.
>>>
>>> This patch allows LLD to define the setting of DBD if required.
>>>
>>> Signed-off-by: Can Guo <[email protected]>
>>> ---
>>>   drivers/scsi/sd.c        | 6 +++++-
>>>   include/scsi/scsi_host.h | 6 ++++++
>>>   2 files changed, 11 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>>> index aab4ed8..6d8194f 100644
>>> --- a/drivers/scsi/sd.c
>>> +++ b/drivers/scsi/sd.c
>>> @@ -2629,6 +2629,7 @@ static int sd_try_rc16_first(struct scsi_device
>>> *sdp)
>>>   {
>>>       int len = 0, res;
>>>       struct scsi_device *sdp = sdkp->device;
>>> +    struct Scsi_Host *host = sdp->host;
>> variable locality
>>>       int dbd;
>>>       int modepage;
>>> @@ -2660,7 +2661,10 @@ static int sd_try_rc16_first(struct
>>> scsi_device *sdp)
>>>           dbd = 8;
>>>       } else {
>>>           modepage = 8;
>>> -        dbd = 0;
>>> +        if (host->set_dbd_for_caching)
>>> +            dbd = 8;
>>> +        else
>>> +            dbd = 0;
>>>       }
>>
>> This simplifies to:
>>
>> -   } else if (sdp->type == TYPE_RBC) {
>>
>> +    } else if (sdp->type == TYPE_RBC ||
>> sdp->host->set_dbd_for_caching) {
>
> IDK what happened with my mailer sending out an older infant copy
> (blame on fumble fingers). My final copy was instead the
> simplification:
>
> +    dbd = sdp->host->set_dbd_for_caching ? 8 : 0;

Thank you for your review.

Regards,
Can Guo