From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@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: Wed, 2 Sep 2026 13:29:01 +0200 [thread overview]
Message-ID: <apgIfRr9MjNov6FV@ryzen> (raw)
In-Reply-To: <20260831020451.585944-37-dlemoal@kernel.org>
On Mon, Aug 31, 2026 at 11:04:50AM +0900, Damien Le Moal wrote:
> Refactor libata core code to use the 16-bits sense_code field of
> struct scsi_sense_hdr and replace all hard-coded additional sense codes
> and additional sense code qualifiers with the enum values defined in
> include/scsi/scsi_sense.h. This helps with code clarity as the sense codes
> being processed are easier to test and self-documented.
>
> No functional change intended.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> drivers/ata/libata-eh.c | 13 +-
> drivers/ata/libata-sata.c | 14 +-
> drivers/ata/libata-scsi.c | 346 +++++++++++++++++++++++---------------
> drivers/ata/libata.h | 5 +-
> 4 files changed, 226 insertions(+), 152 deletions(-)
>
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index c93c24b22d9c..71961fbaa42f 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -1516,11 +1516,13 @@ static bool ata_eh_request_sense(struct ata_queued_cmd *qc)
> err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
> /* Ignore err_mask; ATA_ERR might be set */
> if (tf.status & ATA_SENSE) {
> - if (ata_scsi_sense_is_valid(tf.lbah, tf.lbam, tf.lbal)) {
> + u16 sense_code = scsi_sense_code(tf.lbam, tf.lbal);
Here you take asc and ascq and combine them to one.
I see the reason, since ata_scsi_sense_is_valid() takes a u16 sense code.
That is fine, and I think makes ata_scsi_sense_is_valid() easier to read.
> +
> + 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.
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() ?
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?
(Doing a git grep scsi_build_sense_buffer shows a few users even after this
series.)
Kind regards,
Niklas
next prev parent reply other threads:[~2026-09-02 11:29 UTC|newest]
Thread overview: 51+ 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 [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=apgIfRr9MjNov6FV@ryzen \
--to=cassel@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=dlemoal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox