mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: clemens@ladisch.de, o-takashi@sakamocchi.jp, tiwai@suse.com
Cc: stefanr@s5r6.in-berlin.de, linux-sound@vger.kernel.org,
	perex@perex.cz,  linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] ALSA: firewire-lib: Rearm the FCP transaction after a bus reset
Date: Fri, 20 Nov 2026 05:38:05 +0000	[thread overview]
Message-ID: <20261120-firewire-busreset-v1-1-8bb9079a2984@gmail.com> (raw)
In-Reply-To: <20261120-firewire-busreset-v1-0-8bb9079a2984@gmail.com>

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



  reply	other threads:[~2026-11-20  5:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  5:38 [PATCH 0/2] ALSA: firewire: Don't loop forever " Suyuan Wang via B4 Relay
2026-11-20  5:38 ` Suyuan Wang via B4 Relay [this message]
2026-11-20  5:38 ` [PATCH 2/2] ALSA: fireworks: Rearm the transaction " Suyuan Wang via B4 Relay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120-firewire-busreset-v1-1-8bb9079a2984@gmail.com \
    --to=devnull+shyckless.gmail.com@kernel.org \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=shyckless@gmail.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®