From patchwork Mon Jul 29 21:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edmund Raile X-Patchwork-Id: 13745833 Received: from mail-43166.protonmail.ch (mail-43166.protonmail.ch [185.70.43.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BBFE18E756; Mon, 29 Jul 2024 21:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.166 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722289353; cv=none; b=f1SG/SHGRcsj8nopj8a+v0ZxN9RbLVZU9hGrrZmqQ14PSk4Gkugrc5Zk0WDVu0+CgEcqKYFX7oUGz/n4Q64mgktJ80sXu0ufH8Hw/ok+Koo/q3Hg3YlUVKHZ8hvbWv0yAFJ7HXMK8gpwHNtVp2eXCLddQMNCR3WDoCioDMgl43Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722289353; c=relaxed/simple; bh=yRwttLVnCbGv+EaWNEn53RVQvpUMZ1hdRbs/Bciab/U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u+P43aq44nJXNX4N9n1sdqbukuZ2PGYZuyU8IzAHgDVxGklWwtRIidYy54eEhxm+vvR8syK+K+3sH2DF1gTqTjuxkMV57Ecc2jCpkiF+jXWc1Kr0WtjGo57BM+pKi/Rq/VD0or3j+LGMpitZ/3+dwjC433fORaVo9Ori9zetWpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=r1l45ICv; arc=none smtp.client-ip=185.70.43.166 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="r1l45ICv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1722289349; x=1722548549; bh=yRwttLVnCbGv+EaWNEn53RVQvpUMZ1hdRbs/Bciab/U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=r1l45ICvIsF9l4qaWTKsGDN7U//lQ6Wzlfv7AI5q3jqSTj4zPz0vLfQZN8DdrnRZ2 FJ732EVN2J5pK19ytKvjmHDhKAnjIexFvG76U6acvLPVVAIWLz5pAS8ud6wC2BdDRw C8AYnNOyrmqUEG9IJwmR9WiKjRwGNBqUsHJaQXMJylxItlKKg0cUQptYATGEBp0D+H IPRqiw4BPz8OXcQJpQwbhBjuA8tIpzcLOGZR3spWZZzaUXCN/BKkYNGo8wRIMdIf+3 FGdUCL8gBGjSyCU6USjUBxRMhrUoHNu5RYEAuBUi3QjSJEBE57BDYYX4aZodQarO8c 6sVxOja8RCQqA== Date: Mon, 29 Jul 2024 21:42:26 +0000 To: o-takashi@sakamocchi.jp, clemens@ladisch.de From: Edmund Raile Cc: tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v3 3/3] ALSA: firewire-lib: amdtp-stream work queue inline description Message-ID: <20240729214149.752663-4-edmund.raile@protonmail.com> In-Reply-To: <20240729214149.752663-1-edmund.raile@protonmail.com> References: <20240729214149.752663-1-edmund.raile@protonmail.com> Feedback-ID: 43016623:user:proton X-Pm-Message-ID: c866ae9e4304cd5c42ed2f9839a224dbc09265d4 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace prior inline description to prevent future deadlock. Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/kwryofzdmjvzkuw6j3clftsxmoolynljztxqwg76hzeo4simnl@jn3eo7pe642q/ Signed-off-by: Edmund Raile --- sound/firewire/amdtp-stream.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index a07b0452267d..7438999e0510 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -1857,20 +1857,12 @@ unsigned long amdtp_domain_stream_pcm_pointer(struct amdtp_domain *d, struct amdtp_stream *irq_target = d->irq_target; if (irq_target && amdtp_stream_running(irq_target)) { - // This function is called in software IRQ context of - // period_work or process context. - // - // When the software IRQ context was scheduled by software IRQ - // context of IT contexts, queued packets were already handled. - // Therefore, no need to flush the queue in buffer furthermore. - // - // When the process context reach here, some packets will be - // already queued in the buffer. These packets should be handled - // immediately to keep better granularity of PCM pointer. - // - // Later, the process context will sometimes schedules software - // IRQ context of the period_work. Then, no need to flush the - // queue by the same reason as described in the above + // use wq to prevent AB/BA deadlock competition for + // substream lock: + // fw_iso_context_flush_completions() acquires + // lock by ohci_flush_iso_completions(), + // amdtp-stream process_rx_packets() attempts to + // acquire same lock by snd_pcm_elapsed() if (current_work() != &s->period_work) fw_iso_context_flush_completions(irq_target->context); }