From patchwork Thu Nov 16 07:08:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 119019 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5247736qgn; Wed, 15 Nov 2017 23:08:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMb3f+UHpb/k5wfEKikXF7SytayTz2n5hAMQeyygEy9PrpRz/QbrGH3VRPPofsOJddbTLYiI X-Received: by 10.159.255.5 with SMTP id bi5mr743916plb.217.1510816131192; Wed, 15 Nov 2017 23:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510816131; cv=none; d=google.com; s=arc-20160816; b=JTUW2V7yWOfbWMw98qvwO97fF51k8U2pj59r8axTzkNBt5quLRx9E/X0Q6O/2BGdiG mfCUzTyeA4mIJBuVFCzFxG5ogFG8uRebvKgvo1Bi9QkrgMw+4ENTqcQkc1FI8S31rRXx ewNDFh5qVUjhx7J2JOVJPgnhlrFuXH40roeHRXkisH8M3I3yZOyYT3qHR33TH20Dq80b ABxoeUxrDgrIKDQorNtghFZ5jIitdhwhP8pC+M3CGKTuX9NvngActLyqFGN6ZYY4sXUM ri4QidtGVAgYAXI02zAY2qMZzZGJGboVmUbTBQQBc+ETmJfH1Qb1zL6NzfPyUePUVQsV e+9Q== 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=TphyeZYiCtALEGGmCd8/QJbaDcMPC7I8h22DupIBTjE=; b=BznJEAU3sZRLevmKJGygaJPAypwFQjxFMk5TjkFk24AqrZ4cEp+FoUl4YN+8iWCchY dIDI5pLyFvl4/iNMPfux+9kYrQoi/xN5D2jd1e1h+cEBUf+c7Ir2XIQviTIT2ZNjJOzv 7ggmLHgEO3oeWZVWAJvYlEoSvHMHFMPY+8qnRRQxy2UHZyCQ/quvItpgqhuMgJriIDWo NyZvRSrdC36gL6KAlyT1JvQC26CtGikiyE6PfY0FGSKbHOvcXlnJr48w8lfyBZE4WcvM T3QyCFxJlLdH/vhF2XDujLH7+e9Ml2YT1Bua4qMVOYw14jxzo+eAoQwZTsyS8ky+XbgV RqBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B7dofeG2; 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 e91si402364plb.216.2017.11.15.23.08.49; Wed, 15 Nov 2017 23:08:51 -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=B7dofeG2; 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 S1758850AbdKPHIr (ORCPT + 10 others); Thu, 16 Nov 2017 02:08:47 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:51268 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbdKPHIr (ORCPT ); Thu, 16 Nov 2017 02:08:47 -0500 Received: by mail-pf0-f196.google.com with SMTP id j28so16654036pfk.8 for ; Wed, 15 Nov 2017 23:08:47 -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=/HvBI5n+UiqZZFbekI/cwJFB0hX3MZ7jAH/Tl5wfirY=; b=B7dofeG2ki2fhpXiGn+DI879k3i7kJcFUtFXyR1a4SkMIUyB70Aqtb3CNAJfB1y2Bs AKlUipLjFjMgvMga1z0G5otf5HWidLGKAcJQXokKqDJteP4vOHdScFdW1Hf93SFeSv5D hraGAk3o3YcJ956e4UaegfhzAb8F+aQVe0Bfs= 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=/HvBI5n+UiqZZFbekI/cwJFB0hX3MZ7jAH/Tl5wfirY=; b=aB4R3GEctdtJONOdqjOb+9eXuXwUgXTyfdBhxj85j1kJTPCOIfmxOQUm9Ot3EVM3Ms cpJrq96gXSkccAwMbyBCNQpQw1f1Qn0p0B7TYlMM/Kn6ucVnh6pvGuKwKVofmUMsrfAw MaFzvMbSGD70oxNDXnySIhsMcDaYO7O/KQMtMNIqoPbB6LFegDHOiZz3h9PRLi3BZ+oD +jXYBy43Jxx1ChZjO+gwBRi+BLuAe+T1LMWZCB4WsGh4vQ8sjNvVCANM1PKX4S/PIbX2 K3gwbtexiM1pbEVnlfgd0npk8Bb1IDQyUM5P9u1/HtI8nwIDSiBL/0s8wvH1EiX7tUjI MrdQ== X-Gm-Message-State: AJaThX6rcQ/fakrDRI9Go26McYxVmEeH9+cTaozaFqOA4FcmwjNUEC1I t7aSyv1KTuGHMR2SuSVDzE/Dfg== X-Received: by 10.98.163.73 with SMTP id s70mr830762pfe.64.1510816126525; Wed, 15 Nov 2017 23:08:46 -0800 (PST) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id f7sm1117268pfa.133.2017.11.15.23.08.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 23:08:45 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] rpmsg: qcom_smd: Access APCS through mailbox framework Date: Wed, 15 Nov 2017 23:08:42 -0800 Message-Id: <20171116070842.6362-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. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_smd.c | 62 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 19 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 Reviewed-by: Arun Kumar Neelakantam 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;