From patchwork Fri Apr 20 01:17:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 133848 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp150844ljf; Thu, 19 Apr 2018 18:18:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx48IHQDe1COlfrvBWsFBgwvcD4fSpj+2ePX5k5WjgEQlZ90m+9IxHHzfJsY+aAaan6LYdiD7 X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr8221026plc.384.1524187086563; Thu, 19 Apr 2018 18:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524187086; cv=none; d=google.com; s=arc-20160816; b=oft7oU8nJYe++tCTGx9sG9uLqcbqQO1hBTs/0L4wOabh9VMY/CoxSNbPax7iGKf3Oh fy00ivo0XoFQKhqWKq1/4W7VNFQ3k7V4e3o1pahQOPHunxQH2qYzA5KbCpANwFRSsmvn bjVbukfTuM7AY5YHfRT+ln5v43HTj2dvN69StLULrPd6BmUchMiPOCdHyNaIb5oXgA8s cJ92oHzb0/zPZay9QWfX6mrZNAxQEOlRmBd1Ly0MBXT/1n6hmsrHfkxz13vZvnp1qPsC NveWRNXqT9q4DeVy1MYbuokzmYXcYSIk+1WbjuFEKmteAAz90trGLnSNWZ0IZqqyFaWW J2hw== 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=kdOLnBVILzPM/wdOmBxLjuPc8s2uPnJ2ada4LSa8X8I=; b=ZBIW1gKenjSvKLFwomKP8EzKo0a9PlvykZp6SoagrquZSakYirjjzJZb6DuZi35EOV MvtM/LbleYf/XzopCBzjKd7vboyfJLZW7/qj/IXzdZbe0hyArzIcUbxUA37hf26whRf0 NO/VZ20uhi7ZkJ9WB70oE/aq9EsYusE1WDuBcsFiYjOjx+bAd2Tc3wmQuwneyP2DmOFE n3UyWny95G8yQOinSJF1EV3Zo+kLbGjb2hlVkSte8q4mCkIYs5gkruJZvVoFCjzvvxVB ENKW2PH/J03Vu61QvqXQpI1svuq8MNB3Cho0A9qdNnCZFyr5iL+0Rzsi4lnC5xK2XlID W0TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IcZMAdjx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 z8si4008639pgc.617.2018.04.19.18.18.06; Thu, 19 Apr 2018 18:18:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=IcZMAdjx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1754049AbeDTBSF (ORCPT + 6 others); Thu, 19 Apr 2018 21:18:05 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34070 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753769AbeDTBSD (ORCPT ); Thu, 19 Apr 2018 21:18:03 -0400 Received: by mail-pl0-f66.google.com with SMTP id z12-v6so4286969plo.1 for ; Thu, 19 Apr 2018 18:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=q/9nI734M0BqGFm5Oooi8Wv/+5TKYN/ZKgK0dOZvoyo=; b=IcZMAdjxOt2gp2qcI9w+8YSLpEMp1rGGvlndNXlZt/gfr0VxhLi4rUMd8Qy6HC7TnR 0OMrytfRLttYbFYOUelzLm+e2qLDnO8LuLBpEZyN4Kwq3JkH64xx3AT4iPzjDRJEGAFY HenaQBviRSBJAxugtdkJKzkqKsK23N7X9amiE= 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=q/9nI734M0BqGFm5Oooi8Wv/+5TKYN/ZKgK0dOZvoyo=; b=BlCrTUpqZm8Z3qDbBBJ3UkQw4RAER3a7CeAudoA8JNe33lTFEkb11YuhBhYCuGB+SV wLpXVvUgdGKzpdDfRAAC+nsWZ0Pv5f13KUzGsb/71F5KiT9D/978Ize73maV5oLexXst ZCY4o9agK0iyQ7eKgrrmqhaRrV2ge666kmZPW/Qf+l0s3BmuBgsnhCZFjQKSWtujaX2m ND9IuKoFp9GiC2SJVUMZkTnUnFPRWXrnxd+XZr0TlCHcH4afPGlVjViYQHGVLF6nCGyl sVUdy7Kze60H9bkDJ+YB7ltmbVJeEci/xf6Id5HpcSqpfLHGHM1AvZqdWSJ+ov6QBYFX 4mQg== X-Gm-Message-State: ALQs6tAN5VAgJ1VNSUiJQBffpmUVwgbyAgQuhCZKAEBsnQ+y9orRQHX8 DgjExyEenPd2snH+uy/EAr6dkQ== X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr8308633plb.42.1524187082849; Thu, 19 Apr 2018 18:18:02 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id o2sm8613686pgq.87.2018.04.19.18.18.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 18:18:02 -0700 (PDT) From: Bjorn Andersson To: Rob Herring , Bjorn Andersson Cc: Mark Rutland , Ohad Ben-Cohen , 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, Nicolas Dechesne Subject: [PATCH v3] rpmsg: qcom_smd: Access APCS through mailbox framework Date: Thu, 19 Apr 2018 18:17:57 -0700 Message-Id: <20180420011757.22389-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.16.2 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 v2: - Added comment about mbox_send_message() return value. .../devicetree/bindings/soc/qcom/qcom,smd.txt | 8 ++- drivers/rpmsg/Kconfig | 1 + drivers/rpmsg/qcom_smd.c | 67 ++++++++++++++++------ 3 files changed, 56 insertions(+), 20 deletions(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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 0fe6eac46512..2e4fb4ffd562 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 bc0b30657230..3ff271a44bef 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; @@ -366,7 +372,17 @@ 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) { + /* + * We can ignore a failing mbox_send_message() as the only + * possible cause is that the FIFO in the framework is full of + * other writes to the same bit. + */ + 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)); + } } /* @@ -1326,27 +1342,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); @@ -1452,6 +1478,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); } @@ -1480,6 +1508,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;