Skip to contentSkip to conversation

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

PATCH New Ian Rogers 2 participants 2 messages Nov 19

Subsystems (2)
lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 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.

As a result, the condition is always true even when SCB-space busy-target tables are active, needlessly serializing untagged commands per target and mismatching the untagged_queues accounting elsewhere in the driver.

Test ahc->flags instead of ahc->features.

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")
---
 drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -1
index d93b522695eb..e12ee18a18d5 100644
@@ -1432,7 +1432,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
 	 * table in SCB space.
 	 */
 	if (!(cmd->flags & SCMD_TAGGED)
-	    && (ahc->features & AHC_SCB_BTT) == 0) {
+	    && (ahc->flags & AHC_SCB_BTT) == 0) {
 		int target_offset;
 
 		target_offset = cmd->device->id + cmd->device->channel * 8;
Signature · 1 line
2.56.1.708.g77570a6a1d-goog
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] scsi: aic7xxx: missing per-LUN untagged limit in ahc_linux_run_command() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] scsi: aic7xxx: missing per-LUN untagged limit in ahc_linux_run_command()
--

commit ec21efc91528b4a71de5b706f48c1434b9f8f837
Author: Ian Rogers <[email protected]>

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

This commit changes the untagged queue throttling check in ahc_linux_run_command() to test ahc->flags instead of ahc->features for AHC_SCB_BTT.

drivers/scsi/aic7xxx/aic7xxx_osm.c ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, · line 1438

Quoted 13 lines
drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -1
index d93b522695eba..e12ee18a18d5f 100644
@@ -1432,7 +1432,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
 	 * table in SCB space.
 	 */
 	if (!(cmd->flags & SCMD_TAGGED)
-	    && (ahc->features & AHC_SCB_BTT) == 0) {
+	    && (ahc->flags & AHC_SCB_BTT) == 0) {
 		int target_offset;
 
 		target_offset = cmd->device->id + cmd->device->channel * 8;

[Severity: High]
Can this dispatch two concurrent untagged commands to the same target and LUN when AHC_SCB_BTT is set?

ahc_platform_set_tags() sets queue_depth to 2 for untagged devices:

drivers/scsi/aic7xxx/aic7xxx_osm.c:ahc_platform_set_tags() {
    ...
	default:
		/*
		 * We allow the OS to queue 2 untagged transactions to
		 * us at any time even though we can only execute them
		 * serially on the controller/device.  This should
		 * remove some latency.
		 */
		scsi_change_queue_depth(sdev, 2);
		break;
}

When e4e360c325c9 ("[SCSI] remove aic7xxx busyq") removed the per-device busyq, it also dropped the dev->openings check that serialized untagged commands per LUN; ahc_linux_run_command() decrements dev->openings and increments dev->active without checking either first. Until now that was masked because (ahc->features & AHC_SCB_BTT) == 0 was always true, so ahc->untagged_queues serialized untagged commands across the whole target.

The SCB-space busy target table (SCB_64_BTT) only holds one SCB tag per (target, LUN) slot to allow concurrent untagged commands across different LUNs of a target. Without a per-LUN check (such as returning SCSI_MLQUEUE_DEVICE_BUSY when dev->active != 0 for an untagged command, or limiting untagged queue_depth to 1), bypassing untagged_queues sends a second untagged SCB for the same (target, LUN) to ahc_queue_scb(), overlapping untagged commands on the bus and overwriting the SCB_64_BTT slot on disconnect.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1