public inbox for linux-arm-msm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V7 1/4] rpmsg: glink: Use complete_all for open states
       [not found] <1593017121-7953-1-git-send-email-deesin@codeaurora.org>
@ 2020-06-24 16:45 ` Deepak Kumar Singh
  2020-06-24 16:45 ` [PATCH V7 3/4] rpmsg: glink: Add support for rpmsg glink chrdev Deepak Kumar Singh
  2020-06-24 16:45 ` [PATCH V7 4/4] rpmsg: glink: Expose rpmsg name attr for glink Deepak Kumar Singh
  2 siblings, 0 replies; 3+ messages in thread
From: Deepak Kumar Singh @ 2020-06-24 16:45 UTC (permalink / raw)
  To: bjorn.andersson, clew, mathieu.poirier
  Cc: Deepak Kumar Singh, Arun Kumar Neelakantam, Andy Gross,
	Ohad Ben-Cohen, open list:ARM/QUALCOMM SUPPORT,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM, open list

From: Chris Lew <clew@codeaurora.org>

The open_req and open_ack completion variables are the state variables
to represet a remote channel as open. Use complete_all so there are no
races with waiters and using completion_done.

Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 1995f5b..d5114ab 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)
 		return -EINVAL;
 	}
 
-	complete(&channel->open_ack);
+	complete_all(&channel->open_ack);
 
 	return 0;
 }
@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
 	__be32 *val = defaults;
 	int size;
 
-	if (glink->intentless)
+	if (glink->intentless || !completion_done(&channel->open_ack))
 		return 0;
 
 	prop = of_find_property(np, "qcom,intents", NULL);
@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
 	channel->rcid = ret;
 	spin_unlock_irqrestore(&glink->idr_lock, flags);
 
-	complete(&channel->open_req);
+	complete_all(&channel->open_req);
 
 	if (create_device) {
 		rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH V7 3/4] rpmsg: glink: Add support for rpmsg glink chrdev
       [not found] <1593017121-7953-1-git-send-email-deesin@codeaurora.org>
  2020-06-24 16:45 ` [PATCH V7 1/4] rpmsg: glink: Use complete_all for open states Deepak Kumar Singh
@ 2020-06-24 16:45 ` Deepak Kumar Singh
  2020-06-24 16:45 ` [PATCH V7 4/4] rpmsg: glink: Expose rpmsg name attr for glink Deepak Kumar Singh
  2 siblings, 0 replies; 3+ messages in thread
From: Deepak Kumar Singh @ 2020-06-24 16:45 UTC (permalink / raw)
  To: bjorn.andersson, clew, mathieu.poirier
  Cc: Deepak Kumar Singh, Arun Kumar Neelakantam, Andy Gross,
	Ohad Ben-Cohen, open list:ARM/QUALCOMM SUPPORT,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM, open list

RPMSG provides a char device interface to userspace. Probe the rpmsg
chrdev channel to enable the rpmsg_ctrl device creation on glink
transports.

Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index d5114ab..3a7f87c 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -1574,6 +1574,40 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink)
 		kfree(dcmd);
 }
 
+static void qcom_glink_device_release(struct device *dev)
+{
+	struct rpmsg_device *rpdev = to_rpmsg_device(dev);
+	struct glink_channel *channel = to_glink_channel(rpdev->ept);
+
+	/* Release qcom_glink_alloc_channel() reference */
+	kref_put(&channel->refcount, qcom_glink_channel_release);
+	kfree(rpdev);
+}
+
+static int qcom_glink_create_chrdev(struct qcom_glink *glink)
+{
+	struct rpmsg_device *rpdev;
+	struct glink_channel *channel;
+
+	rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL);
+	if (!rpdev)
+		return -ENOMEM;
+
+	channel = qcom_glink_alloc_channel(glink, "rpmsg_chrdev");
+	if (IS_ERR(channel)) {
+		kfree(rpdev);
+		return PTR_ERR(channel);
+	}
+	channel->rpdev = rpdev;
+
+	rpdev->ept = &channel->ept;
+	rpdev->ops = &glink_device_ops;
+	rpdev->dev.parent = glink->dev;
+	rpdev->dev.release = qcom_glink_device_release;
+
+	return rpmsg_chrdev_register_device(rpdev);
+}
+
 struct qcom_glink *qcom_glink_native_probe(struct device *dev,
 					   unsigned long features,
 					   struct qcom_glink_pipe *rx,
@@ -1633,6 +1667,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
 	if (ret)
 		return ERR_PTR(ret);
 
+	ret = qcom_glink_create_chrdev(glink);
+	if (ret)
+		dev_err(glink->dev, "failed to register chrdev\n");
+
 	return glink;
 }
 EXPORT_SYMBOL_GPL(qcom_glink_native_probe);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH V7 4/4] rpmsg: glink: Expose rpmsg name attr for glink
       [not found] <1593017121-7953-1-git-send-email-deesin@codeaurora.org>
  2020-06-24 16:45 ` [PATCH V7 1/4] rpmsg: glink: Use complete_all for open states Deepak Kumar Singh
  2020-06-24 16:45 ` [PATCH V7 3/4] rpmsg: glink: Add support for rpmsg glink chrdev Deepak Kumar Singh
@ 2020-06-24 16:45 ` Deepak Kumar Singh
  2 siblings, 0 replies; 3+ messages in thread
From: Deepak Kumar Singh @ 2020-06-24 16:45 UTC (permalink / raw)
  To: bjorn.andersson, clew, mathieu.poirier
  Cc: Deepak Kumar Singh, Arun Kumar Neelakantam, Andy Gross,
	Ohad Ben-Cohen, open list:ARM/QUALCOMM SUPPORT,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM, open list

From: Chris Lew <clew@codeaurora.org>

Expose the name field as an attr so clients listening to uevents for
rpmsg can identify the edge the events correspond to.

Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 3a7f87c..0e8a28c0 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -1574,6 +1574,26 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink)
 		kfree(dcmd);
 }
 
+static ssize_t rpmsg_name_show(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	int ret = 0;
+	const char *name;
+
+	ret = of_property_read_string(dev->of_node, "label", &name);
+	if (ret < 0)
+		name = dev->of_node->name;
+
+	return snprintf(buf, RPMSG_NAME_SIZE, "%s\n", name);
+}
+static DEVICE_ATTR_RO(rpmsg_name);
+
+static struct attribute *qcom_glink_attrs[] = {
+	&dev_attr_rpmsg_name.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(qcom_glink);
+
 static void qcom_glink_device_release(struct device *dev)
 {
 	struct rpmsg_device *rpdev = to_rpmsg_device(dev);
@@ -1638,6 +1658,12 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
 	idr_init(&glink->lcids);
 	idr_init(&glink->rcids);
 
+	glink->dev->groups = qcom_glink_groups;
+
+	ret = device_add_groups(dev, qcom_glink_groups);
+	if (ret)
+		dev_err(dev, "failed to add groups\n");
+
 	ret = of_property_read_string(dev->of_node, "label", &glink->name);
 	if (ret < 0)
 		glink->name = dev->of_node->name;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-24 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1593017121-7953-1-git-send-email-deesin@codeaurora.org>
2020-06-24 16:45 ` [PATCH V7 1/4] rpmsg: glink: Use complete_all for open states Deepak Kumar Singh
2020-06-24 16:45 ` [PATCH V7 3/4] rpmsg: glink: Add support for rpmsg glink chrdev Deepak Kumar Singh
2020-06-24 16:45 ` [PATCH V7 4/4] rpmsg: glink: Expose rpmsg name attr for glink Deepak Kumar Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox