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: 9550979 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 DD02E60424 for ; Thu, 2 Feb 2017 04:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD2A528458 for ; Thu, 2 Feb 2017 04:48:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE3D82844A; Thu, 2 Feb 2017 04:48:07 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FB092844A for ; Thu, 2 Feb 2017 04:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751014AbdBBEsE (ORCPT ); Wed, 1 Feb 2017 23:48:04 -0500 Received: from mail-qt0-f181.google.com ([209.85.216.181]:33901 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990AbdBBEsB (ORCPT ); Wed, 1 Feb 2017 23:48:01 -0500 Received: by mail-qt0-f181.google.com with SMTP id w20so9805647qtb.1 for ; Wed, 01 Feb 2017 20:48: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=Oe+YcgLyQBi7kH+semS23FN01xpkdOXiqjW8A0RWMyT9V4MgBr2NFxHgq+gY4Wl2Lz KjlWFnCiwIPLKO1X1IGhm4WCH+HN6+ez3LkkpOcXnRszEz6hD1bTHdSI57pP3gXwlvyd NwAaHqLre+2vzscjlW+xRsRPiQSlnoPV+qTk1u6wv1NiktwoYfHnUff1me29JQyCJSO+ BDJ9Xz3tjy4qOqn+JNN4+pwBLbEQqi1rDlgTelXobYODCWuLCWnorUr/r2cHQj4hCpMq JaU22pj0ImLe1YaPOwtLeermNjt5nf+DhwrB3nJfI7uizgIO+ng9fGiNlVX1Ho9Ed9/H nLlQ== X-Gm-Message-State: AIkVDXJplMfHZVVXUaosX3/z2e08m2TJ+5Go67zZNCUf2c/UrsXmX1vOs5l1Bhj4B39NlcEO 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 Cc: Dan Williams , Ray Jui , Scott Branden , Jon Mason , Rob Rice , bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-raid@vger.kernel.org, Anup Patel 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> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.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);