From patchwork Thu Nov 30 00:02:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 120052 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp15771qgn; Wed, 29 Nov 2017 16:02:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMbaju+DXAj4mRZBJtWWxW7Z1uiYv054+Fp5TEuxKUXYYlDYezifUdSZnllpxdCodRHGnJuu X-Received: by 10.84.131.35 with SMTP id 32mr584891pld.347.1512000169646; Wed, 29 Nov 2017 16:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512000169; cv=none; d=google.com; s=arc-20160816; b=kcsV/TPJDXL2i+dF4Iq0f5rs5J383ELcwR81bhtA+UF+s789Zo1+8m2giC/vr6Eo/y dK+979vfXtNBqMEKXHLoW8hr8q/RTgWDPjqP92afaKpMLG+1tBRAQw01RgBBmzqPChAS Esdy3+nfRRfvR12GxCh6/YwAyaYlxjOzYdi4vz5N99k3sFfYPL2VyPbrnB3PKUiKvSG/ CtibWJOFLRdHj8xZiX7CMUWgFBaioW4xDYVBeL+k4CdoXE8DleyoZnNKgaGhkb7FQevr xDebu/x4aA93kyYVLAMz3CjR5D5yr6N6vXsst5XZ42s8GhAmieARMBqd93CkNEJz3jXH ZO4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PHQeVxG0bnLSoCBc6E+zZ+kMLifvdl76f8S/XuNV4qg=; b=E983QkSjzBGw3WcEmjo9PQUf34aOSFkmuKnvplUnUaJbWUf2ZQa5Gz4MrxfHdCUEb6 EIRUsawhfY19dyUpOVheIzTMbXVnusHli0C9dVBlI/6jFUgOzikhu2hCoXB5O24YzwiK W92wCDXqr+ILi+zfYZGIebzDT60fV4LdpzXOzIm8ILB6GAWXys5WfoJqVZKsprqS28r4 f7F2repg+I12TG4Cnmu9WFM5w1TxHajSYFPj2CSJmqsJyyHJi0Jeqgm7y4FvOuKBtaLo hZ59ve9HEpNARDHuBwZtXeDQD0sefpUQXYqDcn9Mrp8QRBX6ifLcuQp9qU1yhiAV4z3z /DTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ab2HIPOe; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l187si2026716pga.371.2017.11.29.16.02.41; Wed, 29 Nov 2017 16:02:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ab2HIPOe; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753242AbdK3ACk (ORCPT + 10 others); Wed, 29 Nov 2017 19:02:40 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:32862 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbdK3ACi (ORCPT ); Wed, 29 Nov 2017 19:02:38 -0500 Received: by mail-pl0-f67.google.com with SMTP id q7so3119750plk.0 for ; Wed, 29 Nov 2017 16:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lOYsjc9t3D/+4VNt1yPh0zMprNBOZ+8S5AWD3OHLGrU=; b=ab2HIPOe0wGA2hZWpAm25Wu2sZBiZsSwJjb8Z5oQtO0zJzA1x+PWOs77VW+imNME1X 1lDY6Br/IJmsJFHM5z0jOHmMDKnFzajR96iXloMpXFvOQS244Xe/JmYhkCLHMg1UJQLw M9KlT1BXEC+WE1pjH6PQY5SSKLHvN39nSATQY= 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; bh=lOYsjc9t3D/+4VNt1yPh0zMprNBOZ+8S5AWD3OHLGrU=; b=dOZ8A9rBcWXpEEN/Xd9i2RoK4W9y45fcl/MFOBQsQzyAlBZyopJxsFC8Qlce4FsC3O OdJbzMajBZjR9Dz4pY9hyiWRtGmoWwHV48/t6CoT0ZbcH9GMtkDxx5k+3iae4hZGjmBS Nu7Fwb2wPJQbHElWbzZwh9G8R058Sx+d3cc+0NY20GVtTmSysEQCVkuvezd7JuPtnQrZ 2dx22NOTshCdVVKQfwTKExjin0P7NSEvCKAM7svO1v4v7Xc0XCQiK8Dof4ZWNaVuMNWX 21ikJ5IRPylSYj3c6p5uAAqk8BmuYUfwrRLzOiKa1nCoaD4B032JaWHey/RqMweUkjXj ndRw== X-Gm-Message-State: AJaThX4oYBCRir8ICFQzjy868zFIKqcgJ9yXh0437DpLsjJuYLLG4H27 CAcCJRBmjsw/ZBQHXeS44yYstg== X-Received: by 10.84.197.35 with SMTP id m32mr596944pld.255.1512000157951; Wed, 29 Nov 2017 16:02:37 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id f23sm5157323pfk.71.2017.11.29.16.02.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 16:02:37 -0800 (PST) From: Bjorn Andersson To: Rob Herring , Mark Rutland , Ohad Ben-Cohen , Bjorn Andersson Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org Subject: [PATCH v2] rpmsg: qcom_smd: Access APCS through mailbox framework Date: Wed, 29 Nov 2017 16:02:33 -0800 Message-Id: <20171130000233.23804-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Attempt to acquire the APCS IPC through the mailbox framework and fall back to the old syscon based approach, to allow us to move away from using the syscon. Reviewed-by: Arun Kumar Neelakantam Signed-off-by: Bjorn Andersson --- Changes since v1: - Added dt binding change .../devicetree/bindings/soc/qcom/qcom,smd.txt | 8 ++- drivers/rpmsg/Kconfig | 1 + drivers/rpmsg/qcom_smd.c | 62 +++++++++++++++------- 3 files changed, 51 insertions(+), 20 deletions(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt index ea1dc75ec9ea..234ae2256501 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt @@ -22,9 +22,15 @@ The edge is described by the following properties: Definition: should specify the IRQ used by the remote processor to signal this processor about communication related updates -- qcom,ipc: +- mboxes: Usage: required Value type: + Definition: reference to the associated doorbell in APCS, as described + in mailbox/mailbox.txt + +- qcom,ipc: + Usage: required, unless mboxes is specified + Value type: Definition: three entries specifying the outgoing ipc bit used for signaling the remote processor: - phandle to a syscon node representing the apcs registers diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 65a9f6b892f0..9b14090e3603 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -39,6 +39,7 @@ config RPMSG_QCOM_GLINK_SMEM config RPMSG_QCOM_SMD tristate "Qualcomm Shared Memory Driver (SMD)" + depends on MAILBOX depends on QCOM_SMEM select RPMSG help diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index b01774e9fac0..ef2a526ebc8f 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -107,6 +108,8 @@ static const struct { * @ipc_regmap: regmap handle holding the outgoing ipc register * @ipc_offset: offset within @ipc_regmap of the register for ipc * @ipc_bit: bit in the register at @ipc_offset of @ipc_regmap + * @mbox_client: mailbox client handle + * @mbox_chan: apcs ipc mailbox channel handle * @channels: list of all channels detected on this edge * @channels_lock: guard for modifications of @channels * @allocated: array of bitmaps representing already allocated channels @@ -129,6 +132,9 @@ struct qcom_smd_edge { int ipc_offset; int ipc_bit; + struct mbox_client mbox_client; + struct mbox_chan *mbox_chan; + struct list_head channels; spinlock_t channels_lock; @@ -365,7 +371,12 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel) { struct qcom_smd_edge *edge = channel->edge; - regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit)); + if (edge->mbox_chan) { + mbox_send_message(edge->mbox_chan, NULL); + mbox_client_txdone(edge->mbox_chan, 0); + } else { + regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit)); + } } /* @@ -1268,27 +1279,37 @@ static int qcom_smd_parse_edge(struct device *dev, key = "qcom,remote-pid"; of_property_read_u32(node, key, &edge->remote_pid); - syscon_np = of_parse_phandle(node, "qcom,ipc", 0); - if (!syscon_np) { - dev_err(dev, "no qcom,ipc node\n"); - return -ENODEV; - } + edge->mbox_client.dev = dev; + edge->mbox_client.knows_txdone = true; + edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0); + if (IS_ERR(edge->mbox_chan)) { + if (PTR_ERR(edge->mbox_chan) != -ENODEV) + return PTR_ERR(edge->mbox_chan); - edge->ipc_regmap = syscon_node_to_regmap(syscon_np); - if (IS_ERR(edge->ipc_regmap)) - return PTR_ERR(edge->ipc_regmap); + edge->mbox_chan = NULL; - key = "qcom,ipc"; - ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset); - if (ret < 0) { - dev_err(dev, "no offset in %s\n", key); - return -EINVAL; - } + syscon_np = of_parse_phandle(node, "qcom,ipc", 0); + if (!syscon_np) { + dev_err(dev, "no qcom,ipc node\n"); + return -ENODEV; + } - ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit); - if (ret < 0) { - dev_err(dev, "no bit in %s\n", key); - return -EINVAL; + edge->ipc_regmap = syscon_node_to_regmap(syscon_np); + if (IS_ERR(edge->ipc_regmap)) + return PTR_ERR(edge->ipc_regmap); + + key = "qcom,ipc"; + ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset); + if (ret < 0) { + dev_err(dev, "no offset in %s\n", key); + return -EINVAL; + } + + ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit); + if (ret < 0) { + dev_err(dev, "no bit in %s\n", key); + return -EINVAL; + } } ret = of_property_read_string(node, "label", &edge->name); @@ -1394,6 +1415,8 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent, return edge; unregister_dev: + if (!IS_ERR_OR_NULL(edge->mbox_chan)) + mbox_free_channel(edge->mbox_chan); put_device(&edge->dev); return ERR_PTR(ret); } @@ -1422,6 +1445,7 @@ int qcom_smd_unregister_edge(struct qcom_smd_edge *edge) if (ret) dev_warn(&edge->dev, "can't remove smd device: %d\n", ret); + mbox_free_channel(edge->mbox_chan); device_unregister(&edge->dev); return 0;