mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Hannes Reinecke <hare@suse.com>,
	 "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 "Martin K. Petersen" <mkp@kernel.org>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	 llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
	Ian Rogers <irogers@google.com>
Subject: [PATCH v2] scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT
Date: Sat, 21 Nov 2026 20:53:10 -0800	[thread overview]
Message-ID: <20261122045310.17980-1-irogers@google.com> (raw)

In ahc_linux_run_command(), the untagged queue throttling check tests
'(ahc->features & AHC_SCB_BTT) == 0'. However, AHC_SCB_BTT (0x40000) is
an ahc_flag bit stored in ahc->flags (and tested via ahc->flags at all
17 other sites across aic7xxx), whereas ahc->features has type
ahc_feature where bit 0x40000 is AHC_MULTIROLE, which is never set on
any controller.

Until now, '(ahc->features & AHC_SCB_BTT) == 0' was always true, which
serialized untagged commands across the whole target via
ahc->untagged_queues and masked a second omission from commit
e4e360c325c9 ("[SCSI] remove aic7xxx busyq"): ahc_platform_set_tags()
sets queue_depth to 2 for untagged devices ("even though we can only
execute them serially on the controller/device"), while SCB_64_BTT only
stores one SCB tag per (target, LUN) slot. In addition, sdev->simple_tags
remains set on SCSI-2+ devices even when aic7xxx disables tagging on dev
(clearing AHC_DEV_Q_BASIC | AHC_DEV_Q_TAGGED).

Check both !(cmd->flags & SCMD_TAGGED) and
(dev->flags & (AHC_DEV_Q_BASIC | AHC_DEV_Q_TAGGED)) == 0, return
SCSI_MLQUEUE_DEVICE_BUSY when dev->active != 0 so untagged commands are
serialized per LUN, and test ahc->flags instead of ahc->features for
AHC_SCB_BTT so controllers with SCB-space busy-target tables can still
issue untagged commands to different LUNs of a target concurrently.

Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wenum-enum-conversion enabled; fix and changelog drafted with an AI
coding assistant. Build-tested under LLVM=1 W=1 (-Werror) and
-Wenum-enum-conversion; not tested on Adaptec Parallel SCSI hardware.

Fixes: e4e360c325c9 ("[SCSI] remove aic7xxx busyq")
Signed-off-by: Ian Rogers <irogers@google.com>
---

Notes:
    v2:
      - Serialize untagged commands per LUN via 'dev->active != 0' (and cover
        devices where AHC_DEV_Q_BASIC | AHC_DEV_Q_TAGGED is clear despite
        SCMD_TAGGED) so queue_depth == 2 cannot dispatch two concurrent
        untagged SCBs to the same (target, LUN) slot when AHC_SCB_BTT is set
        (caught by Sashiko review on v1).
    
    v1: https://lore.kernel.org/r/20261119170605.1518761-1-irogers@google.com

 drivers/scsi/aic7xxx/aic7xxx_osm.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d93b522695eb..af5782a63155 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1429,18 +1429,26 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
 	 * We only allow one untagged transaction
 	 * per target in the initiator role unless
 	 * we are storing a full busy target *lun*
-	 * table in SCB space.
+	 * table in SCB space, in which case we
+	 * allow one untagged transaction per lun.
 	 */
-	if (!(cmd->flags & SCMD_TAGGED)
-	    && (ahc->features & AHC_SCB_BTT) == 0) {
-		int target_offset;
-
-		target_offset = cmd->device->id + cmd->device->channel * 8;
-		untagged_q = &(ahc->untagged_queues[target_offset]);
-		if (!TAILQ_EMPTY(untagged_q))
-			/* if we're already executing an untagged command
-			 * we're busy to another */
+	if (!(cmd->flags & SCMD_TAGGED) ||
+	    (dev->flags & (AHC_DEV_Q_BASIC | AHC_DEV_Q_TAGGED)) == 0) {
+		if (dev->active != 0)
 			return SCSI_MLQUEUE_DEVICE_BUSY;
+		if ((ahc->flags & AHC_SCB_BTT) == 0) {
+			int target_offset;
+
+			target_offset = cmd->device->id + cmd->device->channel * 8;
+			untagged_q = &(ahc->untagged_queues[target_offset]);
+			if (!TAILQ_EMPTY(untagged_q)) {
+				/*
+				 * If we're already executing an untagged
+				 * command we're busy to another.
+				 */
+				return SCSI_MLQUEUE_DEVICE_BUSY;
+			}
+		}
 	}
 
 	nseg = scsi_dma_map(cmd);
-- 
2.56.1.750.gf70dc682cf-goog


                 reply	other threads:[~2026-11-22  4:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261122045310.17980-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=elkin@google.com \
    --cc=hare@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mkp@kernel.org \
    /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

all inboxes | Powered by JetHome®