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: 9550983 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 C310060424 for ; Thu, 2 Feb 2017 04:48:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B16BA2844A for ; Thu, 2 Feb 2017 04:48:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5DD12845F; Thu, 2 Feb 2017 04:48:10 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 5B4E52844A for ; Thu, 2 Feb 2017 04:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751055AbdBBEsI (ORCPT ); Wed, 1 Feb 2017 23:48:08 -0500 Received: from mail-qt0-f169.google.com ([209.85.216.169]:33466 "EHLO mail-qt0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbdBBEsG (ORCPT ); Wed, 1 Feb 2017 23:48:06 -0500 Received: by mail-qt0-f169.google.com with SMTP id v23so9927302qtb.0 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=uOJyeknfB8Z68uAcLe0IV3nPBq15wHEPeJz2VBCT9yVa4foz+Xtr5TxdzMbjxB6GxU Eqtvvmly/dJlCQgX0/C+qI4w0YFIOo4/2/66/aQshyIfJ7HaXoOjpysAmISf3AczpTQy V2F+lHAlLchlxFfk/iXErM7buSSKlaavg/CqDsXqRL8mF1bx1XRoEKiJK3XqfKbys3ET NnDyoWZonLTd2INJ/m3HZ1wreLjBjyiXVxuiCaej4+Q10hXGSeVvKRHvVLbE8bEpvU0f BzTNkkuE7EkBnsgCr3kch4PrUATDyPFlFXz2kwWOomCGAI6azxxtZ3pahV0z7AeDRs/A hagA== X-Gm-Message-State: AIkVDXL7f+CTifUuH0xEJLcno8vwGpHts8vuplWbbp0rL/c3XcxjmWJhTdISB5t7RlZPeB1i 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: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@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);