mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ 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] 4+ 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
  2026-11-22 13:17 ` [PATCH 0/2] ALSA: firewire: Don't loop forever " Takashi Sakamoto
  2 siblings, 0 replies; 4+ 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] 4+ 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
  2026-11-22 13:17 ` [PATCH 0/2] ALSA: firewire: Don't loop forever " Takashi Sakamoto
  2 siblings, 0 replies; 4+ 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] 4+ messages in thread

* Re: [PATCH 0/2] ALSA: firewire: Don't loop forever 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 ` [PATCH 2/2] ALSA: fireworks: Rearm the " Suyuan Wang via B4 Relay
@ 2026-11-22 13:17 ` Takashi Sakamoto
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2026-11-22 13:17 UTC (permalink / raw)
  To: shyckless; +Cc: tiwai, linux-sound, perex, linux-kernel

Hi,

Thanks for the patch.

On Fri, Nov 20, 2026 at 05:38:04AM +0000, Suyuan Wang via B4 Relay wrote:
> 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(+)

I had a look at IEC 61883-1, but it does not specify any particular
requirements for handling bus resets during an FCP transaction.

However, I found the following statement in `AV/C Digital Interface
Command Set General Specification Version 4.2 (1394 Trading Association,
2004. Document number 200406)`:

 * If the target detects a Serial Bus reset, it shall reset its state to
   be able to accept AV/C command frames. In this case, any in progress
   AV/C transactions shall be discarded without the return of a response
   frame.

Although the function that issues fcp_avc_transaction() acts as a peer of
the target, I think it would be safer to abort any pending transactions
as well when a bus reset is detected. Since the bus reset would initialize
the part of device state, the initiator should also restart the entire
transaction sequence.

I would expect Echo Audio's Fireworks transactions to follow the behavior
described in the above specification, since Fireworks also supports some
AV/C commands

Could you revise the patch to abort any pending transactions when a bus
reset is detected? Returning -EAGAIN to the callers would be reasonable
in this case.


Thanks

Takashi Sakamoto

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

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

Thread overview: 4+ 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
2026-11-22 13:17 ` [PATCH 0/2] ALSA: firewire: Don't loop forever " Takashi Sakamoto

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®