Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: Niklas Cassel <Niklas.Cassel@wdc.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 11/25] scsi: move get_scsi_ml_byte() to scsi_priv.h
Date: Thu, 29 Dec 2022 12:55:47 -0600	[thread overview]
Message-ID: <8319d269-42b5-80ef-f103-ae9537d4f6b2@oracle.com> (raw)
In-Reply-To: <Y6yp7G5WEWOwe+DB@x1-carbon>

On 12/28/22 2:41 PM, Niklas Cassel wrote:
> On Thu, Dec 08, 2022 at 05:58:01PM -0600, Mike Christie wrote:
>> On 12/8/22 4:59 AM, Niklas Cassel wrote:
>>> Move get_scsi_ml_byte() to scsi_priv.h since both scsi_lib.c and
>>> scsi_error.c will need to use this helper in a follow-up patch.
>>>
>>> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
>>> ---
>>>  drivers/scsi/scsi_lib.c  | 5 -----
>>>  drivers/scsi/scsi_priv.h | 5 +++++
>>>  2 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
>>> index 9ed1ebcb7443..d243ebc5ad54 100644
>>> --- a/drivers/scsi/scsi_lib.c
>>> +++ b/drivers/scsi/scsi_lib.c
>>> @@ -579,11 +579,6 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
>>>  	return false;
>>>  }
>>>  
>>> -static inline u8 get_scsi_ml_byte(int result)
>>> -{
>>> -	return (result >> 8) & 0xff;
>>> -}
>>> -
>>>  /**
>>>   * scsi_result_to_blk_status - translate a SCSI result code into blk_status_t
>>>   * @result:	scsi error code
>>> diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
>>> index 96284a0e13fe..4f97e126c6fb 100644
>>> --- a/drivers/scsi/scsi_priv.h
>>> +++ b/drivers/scsi/scsi_priv.h
>>> @@ -29,6 +29,11 @@ enum scsi_ml_status {
>>>  	SCSIML_STAT_TGT_FAILURE		= 0x04,	/* Permanent target failure */
>>>  };
>>>  
>>> +static inline u8 get_scsi_ml_byte(int result)
>>> +{
>>> +	return (result >> 8) & 0xff;
>>> +}
>>> +
>>
>> I made a mistake in the naming of this function. The get_* functions take a
>> scsi_cmnd. The ones without the "get_" prefix take the scsi_cmnd->result.
>>
>> Could you rename it to scsi_ml_byte() when you move it so the mistake does not
>> get used in multiple places?
> 
> Hello Mike,
> 
> In scsi.h we have:
> #define status_byte(result) (result & 0xff)
> #define host_byte(result)   (((result) >> 16) & 0xff)
> 
> In scsi_cmnd.h we have:
> static inline u8 get_status_byte(struct scsi_cmnd *cmd)
> static inline u8 get_host_byte(struct scsi_cmnd *cmd)
> 
> So I see your point.
> 
> 
> I understand that you intentionally didn't put the ML byte getter in scsi.h,
> as you intentionally didn't want a LLDD to be able to get the SCSI ML byte.
> 
> However, isn't the important thing that that a LLDD can't *set* the SCSI ML
> byte?
> Does it really matter if a LLDD can *get* the SCSI ML byte?

We don't want LLDDs to get the ml byte and do something with it because I think
it's kind of just a hack to avoid parsing the result/sense multiple times, and
the drivers have no need for accessing it.

If you put it in scsi_cmnd.h they can still do:

if (get_scsi_ml_byte(cmd))
	do something;

