From: Damien Le Moal <dlemoal@kernel.org>
To: linux-ide@vger.kernel.org, Niklas Cassel <cassel@kernel.org>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: [PATCH v1 4/9] ata: libata-scsi: improve ata_get_xlat_func
Date: Mon, 6 Jul 2026 15:56:05 +0900 [thread overview]
Message-ID: <20260706065610.3559692-5-dlemoal@kernel.org> (raw)
In-Reply-To: <20260706065610.3559692-1-dlemoal@kernel.org>
ata_get_xlat_func() is given only the opcode of a SCSI command to
determine the ATA command to translate to. This makes it impossible to
translate SCSI commands such as SERVICE ACTION IN which need a service
action field to fully specify the command.
In preparation for supporting the translation of the SERVICE ACTION IN
command with service actions different from the SAI_READ_CAPACITY_16 (READ
CAPACITY 16), change ata_get_xlat_func() to take a pointer to a SCSI
command CDB so that all fields of the SCSI command to translate can be
easily inspected.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/ata/libata-scsi.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5cddb63a6bc6..f5c838ca0ce9 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -4606,7 +4606,7 @@ static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc)
/**
* ata_get_xlat_func - check if SCSI to ATA translation is possible
* @dev: ATA device
- * @cmd: SCSI command opcode to consider
+ * @cdb: CDB of the SCSI command to consider
*
* Look up the SCSI command given, and determine whether the
* SCSI command is to be translated or simulated.
@@ -4615,9 +4615,10 @@ static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc)
* Pointer to translation function if possible, %NULL if not.
*/
-static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
+static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev,
+ u8 *cdb)
{
- switch (cmd) {
+ switch (cdb[0]) {
case READ_6:
case READ_10:
case READ_16:
@@ -4748,7 +4749,8 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
struct ata_port *ap)
__must_hold(ap->lock)
{
- u8 scsi_op = scmd->cmnd[0];
+ u8 *cdb = scmd->cmnd;
+ u8 scsi_op = cdb[0];
ata_xlat_func_t xlat_func;
/*
@@ -4768,7 +4770,7 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
if (unlikely(scmd->cmd_len > dev->cdb_len))
goto bad_cdb_len;
- xlat_func = ata_get_xlat_func(dev, scsi_op);
+ xlat_func = ata_get_xlat_func(dev, cdb);
} else if (likely((scsi_op != ATA_16) || !atapi_passthru16)) {
/* relay SCSI command to ATAPI device */
int len = COMMAND_SIZE(scsi_op);
@@ -4784,7 +4786,7 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
if (unlikely(scmd->cmd_len > 16))
goto bad_cdb_len;
- xlat_func = ata_get_xlat_func(dev, scsi_op);
+ xlat_func = ata_get_xlat_func(dev, cdb);
}
if (xlat_func)
--
2.54.0
next prev parent reply other threads:[~2026-07-06 6:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 6:56 [PATCH v1 0/9] ATA support for storage element management commands Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 1/9] scsi: scsi_debug: move ASC and ASCQ definitions to scsi_proto.h Damien Le Moal
2026-07-06 8:29 ` Hannes Reinecke
2026-07-06 8:55 ` Damien Le Moal
2026-07-06 8:44 ` Hannes Reinecke
2026-07-06 9:00 ` Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 2/9] scsi: define depopulation capabilities related service actions Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 3/9] ata: libata: improve the definition of device flags Damien Le Moal
2026-07-06 6:56 ` Damien Le Moal [this message]
2026-07-06 6:56 ` [PATCH v1 5/9] ata: libata-core: detect support for depopulation capabilities Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 6/9] ata: libata-scsi: add support for the GET PHYSICAL ELEMENT STATUS command Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 7/9] ata: libata-scsi: add support for the REMOVE ELEMENT AND TRUNCATE command Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 8/9] ata: libata-scsi: add support for the RESTORE ELEMENTS AND REBUILD command Damien Le Moal
2026-07-06 6:56 ` [PATCH v1 9/9] ata: libata-scsi: add support for the REMOVE ELEMENT AND MODIFY ZONES command 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=20260706065610.3559692-5-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=linux-ide@vger.kernel.org \
--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