Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT
@ 2026-11-19 17:06 Ian Rogers
  2026-11-19 17:19 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2026-11-19 17:06 UTC (permalink / raw)
  To: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel, llvm, Elkin Cruz, Ian Rogers

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")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d93b522695eb..e12ee18a18d5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -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;
-- 
2.56.1.708.g77570a6a1d-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT
  2026-11-19 17:06 [PATCH] scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT Ian Rogers
@ 2026-11-19 17:19 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-19 17:19 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-scsi

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 <irogers@google.com>

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.

> diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> index d93b522695eba..e12ee18a18d5f 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> @@ -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.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119170605.1518761-1-irogers@google.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 17:06 [PATCH] scsi: aic7xxx: Check ahc->flags instead of ahc->features for AHC_SCB_BTT Ian Rogers
2026-11-19 17:19 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox