Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbdLFMIK (ORCPT ); Wed, 6 Dec 2017 07:08:10 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50722 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbdLFMII (ORCPT ); Wed, 6 Dec 2017 07:08:08 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8AB7660215 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=shajit@codeaurora.org Subject: Re: [PATCH] rpmsg: qcom_smd: Access APCS through mailbox framework To: Bjorn Andersson , Ohad Ben-Cohen Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20171116070842.6362-1-bjorn.andersson@linaro.org> From: Jitendra Sharma Message-ID: Date: Wed, 6 Dec 2017 17:38:02 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171116070842.6362-1-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4462 Lines: 132 Hi Bjorn, On 11/16/2017 12:38 PM, Bjorn Andersson wrote: > 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(-) > > 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_send_message could fail. So return value should be checked > + 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;