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: 40466 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C8AC6205D8 for ; Sun, 9 Nov 2014 13:18:57 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id x13sf3168404wgg.5 for ; Sun, 09 Nov 2014 05:18:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=8Zyy8dfxlWgD8bc/iBLzDZHTlT6Tpqu6ouXOEsfByyQ=; b=VnugL9GaOefBOQhARrVPX/eewlwqV9IQjFiDNquDa7udsHN4S3YkeMHpNCAKzol+O0 NnW+rMChO3aMUWv6+iyzYrotBCECItjSDrKFhjgvr2+1FdJd918BVknFceszI3QMnXVz LMBTz1w/VA8TomMVVKtCXq3P8Oo8KwRrayk611jJbJVrt4fS7gSveLHzTfeuokXojc13 M96nNPsuzy+50zPVCuo4fL5tgSC7TJRBPI7OvT7tPsXYHR2cRV9cl+Ja1begSVhWg14I Z2YmZjrZir13hftsDaQqaK83KUO8/aNQL8xzkCKtO/PaAQPRUTGfAAWAAb+tDoUCwKrk 0tyA== X-Gm-Message-State: ALoCoQlTByNOwg1b/IgNtGcA8HJrGLqNyX4WhURDSsAz06ZAN9t5G5BuaFpZzS2iyMElv72XB3OE X-Received: by 10.194.176.106 with SMTP id ch10mr381192wjc.6.1415539136682; Sun, 09 Nov 2014 05:18:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.227 with SMTP id e3ls373087laa.69.gmail; Sun, 09 Nov 2014 05:18:56 -0800 (PST) X-Received: by 10.152.5.201 with SMTP id u9mr23646680lau.24.1415539136325; Sun, 09 Nov 2014 05:18:56 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id ke10si23463209lbc.41.2014.11.09.05.18.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Nov 2014 05:18:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id ge10so6550524lab.16 for ; Sun, 09 Nov 2014 05:18:55 -0800 (PST) X-Received: by 10.112.202.104 with SMTP id kh8mr23711711lbc.46.1415539135823; Sun, 09 Nov 2014 05:18:55 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp446192lbc; Sun, 9 Nov 2014 05:18:54 -0800 (PST) X-Received: by 10.70.91.10 with SMTP id ca10mr25968546pdb.6.1415539134193; Sun, 09 Nov 2014 05:18:54 -0800 (PST) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com. [209.85.192.170]) by mx.google.com with ESMTPS id dk3si14048873pbd.43.2014.11.09.05.18.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Nov 2014 05:18:54 -0800 (PST) Received-SPF: pass (google.com: domain of jaswinder.singh@linaro.org designates 209.85.192.170 as permitted sender) client-ip=209.85.192.170; Received: by mail-pd0-f170.google.com with SMTP id z10so6163215pdj.1 for ; Sun, 09 Nov 2014 05:18:53 -0800 (PST) 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jaswinder.singh@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;