From patchwork Sat Aug 22 09:19:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 7055451 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 95F76C05AC for ; Sat, 22 Aug 2015 09:23:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C157C206A1 for ; Sat, 22 Aug 2015 09:23:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1313E2069F for ; Sat, 22 Aug 2015 09:23:37 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2907E265EAB; Sat, 22 Aug 2015 11:23:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C45EF260656; Sat, 22 Aug 2015 11:20:08 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2A1DA260603; Sat, 22 Aug 2015 11:20:04 +0200 (CEST) Received: from smtp311.phy.lolipop.jp (smtp311.phy.lolipop.jp [210.157.22.79]) by alsa0.perex.cz (Postfix) with ESMTP id 52230260595 for ; Sat, 22 Aug 2015 11:19:48 +0200 (CEST) Received: from smtp311.phy.lolipop.lan (HELO smtp311.phy.lolipop.jp) (172.17.1.11) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp311.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Sat, 22 Aug 2015 18:19:44 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp311.phy.lolipop.jp (LOLIPOP-Fsecure); Sat, 22 Aug 2015 18:19:42 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sat, 22 Aug 2015 18:19:23 +0900 Message-Id: <1440235181-18181-8-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440235181-18181-1-git-send-email-o-takashi@sakamocchi.jp> References: <1440235181-18181-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 07/25] ALSA: firewire-lib: avoid endless loop to transfer MIDI messages at fatal error X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, when asynchronous transactions finish in error state and retries, tasklet scheduling and tasklet running also continues. This should be canceled at fatal error because it can cause endless loop. This commit cancels transferring MIDI messages when transactions encounter fatal error, by setting error state. Signed-off-by: Takashi Sakamoto --- sound/firewire/lib.c | 11 +++++++++-- sound/firewire/lib.h | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sound/firewire/lib.c b/sound/firewire/lib.c index 5d04632..013d40d 100644 --- a/sound/firewire/lib.c +++ b/sound/firewire/lib.c @@ -79,6 +79,9 @@ static void async_midi_port_callback(struct fw_card *card, int rcode, else if (!rcode_is_permanent_error(rcode)) /* To start next transaction immediately for recovery. */ port->next_tick = 0; + else + /* Don't continue processing. */ + port->error = true; port->idling = true; @@ -94,8 +97,8 @@ static void midi_port_tasklet(unsigned long data) int generation; int type; - /* Under transacting. */ - if (!port->idling) + /* Under transacting or error state. */ + if (!port->idling || port->error) return; /* Nothing to do. */ @@ -119,6 +122,9 @@ static void midi_port_tasklet(unsigned long data) if (port->consume_bytes == 0) { port->next_tick = 0; tasklet_schedule(&port->tasklet); + } else { + /* Fatal error. */ + port->error = true; } return; } @@ -187,6 +193,7 @@ int snd_fw_async_midi_port_init(struct snd_fw_async_midi_port *port, port->packetize = packetize; port->idling = true; port->next_tick = 0; + port->error = false; tasklet_init(&port->tasklet, midi_port_tasklet, (unsigned long)port); diff --git a/sound/firewire/lib.h b/sound/firewire/lib.h index bfc353b..84db912 100644 --- a/sound/firewire/lib.h +++ b/sound/firewire/lib.h @@ -27,6 +27,7 @@ struct snd_fw_async_midi_port { struct tasklet_struct tasklet; bool idling; __u64 next_tick; + bool error; __u64 addr; struct fw_transaction transaction; @@ -54,8 +55,10 @@ static inline void snd_fw_async_midi_port_run(struct snd_fw_async_midi_port *port, struct snd_rawmidi_substream *substream) { - port->substream = substream; - tasklet_schedule(&port->tasklet); + if (!port->error) { + port->substream = substream; + tasklet_schedule(&port->tasklet); + } } /** @@ -66,6 +69,7 @@ static inline void snd_fw_async_midi_port_finish(struct snd_fw_async_midi_port *port) { port->substream = NULL; + port->error = false; } #endif