All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de
Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net
Subject: [RFC][PATCH 07/37] ALSA: firewire-lib: avoid endless loop to transfer MIDI messages at fatal error
Date: Sat, 11 Jul 2015 23:12:18 +0900	[thread overview]
Message-ID: <1436623968-10780-8-git-send-email-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <1436623968-10780-1-git-send-email-o-takashi@sakamocchi.jp>

When asynchronous transactions finish in error state and retries,
tasklet scheduling and tasklet running also continues.

This commit cancels transferring MIDI messages wnen transactions encounter
fatal error, by setting error state.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 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 f9c1873..b568059c 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. */
@@ -117,6 +120,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;
 	}
@@ -167,6 +173,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 e4b00e2..c9ea52b 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;
 	unsigned long 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
-- 
2.1.4

  parent reply	other threads:[~2015-07-11 14:13 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-11 14:12 [RFC][PATCH 00/37] ALSA: firewire: support AMDTP variants Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 01/37] ALSA: firewire-lib: rename 'amdtp' to 'amdtp-stream' for functional separation Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 02/37] ALSA: firewire-lib: functional separation between packet stream and data block format Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 03/37] ALSA: firewire-lib: add helper functions for asynchronous MIDI port Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 04/37] ALSA: firewire-lib: serialize request transaction and response transaction Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 05/37] ALSA: firewire-lib: schedule tasklet again when MIDI substream has rest of MIDI messages Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 06/37] ALSA: firewire-lib: add throttle for MIDI data rate Takashi Sakamoto
2015-07-12  8:31   ` [FFADO-devel] " Jonathan Woithe
2015-07-11 14:12 ` Takashi Sakamoto [this message]
2015-07-11 14:12 ` [RFC][PATCH 08/37] ALSA: firewire-digi00x: add skelton for Digi 002/003 family Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 09/37] ALSA: firewire-digi00x: add protocol layer Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 10/37] ALSA: firewire-digi00x: add stream functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 11/37] ALSA: firewire-digi00x: add proc node to show clock status Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 12/37] ALSA: firewire-digi00x: add PCM functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 13/37] ALSA: firewire-digi00x: add MIDI functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 14/37] ALSA: firewire-digi00x: add hwdep interface Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 15/37] ALSA: firewire-digi00x: add support for asynchronous messaging Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 16/37] ALSA: firewire-digi00x: add support for MIDI ports for machine control Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 17/37] ALSA: firewire-tascam: add skeleton for TASCAM FireWire series Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 18/37] ALSA: firewire-tascam: add a structure for model-dependent parameters Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 19/37] ALSA: firewire-tascam: add proc node to show firmware information Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 20/37] ALSA: firewire-tascam: add specific protocol layer Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 21/37] ALSA: firewire-tascam: add streaming functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 22/37] ALSA: firewire-tascam: add PCM functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 23/37] ALSA: firewire-tascam: add transaction functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 24/37] ALSA: firewire-tascam: add MIDI functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 25/37] ALSA: firewire-tascam: add hwdep interface Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 26/37] ALSA: firewire-tascam: add MMAP support to show status and control message Takashi Sakamoto
2015-07-20 14:23   ` Takashi Iwai
2015-07-22 14:53     ` Takashi Sakamoto
2015-07-21 14:06   ` Clemens Ladisch
2015-07-22 15:19     ` Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 27/37] ALSA: firewire-lib: add support for source packet header field in CIP header Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 28/37] ALSA: firewire-lib: enable protocol layer to handle current cycle count Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 29/37] ALSA: firewire-motu: add skeleton for Mark of the unicorn (MOTU) FireWire series Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 30/37] ALSA: firewire-motu: add a structure for model-dependent parameters Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 31/37] ALSA: firewire-motu: add MOTU specific protocol layer Takashi Sakamoto
2015-07-12  1:05   ` [FFADO-devel] " Jonathan Woithe
2015-07-15 16:10     ` Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 32/37] ALSA: firewire-motu: add stream functionality Takashi Sakamoto
2015-07-13 11:09   ` [FFADO-devel] " Jonathan Woithe
2015-07-13 11:23   ` Jonathan Woithe
2015-07-11 14:12 ` [RFC][PATCH 33/37] ALSA: firewire-motu: add transaction functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 34/37] ALSA: firewire-motu: add proc node to show the status of internal clock Takashi Sakamoto
2015-07-13 11:28   ` [FFADO-devel] " Jonathan Woithe
2015-07-11 14:12 ` [RFC][PATCH 35/37] ALSA: firewire-motu: add PCM functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 36/37] ALSA: firewire-motu: add MIDI functionality Takashi Sakamoto
2015-07-11 14:12 ` [RFC][PATCH 37/37] ALSA: firewire-motu: add hwdep interface Takashi Sakamoto
2015-07-13 10:58   ` [FFADO-devel] " Jonathan Woithe
2015-07-11 14:33 ` [RFC][PATCH 00/37] ALSA: firewire: support AMDTP variants Takashi Sakamoto
2015-07-12  8:46 ` [FFADO-devel] " Jonathan Woithe

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=1436623968-10780-8-git-send-email-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.