From patchwork Wed Nov 1 16:32:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 117730 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1088424qgn; Wed, 1 Nov 2017 09:32:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T0bOgqBtm3wctCs8TeuvsUDIr9JMZ8WnRK86RbVLegzdIKYQ6uQhikr0tvrcKGDqG/rLow X-Received: by 10.99.150.2 with SMTP id c2mr460629pge.386.1509553977358; Wed, 01 Nov 2017 09:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509553977; cv=none; d=google.com; s=arc-20160816; b=j9/WJsrP7m4SP0h9lNA6i5eeFHsVPvMuf6Tb8MX3bseXV+YCsuUbUG4FUCERtwTcih woNlgNjO/TRFDgxHAHKt9yJC9lk1V9UFTnIxgeTfdXAiGwR4oC8H58kZpWnfDauQFSOq 9SXWNwQdPjCcMI38vJU6zJstJBXZxuQk/0En6PVoBL58eXRyCcyIsXQZR6ZC7tl4P0SG bCt+RCu+HMm38MfCTUn2zW5PhIWvwkTB0pc6jYxDQtpWz7k+atP6yoNJvbWb4OQgi3rI 7pTF8VcecYpFjRm8Cx9cqeDgbEiUySPn+eoQvMTfCOHn9C3Tj2WdNTyscYwua0kvi3g9 TkTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4Or/QGongVz/nL7/KY5i2tOV9F7iuRC6AaR+9mjiyPY=; b=s0ahG7A+rM0h0PuqAjRXnwAH3wJOmqmlVaTaMxvlKfUN3pJ/94X9brjR221ttoRjr5 3rVDzXKqzl6s0gEd23H+kve0OWjXb6YiYUDc4Yal9GqYZEUvNIGTnrp1B5FyvkILgTvl B2s1V9yv4yJvbamW2sjxASjbnnabrCOF8+gXTY2OY1pEqOfxixFMwMIgpeCLp1aQHLNz 5frZdbDUy0kKZzWODTZRfLW4zGzxO0DlSE5s6ncK0m/d09Mlk0hYZXdyvDDwsUIoItX7 5IHKl1h6b7+VQpK+ebMWSEOz8zABOAg4F/JlIZaFwAkbAtwOF8zYc3JX4Ly6F/0IIPZc 7cqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si96859pli.728.2017.11.01.09.32.57; Wed, 01 Nov 2017 09:32:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754932AbdKAQcz (ORCPT + 26 others); Wed, 1 Nov 2017 12:32:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754089AbdKAQcx (ORCPT ); Wed, 1 Nov 2017 12:32:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FE311529; Wed, 1 Nov 2017 09:32:53 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C6353F24A; Wed, 1 Nov 2017 09:32:52 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Jassi Brar Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Arnd Bergmann , Bjorn Andersson Subject: [PATCH] mailbox: add support for doorbell/signal mode controllers Date: Wed, 1 Nov 2017 16:32:44 +0000 Message-Id: <1509553964-4451-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some mailbox controllers are lack FIFOs or memory to transmit data. They typically contains single doorbell registers to just signal the remote. The actually data is transmitted/shared using some shared memory which is not part of the mailbox. Such controllers don't need to transmit any data, they just transmit the signal. In such controllers the data pointer passed to mbox_send_message is passed to client via it's tx_prepare callback. Controller doesn't need any data to be passed from the client. This patch introduce the new API send_signal to support such doorbell/ signal mode in mailbox controllers. This is useful to avoid another layer of abstraction as typically multiple channels can be multiplexied into single register. Cc: Jassi Brar Cc: Arnd Bergmann Cc: Bjorn Andersson Signed-off-by: Sudeep Holla --- drivers/mailbox/mailbox.c | 11 ++++++++++- include/linux/mailbox_controller.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) Hi Jassi, Arnd, This is rough idea I have on extending mailbox interface to support the doorbell requirements. The new API send_signal will eliminate the issue Jassi has explained in earlier discussion with respect to generic message format using Rockchip example. Regards, Sudeep -- 2.7.4 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 674b35f402f5..495b4574b954 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -77,7 +77,10 @@ static void msg_submit(struct mbox_chan *chan) if (chan->cl->tx_prepare) chan->cl->tx_prepare(chan->cl, data); /* Try to submit a message to the MBOX controller */ - err = chan->mbox->ops->send_data(chan, data); + if (chan->mbox->ops->send_data) + err = chan->mbox->ops->send_data(chan, data); + else + err = chan->mbox->ops->send_signal(chan); if (!err) { chan->active_req = data; chan->msg_count--; @@ -451,6 +454,12 @@ int mbox_controller_register(struct mbox_controller *mbox) /* Sanity check */ if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans) return -EINVAL; + /* + * A controller can support either doorbell mode or normal message + * transmission mode but not both + */ + if (mbox->ops->send_data && mbox->ops->send_signal) + return -EINVAL; if (mbox->txdone_irq) txdone = TXDONE_BY_IRQ; diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 74deadb42d76..bdbc5b74097e 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -24,6 +24,16 @@ struct mbox_chan; * transmission of data is reported by the controller via * mbox_chan_txdone (if it has some TX ACK irq). It must not * sleep. + * @send_signal: The API asks the MBOX controller driver, in atomic + * context try to transmit a signal on the bus. Returns 0 if + * data is accepted for transmission, -EBUSY while rejecting + * if the remote hasn't yet absorbed the last signal sent. Actual + * transmission of data must be handled by the client and is + * reported by the controller via mbox_chan_txdone (if it has + * some TX ACK irq). It must not sleep. Unlike send_data, + * send_signal doesn't handle any messages/data. It just sends + * notification signal(doorbell) and client needs to prepare all + * the data. * @startup: Called when a client requests the chan. The controller * could ask clients for additional parameters of communication * to be provided via client's chan_data. This call may @@ -46,6 +56,7 @@ struct mbox_chan; */ struct mbox_chan_ops { int (*send_data)(struct mbox_chan *chan, void *data); + int (*send_signal)(struct mbox_chan *chan); int (*startup)(struct mbox_chan *chan); void (*shutdown)(struct mbox_chan *chan); bool (*last_tx_done)(struct mbox_chan *chan);