Linux ATA/IDE development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org, cassel@kernel.org
Subject: Re: [PATCH v2 2/5] ata: libata-scsi: refactor ata_scsi_report_supported_opcodes()
Date: Thu, 02 Jul 2026 06:53:20 +0000	[thread overview]
Message-ID: <20260702065321.07EB51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702063412.1892584-3-dlemoal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] WRITE_SAME_16 is unconditionally reported as supported via REPORT SUPPORTED OPERATION CODES, even for devices that do not support TRIM.
--

commit b8e6e9f4e6e3177fe0e766704af6b504468c2de3
Author: Damien Le Moal <dlemoal@kernel.org>

ata: libata-scsi: refactor ata_scsi_report_supported_opcodes()

This commit refactors ata_scsi_report_supported_opcodes() to use an array
of supported commands for easier modifications and extensions. It also adds
handling for WRITE_SAME_16 and VARIABLE_LENGTH_CMD to the list of commands
which libata-scsi translates.

> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 8811bfc373697..4f0ae44f59dd2 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
[ ... ]
> +static bool ata_scsi_cmd_is_supported(struct ata_device *dev, u8 op,
> +				      struct ata_scsi_cmd_support *sup)
> +{
> +	const struct ata_scsi_cmd *cmd;
> +
> +	/* First, see if we support the command. */
> +	cmd = ata_scsi_get_supported_cmd(op);
> +	if (!cmd)
> +		return false;
> +
> +	/* Now refine the support report depending on the device features. */
> +	memset(sup, 0, sizeof(*sup));
> +	switch (op) {
> +	case READ_16:
[ ... ]
> +	case ZBC_IN:
> +	case ZBC_OUT:
> +		return ata_dev_is_zoned(dev);
> +	case SECURITY_PROTOCOL_IN:
> +	case SECURITY_PROTOCOL_OUT:
> +		return dev->flags & ATA_DFLAG_TRUSTED;
> +	default:
> +		break;
> +	}
> +
> +	return true;
> +}

[Severity: Medium]
Should WRITE_SAME_16 be refined here to check for TRIM support?

The commit message mentions adding WRITE_SAME_16 to the supported array,
so it falls through to the default case in this switch statement and
unconditionally returns true.

However, looking at ata_scsi_write_same_xlat(), the command is unconditionally
rejected if the device lacks TRIM capabilities:

ata_scsi_write_same_xlat()
    ...
    if (!unmap || (dev->quirks & ATA_QUIRK_NOTRIM) ||
        !ata_id_has_trim(dev->id)) {
        fp = 1;
        bp = 3;
        goto invalid_fld;
    }

Does this cause the report supported operation codes query to incorrectly
inform the SCSI layer that WRITE_SAME_16 is supported on ATA devices that
do not actually support TRIM?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702063412.1892584-1-dlemoal@kernel.org?part=2

  parent reply	other threads:[~2026-07-02  6:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  6:34 [PATCH v2 0/5] Improve ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:34 ` [PATCH v2 1/5] ata: libata: rename ata_dev_is_zac() Damien Le Moal
2026-07-02  6:38   ` Hannes Reinecke
2026-07-02  7:16   ` sashiko-bot
2026-07-02  6:34 ` [PATCH v2 2/5] ata: libata-scsi: refactor ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:44   ` Hannes Reinecke
2026-07-02  7:01     ` Damien Le Moal
2026-07-02  6:53   ` sashiko-bot [this message]
2026-07-02 13:25     ` Niklas Cassel
2026-07-02 14:36       ` Niklas Cassel
2026-07-02 14:48         ` Christoph Hellwig
2026-07-02 14:53           ` Niklas Cassel
2026-07-02  6:34 ` [PATCH v2 3/5] ata: libata-scsi: improve service action support in ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:45   ` Hannes Reinecke
2026-07-02  6:47   ` sashiko-bot
2026-07-02  6:34 ` [PATCH v2 4/5] ata: libata-scsi: support reporting options 2 in REPORT SUPPORTED OPERATION CODES Damien Le Moal
2026-07-02  6:46   ` Hannes Reinecke
2026-07-02  6:52   ` sashiko-bot
2026-07-02  7:00     ` Damien Le Moal
2026-07-02 11:41       ` Niklas Cassel
2026-07-02  6:53   ` Hannes Reinecke
2026-07-02  6:34 ` [PATCH v2 5/5] ata: libata-scsi: support the all command format for reporting supported commands Damien Le Moal
2026-07-02  6:54   ` Hannes Reinecke

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=20260702065321.07EB51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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