From patchwork Tue May 8 11:43:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Perttunen X-Patchwork-Id: 10386001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0BAB6602C2 for ; Tue, 8 May 2018 11:49:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE32D28786 for ; Tue, 8 May 2018 11:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E285B28D77; Tue, 8 May 2018 11:49:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 379F228786 for ; Tue, 8 May 2018 11:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GWxi7zjpMo9HijfOs6cbj6rzqpJZYrwhwXM1HiZx2us=; b=Nhx74b+Q4zo6C+ 5mOAtTv1vsaHusXZBGQjX1nDNPzQ5WqX0DPRI0q8tbrvCIXok7k/0u9naekKlmM8R5TywXX0zjKJ0 gfLkoNy/p9hAZwW4pMOHpYj5yZ82WRXI+PU0154i4y1mPTHACJCBMUeexRPlXUSwuoJP4+yO6gw3m LkvXU+fgM20B80MsT0wm3hbiKwWtuxrQzVOVVio9+hcUsvP1+0Kb+Drv6rW43EFS+ndLtPMLc5Bk5 IqW6Hg67BNDgUQBm/RVGdA4C08vug8ELa5WUMc4YedPDTZXSaVeat9jR0omF8o79F5C/0cr+FoB8G 9vK8h8euKdbfY4nEXiAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fG17f-0000ir-Em; Tue, 08 May 2018 11:49:35 +0000 Received: from hqemgate16.nvidia.com ([216.228.121.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fG17b-0000hW-TW for linux-arm-kernel@lists.infradead.org; Tue, 08 May 2018 11:49:33 +0000 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Tue, 08 May 2018 04:49:30 -0700 Received: from HQMAIL104.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 08 May 2018 04:49:30 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 08 May 2018 04:49:30 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 8 May 2018 11:49:30 +0000 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 8 May 2018 11:49:29 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server id 15.0.1347.2 via Frontend Transport; Tue, 8 May 2018 11:49:29 +0000 Received: from mperttunen-lnx.Nvidia.com (Not Verified[10.21.26.144]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 8, 10121) id ; Tue, 08 May 2018 04:49:29 -0700 From: Mikko Perttunen To: , , , , , Subject: [PATCH 3/8] mailbox: Add transmit done by blocking option Date: Tue, 8 May 2018 14:43:58 +0300 Message-ID: <20180508114403.14499-4-mperttunen@nvidia.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180508114403.14499-1-mperttunen@nvidia.com> References: <20180508114403.14499-1-mperttunen@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180508_044931_976662_25658EEA X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, araza@nvidia.com, linux-kernel@vger.kernel.org, Mikko Perttunen , linux-serial@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new TXDONE option, TXDONE_BY_BLOCK. With this option, the send_data function of the mailbox driver is expected to block until the message has been sent. The new option is used with the Tegra Combined UART driver to minimize unnecessary overhead when transmitting data. Signed-off-by: Mikko Perttunen --- drivers/mailbox/mailbox.c | 30 +++++++++++++++++++++--------- drivers/mailbox/mailbox.h | 1 + 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 674b35f402f5..5c76b70e673c 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -53,6 +53,8 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg) return idx; } +static void tx_tick(struct mbox_chan *chan, int r, bool submit_next); + static void msg_submit(struct mbox_chan *chan) { unsigned count, idx; @@ -60,10 +62,13 @@ static void msg_submit(struct mbox_chan *chan) void *data; int err = -EBUSY; +next: spin_lock_irqsave(&chan->lock, flags); - if (!chan->msg_count || chan->active_req) - goto exit; + if (!chan->msg_count || chan->active_req) { + spin_unlock_irqrestore(&chan->lock, flags); + return; + } count = chan->msg_count; idx = chan->msg_free; @@ -82,15 +87,21 @@ static void msg_submit(struct mbox_chan *chan) chan->active_req = data; chan->msg_count--; } -exit: + spin_unlock_irqrestore(&chan->lock, flags); if (!err && (chan->txdone_method & TXDONE_BY_POLL)) /* kick start the timer immediately to avoid delays */ hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); + + if (chan->txdone_method & TXDONE_BY_BLOCK) { + tx_tick(chan, err, false); + if (!err) + goto next; + } } -static void tx_tick(struct mbox_chan *chan, int r) +static void tx_tick(struct mbox_chan *chan, int r, bool submit_next) { unsigned long flags; void *mssg; @@ -101,7 +112,8 @@ static void tx_tick(struct mbox_chan *chan, int r) spin_unlock_irqrestore(&chan->lock, flags); /* Submit next message */ - msg_submit(chan); + if (submit_next) + msg_submit(chan); if (!mssg) return; @@ -127,7 +139,7 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) if (chan->active_req && chan->cl) { txdone = chan->mbox->ops->last_tx_done(chan); if (txdone) - tx_tick(chan, 0); + tx_tick(chan, 0, true); else resched = true; } @@ -176,7 +188,7 @@ void mbox_chan_txdone(struct mbox_chan *chan, int r) return; } - tx_tick(chan, r); + tx_tick(chan, r, true); } EXPORT_SYMBOL_GPL(mbox_chan_txdone); @@ -196,7 +208,7 @@ void mbox_client_txdone(struct mbox_chan *chan, int r) return; } - tx_tick(chan, r); + tx_tick(chan, r, true); } EXPORT_SYMBOL_GPL(mbox_client_txdone); @@ -275,7 +287,7 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) ret = wait_for_completion_timeout(&chan->tx_complete, wait); if (ret == 0) { t = -ETIME; - tx_tick(chan, t); + tx_tick(chan, t, true); } } diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h index 456ba68513bb..ec68e2e28cd6 100644 --- a/drivers/mailbox/mailbox.h +++ b/drivers/mailbox/mailbox.h @@ -10,5 +10,6 @@ #define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */ #define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */ #define TXDONE_BY_ACK BIT(2) /* S/W ACK recevied by Client ticks the TX */ +#define TXDONE_BY_BLOCK BIT(3) /* mailbox driver send_data blocks until done */ #endif /* __MAILBOX_H */