mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ALSA: firewire: Abort transactions on a bus reset
@ 2026-11-22 13:46 Suyuan Wang via B4 Relay
  2026-11-22 13:46 ` [PATCH v2 1/2] ALSA: firewire-lib: Abort the FCP transaction " Suyuan Wang via B4 Relay
  2026-11-22 13:46 ` [PATCH v2 2/2] ALSA: fireworks: Abort the " Suyuan Wang via B4 Relay
  0 siblings, 2 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-22 13:46 UTC (permalink / raw)
  To: o-takashi, clemens, 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, 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/20261120-firewire-busreset-v1-0-8bb9079a2984@gmail.com/
---
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(-)



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

* [PATCH v2 1/2] ALSA: firewire-lib: Abort the FCP transaction on a bus reset
  2026-11-22 13:46 [PATCH v2 0/2] ALSA: firewire: Abort transactions on a bus reset Suyuan Wang via B4 Relay
@ 2026-11-22 13:46 ` Suyuan Wang via B4 Relay
  2026-11-22 13:46 ` [PATCH v2 2/2] ALSA: fireworks: Abort the " Suyuan Wang via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-22 13:46 UTC (permalink / raw)
  To: o-takashi, clemens, tiwai; +Cc: stefanr, linux-sound, perex, linux-kernel

From: Suyuan Wang <stevewong@hust.edu.cn>

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.

Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c
index e60bfd0ee4ac..b8e7e2c90791 100644
--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -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;

-- 
2.34.1



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

* [PATCH v2 2/2] ALSA: fireworks: Abort the transaction on a bus reset
  2026-11-22 13:46 [PATCH v2 0/2] ALSA: firewire: Abort transactions on a bus reset Suyuan Wang via B4 Relay
  2026-11-22 13:46 ` [PATCH v2 1/2] ALSA: firewire-lib: Abort the FCP transaction " Suyuan Wang via B4 Relay
@ 2026-11-22 13:46 ` Suyuan Wang via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-22 13:46 UTC (permalink / raw)
  To: o-takashi, clemens, tiwai; +Cc: stefanr, linux-sound, perex, linux-kernel

From: Suyuan Wang <stevewong@hust.edu.cn>

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.

Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
index 5c859773fe06..bb9ab8ed52b5 100644
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -34,7 +34,6 @@
 #define MEMORY_SPACE_EFW_RESPONSE	0xecc080000000ULL
 
 #define ERROR_RETRIES 3
-#define ERROR_DELAY_MS 5
 #define EFC_TIMEOUT_MS 125
 
 static 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;

-- 
2.34.1



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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 13:46 [PATCH v2 0/2] ALSA: firewire: Abort transactions on a bus reset Suyuan Wang via B4 Relay
2026-11-22 13:46 ` [PATCH v2 1/2] ALSA: firewire-lib: Abort the FCP transaction " Suyuan Wang via B4 Relay
2026-11-22 13:46 ` [PATCH v2 2/2] ALSA: fireworks: Abort 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®