Skip to contentSkip to conversation

rpmsg: glink: Use complete_all for open states

PATCH Applied Deepak Kumar Singh 4 participants 8 messages Jun 24, 2020 – Sep 15, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v7 1/4 rpmsg: glink: Use complete_all for open states

From: Chris Lew <[email protected]>

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.

---
 drivers/rpmsg/qcom_glink_native.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rpmsg/qcom_glink_native.c +3 -3
index 1995f5b..d5114ab 100644
@@ -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);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw
This series was applied to andersson/remoteproc.git (refs/heads/for-next).

Hello:

This series was applied to andersson/remoteproc.git (refs/heads/for-next).

Quoted 11 lines · On Wed, 24 Jun 2020 22:15:18 +0530 you wrote:

From: Chris Lew <[email protected]>

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.

[...]

Here is a summary with links:
- [V7,1/4] rpmsg: glink: Use complete_all for open states

    https://git.kernel.org/andersson/remoteproc/c/4fcdaf6e28d11e2f3820d54dd23cd12a47ddd44e
  - [V7,2/4] rpmsg: Guard against null endpoint ops in destroy
    https://git.kernel.org/andersson/remoteproc/c/d5158cda9e7b66fd412815df32e58943b7383f0c
  - [V7,3/4] rpmsg: glink: Add support for rpmsg glink chrdev
    https://git.kernel.org/andersson/remoteproc/c/0f579e52472198cec2d3d794a26e277c84e9dbd2
  - [V7,4/4] rpmsg: glink: Expose rpmsg name attr for glink
    https://git.kernel.org/andersson/remoteproc/c/4e3dda0bc603c1ca84680a56bfc49e8fe2519c89

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot
#3 lore raw

PATCH v7 2/4 rpmsg: Guard against null endpoint ops in destroy

In reply to a message not in the archive

From: Chris Lew <[email protected]>

In RPMSG GLINK the chrdev device will allocate an ept as part of the rpdev creation. This device will not register endpoint ops even though it has an allocated ept. Protect against the case where the device is being destroyed.

---
 drivers/rpmsg/rpmsg_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +1 -1
index a6361ca..91de940 100644
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(rpmsg_create_ept);
  */
 void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
 {
-	if (ept)
+	if (ept && ept->ops)
 		ept->ops->destroy_ept(ept);
 }
 EXPORT_SYMBOL(rpmsg_destroy_ept);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw

Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy

Quoted 10 lines · Deepak Kumar Singh

From: Chris Lew <[email protected]>

In RPMSG GLINK the chrdev device will allocate an ept as part of the rpdev creation. This device will not register endpoint ops even though it has an allocated ept. Protect against the case where the device is being destroyed.

Should this be marked for stable kernels?

And if so, what commit does this fix? Any reason the Fixes: tag was not used here?

And what happened to this series? I don't see it in linux-next, did the maintainer ignore it?

thanks,

greg k-h

#5 lore raw

Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy

Hi Greg,

Quoted 8 lines · Greg KH
Quoted 7 lines · Deepak Kumar Singh

From: Chris Lew <[email protected]>

In RPMSG GLINK the chrdev device will allocate an ept as part of the rpdev creation. This device will not register endpoint ops even though it has an allocated ept. Protect against the case where the device is being destroyed.

Quoted 9 lines
Quoted 3 lines

Should this be marked for stable kernels?

And if so, what commit does this fix? Any reason the Fixes: tag was not used here?

The crash that this fixes doesn't show up unless one of the previous patches in the series is applied.

[PATCH V6 3/5] rpmsg: glink: Add support for rpmsg glink chrdev

I'm not sure if the fixes tag should apply to this change or one of the commits to the base rpmsg code.

Quoted 3 lines

And what happened to this series? I don't see it in linux-next, did the maintainer ignore it?

I believe most of the review feedback for the series has been addressed by Deepak. There is one remaining action item for me and Deepak to provide more concrete evidence that the first patch in the series is needed.

[PATCH V6 1/5] rpmsg: glink: Use complete_all for open states

Quoted 4 lines

thanks,

greg k-h

Thanks,
Chris

Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#6 lore raw

Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy

Quoted 21 lines · Chris Lew

Hi Greg,

Quoted 8 lines · Greg KH
Quoted 7 lines · Deepak Kumar Singh

From: Chris Lew <[email protected]>

In RPMSG GLINK the chrdev device will allocate an ept as part of the rpdev creation. This device will not register endpoint ops even though it has an allocated ept. Protect against the case where the device is being destroyed.

Quoted 9 lines
Quoted 3 lines

Should this be marked for stable kernels?

And if so, what commit does this fix? Any reason the Fixes: tag was not used here?

Quoted 7 lines

The crash that this fixes doesn't show up unless one of the previous patches in the series is applied.

[PATCH V6 3/5] rpmsg: glink: Add support for rpmsg glink chrdev

I'm not sure if the fixes tag should apply to this change or one of the commits to the base rpmsg code.

That's a different series, why not merge this patch with that one so there is no need for a fix if none of this has been merged yet?

Quoted 9 lines
Quoted 3 lines

And what happened to this series? I don't see it in linux-next, did the maintainer ignore it?

I believe most of the review feedback for the series has been addressed by Deepak. There is one remaining action item for me and Deepak to provide more concrete evidence that the first patch in the series is needed.

[PATCH V6 1/5] rpmsg: glink: Use complete_all for open states

Ok, thanks, just didn't want to see this get forgotten...

greg k-h

#7 lore raw

PATCH v7 3/4 rpmsg: glink: Add support for rpmsg glink chrdev

In reply to a message not in the archive

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

---
 drivers/rpmsg/qcom_glink_native.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
drivers/rpmsg/qcom_glink_native.c +38 -0
index d5114ab..3a7f87c 100644
@@ -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);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#8 lore raw

PATCH v7 4/4 rpmsg: glink: Expose rpmsg name attr for glink

In reply to a message not in the archive

From: Chris Lew <[email protected]>

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

---
 drivers/rpmsg/qcom_glink_native.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/rpmsg/qcom_glink_native.c +26 -0
index 3a7f87c..0e8a28c0 100644
@@ -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;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project