From patchwork Thu Feb 2 04:47:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9551013 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 CCCC060424 for ; Thu, 2 Feb 2017 04:49:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCA8528458 for ; Thu, 2 Feb 2017 04:49:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B09192844A; Thu, 2 Feb 2017 04:49:28 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no 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 705A12844A for ; Thu, 2 Feb 2017 04:49:28 +0000 (UTC) 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 1cZ9Ko-0005Dm-LL; Thu, 02 Feb 2017 04:49:26 +0000 Received: from mail-qt0-f182.google.com ([209.85.216.182]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cZ9Kk-0004xU-2k for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2017 04:49:24 +0000 Received: by mail-qt0-f182.google.com with SMTP id v23so9927298qtb.0 for ; Wed, 01 Feb 2017 20:49:01 -0800 (PST) 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=/21cK0Pje28vwDzUJ1U7u2O8OSl8sstkRSuPodyfgoM=; b=Y6dUMwEkvxEL1G1ltQ0TxlfnwJSBZQlSbhGHu02Xng+GVZxa1NCQSjF77+Ur1KU8kz 0pyW5aAoPDi00qgN9W/W6M3f4SNt2vTZdBixK2NQ0tdEEVOTkZ04pYMiS+kz9AopXYEn 4XaNIzR05YJmkgXy56FRvlAjdZOdKZ7c3VXwo= 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=/21cK0Pje28vwDzUJ1U7u2O8OSl8sstkRSuPodyfgoM=; b=t+i8nurGZZGbIirLVBeKOkl14Az3vyDD7BJvZCa6JXY6E+dQhCWRd0FyHOts/AcWe6 ovkoA9ae/cjl3UY4RYhzIO9CewYg/Rh8Y/URBV905zPH1aIyW+tOKhfVzspO2KzrOok1 H+BMLpPnCDs/fmVk2QyrAYLkKH6lvuJskDoyucNTxFoQIFGWzp3qCIs/+Xc133+iP92+ lI0Hqe0NHn8L7/KFSwKvXLL45nf0LD8nhKi1T3sRnwoZCHnhQVTwKylLt3mr76/yDAs3 qS6RAaXz0mdQ+Kij9qn/ZwXujPkT1TdgPqfDd1KFv9fL6wSLeKK+IOLnzqUdNpS7fDRT TVPg== X-Gm-Message-State: AIkVDXL2T/9zJ/aQ20G9J5hcdI2NosrFr7V63JHSfGnSVOfKVLakfFX69AllHsiAqAfXRACq X-Received: by 10.237.59.213 with SMTP id s21mr5997270qte.146.1486010880542; Wed, 01 Feb 2017 20:48:00 -0800 (PST) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id y189sm20532696qky.39.2017.02.01.20.47.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Feb 2017 20:47:58 -0800 (PST) From: Anup Patel To: Vinod Koul , Rob Herring , Mark Rutland , Herbert Xu , "David S . Miller" , Jassi Brar Subject: [PATCH 1/6] mailbox: Add new API mbox_channel_device() for clients Date: Thu, 2 Feb 2017 10:17:11 +0530 Message-Id: <1486010836-25228-2-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486010836-25228-1-git-send-email-anup.patel@broadcom.com> References: <1486010836-25228-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170201_204922_282616_AE8F21C0 X-CRM114-Status: GOOD ( 12.09 ) 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, Anup Patel , Scott Branden , Jon Mason , Ray Jui , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-crypto@vger.kernel.org, Rob Rice , dmaengine@vger.kernel.org, Dan Williams , 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 The remote processor can have DMAENGINE capabilities and client can pass data to be processed via main memory. In such cases, the client will require DMAble memory for remote processor. This patch adds new API mbox_channel_device() which can be used by clients to get struct device pointer of underlying mailbox controller. This struct device pointer of mailbox controller can be used by clients to allocate DMAble memory for remote processor. Signed-off-by: Anup Patel Reviewed-by: Scott Branden Reviewed-by: Ray Jui --- drivers/mailbox/mailbox.c | 21 +++++++++++++++++++++ include/linux/mailbox_client.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 4671f8a..d4380fc 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -281,6 +281,27 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) EXPORT_SYMBOL_GPL(mbox_send_message); /** + * mbox_channel_device - Get device pointer of a mailbox channel. + * @chan: Mailbox channel assigned to this client. + * + * The remote processor can have DMAENGINE capabilities and client + * can pass data to be processed via main memory. In such cases, + * the client will require struct device pointer of the mailbox + * channel to map/unmap/allocate/free DMAble memory. + * + * Return: Pointer to the struct device of mailbox channel. + * ERR_PTR on failure. + */ +struct device *mbox_channel_device(struct mbox_chan *chan) +{ + if (!chan || !chan->cl) + return ERR_PTR(-EINVAL); + + return chan->mbox->dev; +} +EXPORT_SYMBOL_GPL(mbox_channel_device); + +/** * mbox_request_channel - Request a mailbox channel. * @cl: Identity of the client requesting the channel. * @index: Index of mailbox specifier in 'mboxes' property. diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index 4434871..3daffad 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -40,6 +40,7 @@ struct mbox_client { void (*tx_done)(struct mbox_client *cl, void *mssg, int r); }; +struct device *mbox_channel_device(struct mbox_chan *chan); struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, const char *name); struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index);