which we don't want.


  reply	other threads:[~2022-12-29 18:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 10:59 [PATCH 00/25] Add Command Duration Limits support Niklas Cassel
2022-12-08 10:59 ` [PATCH 01/25] ata: scsi: rename flag ATA_QCFLAG_FAILED to ATA_QCFLAG_EH Niklas Cassel
2022-12-21 11:47   ` John Garry
2022-12-08 10:59 ` [PATCH 02/25] ata: libata: move NCQ related ATA_DFLAGs Niklas Cassel
2022-12-08 10:59 ` [PATCH 03/25] ata: libata: simplify qc_fill_rtf port operation interface Niklas Cassel
2022-12-21 11:48   ` John Garry
2022-12-08 10:59 ` [PATCH 04/25] ata: libata: fix broken NCQ command status handling Niklas Cassel
2022-12-08 10:59 ` [PATCH 05/25] ata: libata: respect successfully completed commands during errors Niklas Cassel
2022-12-08 10:59 ` [PATCH 06/25] ata: libata: allow ata_scsi_set_sense() to not set CHECK_CONDITION Niklas Cassel
2022-12-08 10:59 ` [PATCH 07/25] ata: libata: allow ata_eh_request_sense() " Niklas Cassel
2022-12-08 10:59 ` [PATCH 08/25] ata: libata-scsi: do not overwrite SCSI ML and status bytes Niklas Cassel
2022-12-08 10:59 ` [PATCH 09/25] ata: libata-scsi: improve ata_scsiop_maint_in() Niklas Cassel
2022-12-08 10:59 ` [PATCH 10/25] scsi: core: allow libata to complete successful commands via EH Niklas Cassel
2022-12-08 10:59 ` [PATCH 11/25] scsi: move get_scsi_ml_byte() to scsi_priv.h Niklas Cassel
2022-12-08 23:58   ` Mike Christie
2022-12-28 20:41     ` Niklas Cassel
2022-12-29 18:55       ` Mike Christie [this message]
2022-12-29 20:19         ` Niklas Cassel
2022-12-08 10:59 ` [PATCH 12/25] scsi: support retrieving sub-pages of mode pages Niklas Cassel
2022-12-08 10:59 ` [PATCH 13/25] scsi: support service action in scsi_report_opcode() Niklas Cassel
2022-12-08 10:59 ` [PATCH 14/25] block: introduce duration-limits priority class Niklas Cassel
2022-12-08 10:59 ` [PATCH 15/25] block: introduce BLK_STS_DURATION_LIMIT Niklas Cassel
2022-12-08 10:59 ` [PATCH 16/25] ata: libata: detect support for command duration limits Niklas Cassel
2022-12-08 10:59 ` [PATCH 17/25] ata: libata-scsi: handle CDL bits in ata_scsiop_maint_in() Niklas Cassel
2022-12-08 10:59 ` [PATCH 18/25] ata: libata-scsi: add support for CDL pages mode sense Niklas Cassel
2022-12-08 10:59 ` [PATCH 19/25] ata: libata: add ATA feature control sub-page translation Niklas Cassel
2022-12-08 10:59 ` [PATCH 20/25] ata: libata: set read/write commands CDL index Niklas Cassel
2022-12-08 10:59 ` [PATCH 21/25] scsi: sd: detect support for command duration limits Niklas Cassel
2022-12-08 10:59 ` [PATCH 22/25] scsi: sd: set read/write commands CDL index Niklas Cassel
2022-12-08 10:59 ` [PATCH 23/25] scsi: sd: handle read/write CDL timeout failures Niklas Cassel
2022-12-09  0:13   ` Mike Christie
2022-12-09  0:26     ` Damien Le Moal
2022-12-08 10:59 ` [PATCH 24/25] ata: libata: handle completion of CDL commands using policy 0xD Niklas Cassel
2022-12-08 10:59 ` [PATCH 25/25] Documentation: sysfs-block-device: document command duration limits Niklas Cassel
2022-12-09  3:22   ` Bagas Sanjaya
2022-12-09  3:31     ` Damien Le Moal
2022-12-08 18:18 ` [PATCH 00/25] Add Command Duration Limits support Chaitanya Kulkarni
2022-12-09  0:29   ` 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=8319d269-42b5-80ef-f103-ae9537d4f6b2@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=Niklas.Cassel@wdc.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --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