From patchwork Sat Jul 11 14:12:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 6770401 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 859309F319 for ; Sat, 11 Jul 2015 14:14:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B67022065F for ; Sat, 11 Jul 2015 14:14:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7CFAD20656 for ; Sat, 11 Jul 2015 14:14:22 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 81E2426673B; Sat, 11 Jul 2015 16:14:21 +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=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 589012605E4; Sat, 11 Jul 2015 16:13:13 +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 125822605D7; Sat, 11 Jul 2015 16:13:10 +0200 (CEST) Received: from smtp301.phy.lolipop.jp (smtp301.phy.lolipop.jp [210.157.22.84]) by alsa0.perex.cz (Postfix) with ESMTP id 80689260545 for ; Sat, 11 Jul 2015 16:13:02 +0200 (CEST) Received: from smtp301.phy.lolipop.lan (HELO smtp301.phy.lolipop.jp) (172.17.1.84) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp301.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Sat, 11 Jul 2015 23:12:59 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp301.phy.lolipop.jp (LOLIPOP-Fsecure); Sat, 11 Jul 2015 23:12:49 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de Date: Sat, 11 Jul 2015 23:12:15 +0900 Message-Id: <1436623968-10780-5-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436623968-10780-1-git-send-email-o-takashi@sakamocchi.jp> References: <1436623968-10780-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net Subject: [alsa-devel] [RFC][PATCH 04/37] ALSA: firewire-lib: serialize request transaction and response transaction 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 The helper functions for asynchronous MIDI port use 'tasklet' to run IEEE 1394 asynchronous transactions, while running transactions need to wait for response. In this reason, one transaction should be transferred at one tasklet scheduling, because tasklet runs one kernel thread available for the other tasks For these reasons, this commit serialize request/response transactions, by adding one boolean member. Signed-off-by: Takashi Sakamoto --- sound/firewire/lib.c | 8 ++++++++ sound/firewire/lib.h | 1 + 2 files changed, 9 insertions(+) diff --git a/sound/firewire/lib.c b/sound/firewire/lib.c index f5b5526..a66e011 100644 --- a/sound/firewire/lib.c +++ b/sound/firewire/lib.c @@ -76,6 +76,8 @@ static void async_midi_port_callback(struct fw_card *card, int rcode, if (rcode == RCODE_COMPLETE && substream != NULL) snd_rawmidi_transmit_ack(substream, port->consume_bytes); + + port->idling = true; } static void midi_port_tasklet(unsigned long data) @@ -86,6 +88,10 @@ static void midi_port_tasklet(unsigned long data) int generation; int type; + /* Under transacting. */ + if (!port->idling) + return; + /* Nothing to do. */ if (substream == NULL || snd_rawmidi_transmit_empty(substream)) return; @@ -110,6 +116,7 @@ static void midi_port_tasklet(unsigned long data) type = TCODE_WRITE_BLOCK_REQUEST; /* Start this transaction. */ + port->idling = false; generation = port->parent->generation; smp_rmb(); /* node_id vs. generation */ fw_send_request(port->parent->card, &port->transaction, type, @@ -142,6 +149,7 @@ int snd_fw_async_midi_port_init(struct snd_fw_async_midi_port *port, port->parent = fw_parent_device(unit); port->addr = addr; port->packetize = packetize; + port->idling = true; tasklet_init(&port->tasklet, midi_port_tasklet, (unsigned long)port); diff --git a/sound/firewire/lib.h b/sound/firewire/lib.h index c662bf9..9d76f5c 100644 --- a/sound/firewire/lib.h +++ b/sound/firewire/lib.h @@ -25,6 +25,7 @@ static inline bool rcode_is_permanent_error(int rcode) struct snd_fw_async_midi_port { struct fw_device *parent; struct tasklet_struct tasklet; + bool idling; __u64 addr; struct fw_transaction transaction;