All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	"James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-usb@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 36/37] ata: libata: use 16-bits defined sense codes
Date: Thu, 3 Sep 2026 08:48:03 +0900	[thread overview]
Message-ID: <d2d31879-b01f-4af3-836c-d0372f90c26d@kernel.org> (raw)
In-Reply-To: <apgIfRr9MjNov6FV@ryzen>

On 9/2/26 20:29, Niklas Cassel wrote:
>> +		if (ata_scsi_sense_is_valid(tf.lbah, sense_code)) {
>>  			/* Set sense without also setting scsicmd->result */
>> -			scsi_build_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE,
>> -						cmd->sense_buffer, tf.lbah,
>> -						tf.lbam, tf.lbal);
>> +			scsi_set_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE,
>> +					      cmd->sense_buffer, tf.lbah,
>> +					      sense_code);
> 
> However, here you call scsi_set_sense_buffer() which is just an inline
> function that calls:
> scsi_build_sense_buffer(desc, buf, key, scsi_sense_code_asc(code),
> 			scsi_sense_code_ascq(code));
> 
> which will call scsi_sense_code_asc() and scsi_sense_code_ascq() to
> split sense_code to asc and ascq again.

Yes. I considered keeping the original call to scsi_build_sense_buffer() but
went with using scsi_set_sense_buffer() to be consistent with the fact that we
have the 16-bits sense_code and to try to stick with using it as much as we can.
I do understand that this is a bit silly to combined and split again the
asc/ascq, but this is all done only if there is a sense, meaning there was an
error and so things went through EH already and thus have been slow anyway. So I
do not see this as a perf problem at all and prefer to priviledge
readability/code simplicity.

> It seems that you series has decided to not kill scsi_build_sense_buffer().
> 
> As long as scsi_build_sense_buffer() exists, and since we already have asc
> and ascq stored in separate variables, I think we should let this code
> continue calling scsi_build_sense_buffer().
> 
> Especially since, even after this series, we still will have a call to
> scsi_build_sense_buffer() in libata-sata.c:ata_eh_get_ncq_success_sense().
> 
> I think either this function and ata_eh_get_ncq_success_sense() should both
> call scsi_build_sense_buffer(), or both should call scsi_set_sense_buffer().
> 
> Is there a reason why you don't convert all scsi_build_sense_buffer() users
> to scsi_set_sense_buffer() and drop scsi_build_sense_buffer() ?

The target code (and ATA code) fill the sense buffer from asc and ascq obtained
directly from command results, not from a sense code. So I kept that function to
avoid doing the combine/split asc/ascq everywhere. This is not great: blame the
scsi specs that define asc/ascq as separate fields while the sense codes are
essentially defined as a 16-bits value combining both :)

> You could even keep the same function name (scsi_build_sense_buffer()) and
> just have it take an u16 sense_code instead of u8 asc + u8 ascq?

Yeah, I wanted to, but that would mean having a single gigantic patch that
change the function use is all scsi and ata code in one go. I did not want to do
that to facilitate review. But if that's the preferred path, I will do that.

> (Doing a git grep scsi_build_sense_buffer shows a few users even after this
> series.)

Yes, I can completely drop it if everyone is OK with a few unnecessary
combine/split asc/ascq in some places.

-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-09-02 23:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  2:04 [PATCH 00/37] Use defined 16-bits ASC/ASCQ combinations Damien Le Moal
2026-08-31  2:04 ` [PATCH 01/37] scsi: define all additional sense codes and their qualifiers Damien Le Moal
2026-08-31  2:04 ` [PATCH 02/37] scsi: constants: use defined sense codes Damien Le Moal
2026-08-31  2:04 ` [PATCH 03/37] scsi: constants: rename internal struct field names Damien Le Moal
2026-08-31  2:04 ` [PATCH 04/37] scsi: rename sense field of struct scsi_failure Damien Le Moal
2026-08-31  2:17   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 05/37] scsi: prepare for using 16-bits defined sense codes Damien Le Moal
2026-08-31  2:04 ` [PATCH 06/37] scsi: use struct scsi_sense_hdr to log sense keys and codes Damien Le Moal
2026-08-31  2:04 ` [PATCH 07/37] scsi: core: use 16-bits defined sense codes Damien Le Moal
2026-08-31  2:18   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 08/37] scsi: sd: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 09/37] scsi: sr: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 10/37] scsi: ses: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 11/37] scsi: ch: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 12/37] scsi: st: " Damien Le Moal
2026-08-31  2:19   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 13/37] scsi: device_handlers: hp_sw: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 14/37] scsi: device_handlers: rdac: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 15/37] scsi: device_handlers: emc: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 16/37] scsi: device_handlers: alua: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 17/37] scsi: mpt3sas: " Damien Le Moal
2026-08-31  2:19   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 18/37] scsi: mpi3mr: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 19/37] scsi: 3w-xxxx: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 20/37] scsi: leapraid: " Damien Le Moal
2026-08-31  2:18   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 21/37] scsi: megaraid: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 22/37] scsi: myrX: " Damien Le Moal
2026-08-31  2:30   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 23/37] scsi: smartpqi: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 24/37] scsi: qla2xxx: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 25/37] scsi: ps3rom: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 26/37] scsi: lpfc: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 27/37] scsi: stex: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 28/37] scsi: mvumi: " Damien Le Moal
2026-08-31  2:24   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 29/37] scsi: libiscsi: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 30/37] scsi: ibmvscsi_tgt: " Damien Le Moal
2026-08-31  2:27   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 31/37] scsi: scsi_debug: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 32/37] scsi: hpsa: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 33/37] scsi: storvsc: " Damien Le Moal
2026-08-31  2:27   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 34/37] usb: storage: " Damien Le Moal
2026-08-31  2:04 ` [PATCH 35/37] cdrom: " Damien Le Moal
2026-08-31  2:29   ` sashiko-bot
2026-08-31  2:04 ` [PATCH 36/37] ata: libata: " Damien Le Moal
2026-09-02 11:29   ` Niklas Cassel
2026-09-02 23:48     ` Damien Le Moal [this message]
2026-08-31  2:04 ` [PATCH 37/37] scsi: cleanup scsi_proto.h Damien Le Moal
2026-08-31  2:31   ` sashiko-bot
2026-08-31  2:36 ` [PATCH 00/37] Use defined 16-bits ASC/ASCQ combinations 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=d2d31879-b01f-4af3-836c-d0372f90c26d@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=cassel@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.