From patchwork Sun Nov 9 13:18:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 5260451 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7235A9F295 for ; Sun, 9 Nov 2014 13:18:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 771C420127 for ; Sun, 9 Nov 2014 13:18:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FFD52012D for ; Sun, 9 Nov 2014 13:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751600AbaKINSz (ORCPT ); Sun, 9 Nov 2014 08:18:55 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:54086 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465AbaKINSx (ORCPT ); Sun, 9 Nov 2014 08:18:53 -0500 Received: by mail-pd0-f174.google.com with SMTP id p10so6087332pdj.5 for ; Sun, 09 Nov 2014 05:18:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8Zyy8dfxlWgD8bc/iBLzDZHTlT6Tpqu6ouXOEsfByyQ=; b=JF4j1bBf3FduIAWrB9d6D1P1DZcKBxzD502Ksw9AeXrdNHevv4Zsev1JRXVK6MkNZ7 JFBms10Py7G94Ce13Aq7gKtH0qK4W/h4fgl764KdVm8/KjCy3bkOVD+LGquxXBg2PWxv Yi0WrZMEfrm42KUfUBhhBJyJYvO0+poXbdXjqRqDhpHRO71JvazlKCN4qnKVBFMOml2U Q6W2r4p7sdrtRbifAiNxnVXlsJmSEpNgIrT7Yko+JScQUG1PjO9rt3pIGYTnVus5luKE M85JgKbxKkuc5naMUdozknKbIKpQ3E1sRQPmZf3irWuDUA81QwZenEOOKvSp+TXSkIU2 qx8w== X-Gm-Message-State: ALoCoQlGK6DmtM+L7ClMuc53AeA7Q/52uRcDSzq2+vwyUxMRNkqZ1ZwEfYGC+RO3aCUC4HksmYR6 X-Received: by 10.68.185.98 with SMTP id fb2mr826531pbc.142.1415539133356; Sun, 09 Nov 2014 05:18:53 -0800 (PST) Received: from localhost.localdomain ([117.205.44.193]) by mx.google.com with ESMTPSA id oq6sm13850719pdb.45.2014.11.09.05.18.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Nov 2014 05:18:52 -0800 (PST) From: Jassi Brar To: ashwin.chaugule@linaro.org, linux-kernel@vger.kernel.org Cc: broonie@kernel.org, patches@linaro.org, linux-acpi@vger.kernel.org, rjw@rjwysocki.net, arnd@arndb.de, lv.zheng@intel.com, linaro-acpi@lists.linaro.org, Jassi Brar Subject: [PATCH] mailbox: enable non-DT/ACPI clients to use the api Date: Sun, 9 Nov 2014 18:48:25 +0530 Message-Id: <1415539105-4213-1-git-send-email-jaswinder.singh@linaro.org> X-Mailer: git-send-email 1.8.1.2 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Mailbox API so far discounted controllers and clients that may not have a DT based channel mapping capability, as in ACPI. Allow such mailbox clients to ask for a mailbox channel by simply specifying a token. The token would be globally unique among channels provided by such controllers... which shouldn't be a problem because practically non-DT means ACPI and ACPI specifies just one controller instance called the Platform Communications Channel (PCC) that could have max 256 subspaces (channels or mailboxes). So this is simply going to be the value from 'Signature' field (first 4bytes) of the SharedMemory Region corresponding to the subspace/channel the client is interested in. Signed-off-by: Jassi Brar --- drivers/mailbox/mailbox.c | 50 +++++++++++++++++++++----------------- include/linux/mailbox_controller.h | 7 ++++++ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index afcb430..8260451 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -296,36 +296,42 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) { struct device *dev = cl->dev; struct mbox_controller *mbox; - struct of_phandle_args spec; - struct mbox_chan *chan; + struct mbox_chan *chan = NULL; unsigned long flags; int ret; - if (!dev || !dev->of_node) { - pr_debug("%s: No owner device node\n", __func__); - return ERR_PTR(-ENODEV); - } - mutex_lock(&con_mutex); - if (of_parse_phandle_with_args(dev->of_node, "mboxes", - "#mbox-cells", index, &spec)) { - dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); - mutex_unlock(&con_mutex); - return ERR_PTR(-ENODEV); - } - - chan = NULL; - list_for_each_entry(mbox, &mbox_cons, node) - if (mbox->dev->of_node == spec.np) { - chan = mbox->of_xlate(mbox, &spec); - break; + if (!dev || !dev->of_node) { /* If it's an ACPI client */ + list_for_each_entry(mbox, &mbox_cons, node) { + if (!mbox->global_xlate) + continue; + chan = mbox->global_xlate(mbox, index); + if (chan && !chan->cl) + break; + } + } else { + struct of_phandle_args spec; + + if (of_parse_phandle_with_args(dev->of_node, "mboxes", + "#mbox-cells", index, &spec)) { + dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", + __func__); + mutex_unlock(&con_mutex); + return ERR_PTR(-ENODEV); } - of_node_put(spec.np); + list_for_each_entry(mbox, &mbox_cons, node) + if (mbox->dev->of_node == spec.np) { + chan = mbox->of_xlate(mbox, &spec); + break; + } + + of_node_put(spec.np); + } if (!chan || chan->cl || !try_module_get(mbox->dev->driver->owner)) { - dev_dbg(dev, "%s: mailbox not free\n", __func__); + pr_err("%s: mailbox not available\n", __func__); mutex_unlock(&con_mutex); return ERR_PTR(-EBUSY); } @@ -344,7 +350,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) ret = chan->mbox->ops->startup(chan); if (ret) { - dev_err(dev, "Unable to startup the chan (%d)\n", ret); + pr_err("Unable to startup the chan (%d)\n", ret); mbox_free_channel(chan); chan = ERR_PTR(ret); } diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index d4cf96f..76871b2 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -67,6 +67,11 @@ struct mbox_chan_ops { * @txpoll_period: If 'txdone_poll' is in effect, the API polls for * last TX's status after these many millisecs * @of_xlate: Controller driver specific mapping of channel via DT + * @global_xlate: Controller driver specific mapping of channel for + * non-DT based clients (like ACPI). The 'global_id' + * argument is a token to uniquely identify the mbox_chan + * fromm those provided by more than one such controllers. + * 'of_xlate' takes precedence for DT based clients. * @poll: API private. Used to poll for TXDONE on all channels. * @node: API private. To hook into list of controllers. */ @@ -80,6 +85,8 @@ struct mbox_controller { unsigned txpoll_period; struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox, const struct of_phandle_args *sp); + struct mbox_chan *(*global_xlate)(struct mbox_controller *mbox, + int global_id); /* Internal to API */ struct timer_list poll; struct list_head node;