From patchwork Tue Aug 1 10:35:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9874103 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 0FCDD603B4 for ; Tue, 1 Aug 2017 10:38:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11F5D28173 for ; Tue, 1 Aug 2017 10:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06DCA285DE; Tue, 1 Aug 2017 10:38:37 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 9731528683 for ; Tue, 1 Aug 2017 10:38:34 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=L40Ue+1ntWXpoXgojJpiztqsGXeCh++skdi3JuBqI1s=; b=YG9gVFGjpIMfdVPc6IyutqhZz1 v1vwPvq0tdUIVe8yIfID9AHMWdXxxWYrgMsHRuSNHlDb6jB0jgcM/nXVEYOnc++/AVuRzBYytFuUK lqP4MIdBw0g/LlQ3haxAfVUDf3xWxOLwtdBekSiD5Bk6DvuUomat10FNfShJtxTfk/xn7wCRcZm+Y 0kl7Zsw0AxYE7hwC3KD8RZlhjCKaneeYinzhchYj7d60OqjK+A68osu+UKkb5fAAIAUGRlBZTL5jg bMOK9dJHcIcQvwJYckCmXrw572VZq+DNM7QgQA5tgXAzlKkbaTVRStlmv/qWo6SVj8aXAk81z7cxD tmCV87gQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcUZH-0003EJ-T6; Tue, 01 Aug 2017 10:38:28 +0000 Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcUY9-000205-Et for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2017 10:37:32 +0000 Received: by mail-qt0-x22e.google.com with SMTP id a18so6482553qta.0 for ; Tue, 01 Aug 2017 03:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bsvl1wSddPl3i8pFYxyWdvBjQvFerLKGNqbOaz2Dwow=; b=DfXei684izrJ2KaPvL9x4/Mb4zEq+6eSzMvY7++sgty/tp3fhLZ3EzhE+ehOywMbyO O/qR31o8g0RWWvsofQgxggvuvm8EG8zP41n7HMaJhvvjjkktPyTQipCrbz6f8uiX+yc0 7l2RhjpkatNaD6+jt6iW4cGJ5pJnRbBmImUU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bsvl1wSddPl3i8pFYxyWdvBjQvFerLKGNqbOaz2Dwow=; b=h8Dt6zgwgp00BKy3aVZfPe+LNEfaNLwe2g6SCpAPOprHE1Xmruq45TOCWQJbwG0k2e 8VAGMfjBC4jfnO1u+pxvz6J98U632hMrjGZ8keQdl5GhmWm9TKdgYmGPkx0iV6KNwvTX hCapWRBkpUwWw3HAP5/1hdOcUCtKpmJp3YoQyVKUv0nxFr/x3aGXKoWlOtSGdNt7jyGH HIdvMEWcBaMSsv7CEGDwmN1LyWCmluqDD+Q3BPu3H4i9kuru0U5axx04DKCWniacjkJN Th3BdnYdyUezFkb94l+Dp4u/XuS4qHsBwq3Cfsh0cV8wWf1ydiEDCt+tDmfVF0nB1ByD i/UA== X-Gm-Message-State: AIVw11306aZfdBN8U2BWoGYPWBwyiVWSEr25bxAwuIEZyMg+wrAly3I3 vY1KwGJtt3UvfZR5 X-Received: by 10.200.13.67 with SMTP id r3mr27549971qti.286.1501583815901; Tue, 01 Aug 2017 03:36:55 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id d14sm23961629qtd.21.2017.08.01.03.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Aug 2017 03:36:55 -0700 (PDT) From: Anup Patel To: Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , Jassi Brar Subject: [PATCH v3 5/5] mailbox: bcm-flexrm-mailbox: Use txdone_ack instead of txdone_poll Date: Tue, 1 Aug 2017 16:05:54 +0530 Message-Id: <1501583754-31969-6-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501583754-31969-1-git-send-email-anup.patel@broadcom.com> References: <1501583754-31969-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170801_033718_002329_7C9E09AE X-CRM114-Status: GOOD ( 18.94 ) 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, Florian Fainelli , Anup Patel , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 Currently, FlexRM driver uses txdone_poll method of Linux Mailbox to model the send_data() callback. To achieve this, we have introduced "last_pending_msg" pointer for each FlexRM ring which keeps track of the message that did not fit in the FlexRM ring. This patch updates FlexRM driver to use txdone_ack method instead of txdone_poll method because txdone_poll is not efficient for FlexRM and requires additional tracking in FlexRM driver. Also, moving to txdone_ack method helps us remove "last_pending_msg" pointer and last_tx_done() callback. Signed-off-by: Anup Patel Reviewed-by: Ray Jui --- drivers/mailbox/bcm-flexrm-mailbox.c | 61 +++--------------------------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c index 9873818..ae61463 100644 --- a/drivers/mailbox/bcm-flexrm-mailbox.c +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -277,7 +277,6 @@ struct flexrm_ring { /* Protected members */ spinlock_t lock; DECLARE_BITMAP(requests_bmap, RING_MAX_REQ_COUNT); - struct brcm_message *last_pending_msg; u32 cmpl_read_offset; }; @@ -997,15 +996,9 @@ static int flexrm_new_request(struct flexrm_ring *ring, spin_lock_irqsave(&ring->lock, flags); reqid = bitmap_find_free_region(ring->requests_bmap, RING_MAX_REQ_COUNT, 0); - if (reqid < 0) { - if (batch_msg) - ring->last_pending_msg = batch_msg; - else - ring->last_pending_msg = msg; - spin_unlock_irqrestore(&ring->lock, flags); - return 0; - } spin_unlock_irqrestore(&ring->lock, flags); + if (reqid < 0) + return -ENOSPC; ring->requests[reqid] = msg; /* Do DMA mappings for the message */ @@ -1018,17 +1011,6 @@ static int flexrm_new_request(struct flexrm_ring *ring, return ret; } - /* If last_pending_msg is already set then goto done with error */ - spin_lock_irqsave(&ring->lock, flags); - if (ring->last_pending_msg) - ret = -ENOSPC; - spin_unlock_irqrestore(&ring->lock, flags); - if (ret < 0) { - dev_warn(ring->mbox->dev, "no space in ring %d\n", ring->num); - exit_cleanup = true; - goto exit; - } - /* Determine current HW BD read offset */ read_offset = readl_relaxed(ring->regs + RING_BD_READ_PTR); val = readl_relaxed(ring->regs + RING_BD_START_ADDR); @@ -1055,13 +1037,7 @@ static int flexrm_new_request(struct flexrm_ring *ring, break; } if (count) { - spin_lock_irqsave(&ring->lock, flags); - if (batch_msg) - ring->last_pending_msg = batch_msg; - else - ring->last_pending_msg = msg; - spin_unlock_irqrestore(&ring->lock, flags); - ret = 0; + ret = -ENOSPC; exit_cleanup = true; goto exit; } @@ -1110,12 +1086,6 @@ static int flexrm_process_completions(struct flexrm_ring *ring) spin_lock_irqsave(&ring->lock, flags); - /* Check last_pending_msg */ - if (ring->last_pending_msg) { - msg = ring->last_pending_msg; - ring->last_pending_msg = NULL; - } - /* * Get current completion read and write offset * @@ -1131,10 +1101,6 @@ static int flexrm_process_completions(struct flexrm_ring *ring) spin_unlock_irqrestore(&ring->lock, flags); - /* If last_pending_msg was set then queue it back */ - if (msg) - mbox_send_message(chan, msg); - /* For each completed request notify mailbox clients */ reqid = 0; while (cmpl_read_offset != cmpl_write_offset) { @@ -1345,9 +1311,6 @@ static int flexrm_startup(struct mbox_chan *chan) val = CMPL_START_ADDR_VALUE(ring->cmpl_dma_base); writel_relaxed(val, ring->regs + RING_CMPL_START_ADDR); - /* Ensure last pending message is cleared */ - ring->last_pending_msg = NULL; - /* Completion read pointer will be same as HW write pointer */ ring->cmpl_read_offset = readl_relaxed(ring->regs + RING_CMPL_WRITE_PTR); @@ -1455,24 +1418,10 @@ static void flexrm_shutdown(struct mbox_chan *chan) } } -static bool flexrm_last_tx_done(struct mbox_chan *chan) -{ - bool ret; - unsigned long flags; - struct flexrm_ring *ring = chan->con_priv; - - spin_lock_irqsave(&ring->lock, flags); - ret = (ring->last_pending_msg) ? false : true; - spin_unlock_irqrestore(&ring->lock, flags); - - return ret; -} - static const struct mbox_chan_ops flexrm_mbox_chan_ops = { .send_data = flexrm_send_data, .startup = flexrm_startup, .shutdown = flexrm_shutdown, - .last_tx_done = flexrm_last_tx_done, .peek_data = flexrm_peek_data, }; @@ -1599,7 +1548,6 @@ static int flexrm_mbox_probe(struct platform_device *pdev) atomic_set(&ring->msg_cmpl_count, 0); spin_lock_init(&ring->lock); bitmap_zero(ring->requests_bmap, RING_MAX_REQ_COUNT); - ring->last_pending_msg = NULL; ring->cmpl_read_offset = 0; } @@ -1671,8 +1619,7 @@ static int flexrm_mbox_probe(struct platform_device *pdev) /* Initialize mailbox controller */ mbox->controller.txdone_irq = false; - mbox->controller.txdone_poll = true; - mbox->controller.txpoll_period = 1; + mbox->controller.txdone_poll = false; mbox->controller.ops = &flexrm_mbox_chan_ops; mbox->controller.dev = dev; mbox->controller.num_chans = mbox->num_rings;