* [PATCH 0/2] ALSA: firewire: Don't loop forever after a bus reset
@ 2026-11-20 5:38 Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 1/2] ALSA: firewire-lib: Rearm the FCP transaction " Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 2/2] ALSA: fireworks: Rearm the " Suyuan Wang via B4 Relay
0 siblings, 2 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-20 5:38 UTC (permalink / raw)
To: clemens, o-takashi, tiwai; +Cc: stefanr, linux-sound, perex, linux-kernel
fcp_avc_transaction() and snd_efw_transaction_run() resend their
command after a bus reset but never move the transaction back to
STATE_PENDING. The response to the resent command is then ignored and
the wait returns immediately, so both loops keep resending the command
after each ERROR_DELAY_MS pause, without a retry limit, until sending
fails.
Each patch sets the state back to STATE_PENDING before resending.
Found with a static analysis tool and checked by hand. Compile tested
only (x86_64, W=1); I don't have FireWire audio hardware.
---
Suyuan Wang (2):
ALSA: firewire-lib: Rearm the FCP transaction after a bus reset
ALSA: fireworks: Rearm the transaction after a bus reset
sound/firewire/fcp.c | 2 ++
sound/firewire/fireworks/fireworks_transaction.c | 2 ++
2 files changed, 4 insertions(+)
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/2] ALSA: firewire-lib: Rearm the FCP transaction after a bus reset
2026-11-20 5:38 [PATCH 0/2] ALSA: firewire: Don't loop forever after a bus reset Suyuan Wang via B4 Relay
@ 2026-11-20 5:38 ` Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 2/2] ALSA: fireworks: Rearm the " Suyuan Wang via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-20 5:38 UTC (permalink / raw)
To: clemens, o-takashi, tiwai; +Cc: stefanr, linux-sound, perex, linux-kernel
From: Suyuan Wang <stevewong@hust.edu.cn>
When a bus reset happens while fcp_avc_transaction() waits for a
response, fcp_bus_reset() moves the transaction to STATE_BUS_RESET and
wakes the waiter, which sleeps and then sends the command again.
Nothing sets the state back to STATE_PENDING, though:
wait_event_timeout(t.wait, t.state != STATE_PENDING, ...);
...
} else if (t.state == STATE_BUS_RESET) {
msleep(ERROR_DELAY_MS);
}
fcp_response() only accepts a response for a transaction in
STATE_PENDING, so the response to the resent command is ignored, and
wait_event_timeout() returns at once because the state is still
STATE_BUS_RESET. The loop then resends the command every
ERROR_DELAY_MS without counting tries, and the caller never returns
unless sending the command itself fails.
Set the state back to STATE_PENDING before resending, as the
STATE_DEFERRED branch already does.
Found with a static analysis tool and checked by hand.
Fixes: 31ef9134eb52 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
sound/firewire/fcp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c
index e60bfd0ee4ac..d733f6123baa 100644
--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -273,6 +273,8 @@ int fcp_avc_transaction(struct fw_unit *unit,
break;
} else if (t.state == STATE_BUS_RESET) {
msleep(ERROR_DELAY_MS);
+ /* resend the command and wait for its response again */
+ t.state = STATE_PENDING;
} else if (++tries >= ERROR_RETRIES) {
dev_err(&t.unit->device, "FCP command timed out\n");
ret = -EIO;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] ALSA: fireworks: Rearm the transaction after a bus reset
2026-11-20 5:38 [PATCH 0/2] ALSA: firewire: Don't loop forever after a bus reset Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 1/2] ALSA: firewire-lib: Rearm the FCP transaction " Suyuan Wang via B4 Relay
@ 2026-11-20 5:38 ` Suyuan Wang via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-20 5:38 UTC (permalink / raw)
To: clemens, o-takashi, tiwai; +Cc: stefanr, linux-sound, perex, linux-kernel
From: Suyuan Wang <stevewong@hust.edu.cn>
snd_efw_transaction_run() has the same problem as fcp_avc_transaction():
after snd_efw_transaction_bus_reset() moves the transaction to
STATE_BUS_RESET, the loop sleeps and resends the command but leaves the
state as it is. The response handler only completes a transaction in
STATE_PENDING, and wait_event_timeout() returns at once on the stale
state, so the command is resent every ERROR_DELAY_MS without counting
tries and the caller never returns unless sending fails.
Set the state back to STATE_PENDING before resending.
Found with a static analysis tool and checked by hand.
Fixes: bde8a8f23bbe ("ALSA: fireworks: Add transaction and some commands")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
sound/firewire/fireworks/fireworks_transaction.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
index 5c859773fe06..57aef570ac2d 100644
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -100,6 +100,8 @@ int snd_efw_transaction_run(struct fw_unit *unit,
break;
} else if (t.state == STATE_BUS_RESET) {
msleep(ERROR_DELAY_MS);
+ /* resend the command and wait for its response again */
+ t.state = STATE_PENDING;
} else if (++tries >= ERROR_RETRIES) {
dev_err(&t.unit->device, "EFW transaction timed out\n");
ret = -EIO;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 5:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 5:38 [PATCH 0/2] ALSA: firewire: Don't loop forever after a bus reset Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 1/2] ALSA: firewire-lib: Rearm the FCP transaction " Suyuan Wang via B4 Relay
2026-11-20 5:38 ` [PATCH 2/2] ALSA: fireworks: Rearm the " Suyuan Wang via B4 Relay
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®