ALSA: firewire: Abort transactions on a bus reset
v2 cover ALSA: firewire: Abort transactions on a bus reset
fcp_avc_transaction() and snd_efw_transaction_run() resend their command after a bus reset but never move the transaction back to STATE_PENDING, so both loops keep resending without a retry limit until sending fails.
As Takashi suggested, v2 no longer resends: on a bus reset the transaction is ended and -EAGAIN is returned, following the AV/C general specification, which says that a target discards any transaction in progress on a bus reset.
Found with a static analysis tool and checked by hand. Compile tested only (x86_64, W=1); I don't have FireWire audio hardware.
Changes in v2:
- Abort the transaction and return -EAGAIN on a bus reset instead of rearming it and resending (Takashi).
- Drop ERROR_DELAY_MS (and <linux/delay.h> in fcp.c), now unused.
v1: https://lore.kernel.org/all/[email protected]/
---
Suyuan Wang (2):
ALSA: firewire-lib: Abort the FCP transaction on a bus reset
ALSA: fireworks: Abort the transaction on a bus reset
sound/firewire/fcp.c | 5 ++--- sound/firewire/fireworks/fireworks_transaction.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-)
PATCH v2 1/2 ALSA: firewire-lib: Abort the FCP transaction on a bus reset
From: Suyuan Wang <[email protected]>
When fcp_bus_reset() marks a transaction as STATE_BUS_RESET, fcp_avc_transaction() sleeps and resends the command, but leaves the state as it is. The response to the resent command is then ignored, and the next wait returns at once, so the loop keeps resending the command without a retry limit until sending fails.
The AV/C Digital Interface Command Set General Specification 4.2 says that a target which detects a bus reset discards any AV/C transaction in progress without returning a response. So instead of resending, end the transaction on a bus reset and return -EAGAIN, so that the caller can start the sequence again. ERROR_DELAY_MS and <linux/delay.h> have no users left after this, so drop them.
Found with a static analysis tool and checked by hand.
--- sound/firewire/fcp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/firewire/fcp.c +2 -3
@@ -14,7 +14,6 @@#include <linux/sched.h> #include <linux/spinlock.h> #include <linux/wait.h> -#include <linux/delay.h> #include "fcp.h" #include "lib.h" #include "amdtp-stream.h"
@@ -22,7 +21,6 @@#define CTS_AVC 0x00#define ERROR_RETRIES 3 -#define ERROR_DELAY_MS 5#define FCP_TIMEOUT_MS 125 int avc_general_set_sig_fmt(struct fw_unit *unit, unsigned int rate,
@@ -272,7 +270,8 @@ int fcp_avc_transaction(struct fw_unit *unit, ret = t.response_size;break ; }else if (t.state ==STATE_BUS_RESET ) { -msleep (ERROR_DELAY_MS ); + ret = -EAGAIN ; +break ; }else if (++tries >=ERROR_RETRIES ) {dev_err (&t.unit->device,"FCP command timed out\n" ); ret = -EIO ;
Signature · 1 line
2.34.1
PATCH v2 2/2 ALSA: fireworks: Abort the transaction on a bus reset
In reply to Suyuan WangFrom: Suyuan Wang <[email protected]>
When snd_efw_transaction_bus_reset() marks a transaction as STATE_BUS_RESET, snd_efw_transaction_run() sleeps and resends the command, but leaves the state as it is. The response to the resent command is then ignored, and the next wait returns at once, so the loop keeps resending the command without a retry limit until sending fails.
Fireworks devices also accept AV/C commands, and the AV/C general specification says that a bus reset discards any transaction in progress. Do the same as for FCP: end the transaction on a bus reset and return -EAGAIN. ERROR_DELAY_MS has no users left, so drop it.
Found with a static analysis tool and checked by hand.
--- sound/firewire/fireworks/fireworks_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/firewire/fireworks/fireworks_transaction.c +2 -2
@@ -34,7 +34,6 @@#define MEMORY_SPACE_EFW_RESPONSE 0xecc080000000ULL#define ERROR_RETRIES 3 -#define ERROR_DELAY_MS 5#define EFC_TIMEOUT_MS 125static DEFINE_SPINLOCK (instances_lock);
@@ -99,7 +98,8 @@ int snd_efw_transaction_run(struct fw_unit *unit, ret = t.size;break ; }else if (t.state ==STATE_BUS_RESET ) { -msleep (ERROR_DELAY_MS ); + ret = -EAGAIN ; +break ; }else if (++tries >=ERROR_RETRIES ) {dev_err (&t.unit->device,"EFW transaction timed out\n" ); ret = -EIO ;
Signature · 1 line
2.34.1
Hi,
Quoted 24 lines · On Sun, Nov 22, 2026 at 01:46:28PM +0000, Suyuan Wang via B4 Relay wrote:
fcp_avc_transaction()andsnd_efw_transaction_run()resend their command after a bus reset but never move the transaction back toSTATE_PENDING, so both loops keep resending without a retry limit until sending fails.As Takashi suggested, v2 no longer resends: on a bus reset the transaction is ended and
-EAGAINis returned, following the AV/C general specification, which says that a target discards any transaction in progress on a bus reset.Found with a static analysis tool and checked by hand. Compile tested only (
x86_64, W=1); I don't have FireWire audio hardware.Changes in v2:
- Abort the transaction and return-EAGAINon a bus reset instead of rearming it and resending (Takashi).
- DropERROR_DELAY_MS(and <linux/delay.h> infcp.c), now unused.v1: https://lore.kernel.org/all/[email protected]/
---
Suyuan Wang (2):
ALSA: firewire-lib: Abort the FCP transaction on a bus reset
ALSA: fireworks: Abort the transaction on a bus reset
Quoted 3 lines
sound/firewire/fcp.c | 5 ++--- sound/firewire/fireworks/fireworks_transaction.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-)
Looks good to me.
Thanks
Takashi Sakamoto
Takashi Iwai
AppliedQuoted 19 lines · On Sun, 22 Nov 2026 14:46:28 +0100, Suyuan Wang via B4 Relay wrote:
fcp_avc_transaction()andsnd_efw_transaction_run()resend their command after a bus reset but never move the transaction back toSTATE_PENDING, so both loops keep resending without a retry limit until sending fails.As Takashi suggested, v2 no longer resends: on a bus reset the transaction is ended and
-EAGAINis returned, following the AV/C general specification, which says that a target discards any transaction in progress on a bus reset.Found with a static analysis tool and checked by hand. Compile tested only (
x86_64, W=1); I don't have FireWire audio hardware.Changes in v2:
- Abort the transaction and return-EAGAINon a bus reset instead of rearming it and resending (Takashi).
- DropERROR_DELAY_MS(and <linux/delay.h> infcp.c), now unused.
Quoted 5 lines
v1: https://lore.kernel.org/all/[email protected]/
---
Suyuan Wang (2):
ALSA: firewire-lib: Abort the FCP transaction on a bus reset
ALSA: fireworks: Abort the transaction on a bus reset
Applied both patches now. Thanks.
Takashi