Skip to contentSkip to conversation

scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT

PATCH New Ian Rogers 1 participant 1 message Nov 22

Subsystems (2)
lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH v2 1/1 scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT

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")

---

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/[email protected]

 drivers/scsi/aic7xxx/aic7xxx_osm.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_osm.c +18 -10
index d93b522695eb..af5782a63155 100644
@@ -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);
Signature · 1 line
2.56.1.750.gf70dc682cf-goog