linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states
       [not found] <1589346606-15046-1-git-send-email-aneela@codeaurora.org>
@ 2020-05-13  5:10 ` Arun Kumar Neelakantam
  2020-05-13 20:59   ` Mathieu Poirier
  2020-05-13  5:10 ` [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev Arun Kumar Neelakantam
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-13  5:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson, clew, sricharan
  Cc: linux-remoteproc, linux-kernel, Arun Kumar Neelakantam,
	Andy Gross, open list:ARM/QUALCOMM SUPPORT

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: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 1995f5b..604f11f 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;
 }
@@ -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);
-- 
2.7.4

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

* [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev
       [not found] <1589346606-15046-1-git-send-email-aneela@codeaurora.org>
  2020-05-13  5:10 ` [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states Arun Kumar Neelakantam
@ 2020-05-13  5:10 ` Arun Kumar Neelakantam
  2020-05-13 21:56   ` Mathieu Poirier
  2020-05-13  5:10 ` [PATCH V5 4/5] rpmsg: glink: Expose rpmsg name attr for glink Arun Kumar Neelakantam
  2020-05-13  5:10 ` [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy Arun Kumar Neelakantam
  3 siblings, 1 reply; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-13  5:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson, clew, sricharan
  Cc: linux-remoteproc, linux-kernel, Arun Kumar Neelakantam,
	Andy Gross, open list:ARM/QUALCOMM SUPPORT

From: Chris Lew <clew@codeaurora.org>

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: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 40 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 604f11f..3a7f87c 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -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);
@@ -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);
-- 
2.7.4

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

* [PATCH V5 4/5] rpmsg: glink: Expose rpmsg name attr for glink
       [not found] <1589346606-15046-1-git-send-email-aneela@codeaurora.org>
  2020-05-13  5:10 ` [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states Arun Kumar Neelakantam
  2020-05-13  5:10 ` [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev Arun Kumar Neelakantam
@ 2020-05-13  5:10 ` Arun Kumar Neelakantam
  2020-05-13  5:10 ` [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy Arun Kumar Neelakantam
  3 siblings, 0 replies; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-13  5:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson, clew, sricharan
  Cc: linux-remoteproc, linux-kernel, Arun Kumar Neelakantam,
	Andy Gross, open list:ARM/QUALCOMM SUPPORT

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: 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;
-- 
2.7.4

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

* [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy
       [not found] <1589346606-15046-1-git-send-email-aneela@codeaurora.org>
                   ` (2 preceding siblings ...)
  2020-05-13  5:10 ` [PATCH V5 4/5] rpmsg: glink: Expose rpmsg name attr for glink Arun Kumar Neelakantam
@ 2020-05-13  5:10 ` Arun Kumar Neelakantam
  2020-05-13 22:13   ` Mathieu Poirier
  3 siblings, 1 reply; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-13  5:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson, clew, sricharan
  Cc: linux-remoteproc, linux-kernel, Arun Kumar Neelakantam,
	Andy Gross, open list:ARM/QUALCOMM SUPPORT

Rpmsg device unregister is not happening if channel close is triggered
from local side and causing re-registration of device failures.

Unregister rpmsg device for local close in endpoint destroy path.

Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 0e8a28c0..fc8ef66 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -1207,6 +1207,7 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
 {
 	struct glink_channel *channel = to_glink_channel(ept);
 	struct qcom_glink *glink = channel->glink;
+	struct rpmsg_channel_info chinfo;
 	unsigned long flags;
 
 	spin_lock_irqsave(&channel->recv_lock, flags);
@@ -1214,6 +1215,13 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
 	spin_unlock_irqrestore(&channel->recv_lock, flags);
 
 	/* Decouple the potential rpdev from the channel */
+	if (channel->rpdev) {
+		strncpy(chinfo.name, channel->name, sizeof(chinfo.name));
+		chinfo.src = RPMSG_ADDR_ANY;
+		chinfo.dst = RPMSG_ADDR_ANY;
+
+		rpmsg_unregister_device(glink->dev, &chinfo);
+	}
 	channel->rpdev = NULL;
 
 	qcom_glink_send_close_req(glink, channel);
@@ -1477,6 +1485,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
 
 		rpmsg_unregister_device(glink->dev, &chinfo);
 	}
+	channel->rpdev = NULL;
 
 	qcom_glink_send_close_ack(glink, channel->rcid);
 
-- 
2.7.4

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

* Re: [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states
  2020-05-13  5:10 ` [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states Arun Kumar Neelakantam
@ 2020-05-13 20:59   ` Mathieu Poirier
  2020-05-20  9:28     ` Arun Kumar Neelakantam
  0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Poirier @ 2020-05-13 20:59 UTC (permalink / raw)
  To: Arun Kumar Neelakantam
  Cc: ohad, bjorn.andersson, clew, sricharan, linux-remoteproc,
	linux-kernel, Andy Gross, open list:ARM/QUALCOMM SUPPORT

Hi Arun,

On Wed, May 13, 2020 at 10:40:02AM +0530, Arun Kumar Neelakantam wrote:
> 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

s/represet/represent

> races with waiters and using completion_done.
> 
> Signed-off-by: Chris Lew <clew@codeaurora.org>
> Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
> ---
>  drivers/rpmsg/qcom_glink_native.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index 1995f5b..604f11f 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);

If you do this and as per the note in the comment section above
completion_done(), there shouldn't be a need to call completion_done() in
qcom_glink_announce_create().

Thanks,
Mathieu 

>  
>  	return 0;
>  }
> @@ -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);
> -- 
> 2.7.4

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

* Re: [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev
  2020-05-13  5:10 ` [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev Arun Kumar Neelakantam
@ 2020-05-13 21:56   ` Mathieu Poirier
  0 siblings, 0 replies; 10+ messages in thread
From: Mathieu Poirier @ 2020-05-13 21:56 UTC (permalink / raw)
  To: Arun Kumar Neelakantam
  Cc: ohad, bjorn.andersson, clew, sricharan, linux-remoteproc,
	linux-kernel, Andy Gross, open list:ARM/QUALCOMM SUPPORT

On Wed, May 13, 2020 at 10:40:04AM +0530, Arun Kumar Neelakantam wrote:
> From: Chris Lew <clew@codeaurora.org>
> 
> 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: Arun Kumar Neelakantam <aneela@codeaurora.org>
> ---
>  drivers/rpmsg/qcom_glink_native.c | 40 ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index 604f11f..3a7f87c 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -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))

Please move this to patch 01.

>  		return 0;
>  
>  	prop = of_find_property(np, "qcom,intents", NULL);
> @@ -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);
> -- 
> 2.7.4

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

* Re: [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy
  2020-05-13  5:10 ` [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy Arun Kumar Neelakantam
@ 2020-05-13 22:13   ` Mathieu Poirier
  2020-05-20  9:32     ` Arun Kumar Neelakantam
  0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Poirier @ 2020-05-13 22:13 UTC (permalink / raw)
  To: Arun Kumar Neelakantam
  Cc: ohad, bjorn.andersson, clew, sricharan, linux-remoteproc,
	linux-kernel, Andy Gross, open list:ARM/QUALCOMM SUPPORT

On Wed, May 13, 2020 at 10:40:06AM +0530, Arun Kumar Neelakantam wrote:
> Rpmsg device unregister is not happening if channel close is triggered
> from local side and causing re-registration of device failures.
> 
> Unregister rpmsg device for local close in endpoint destroy path.
> 
> Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
> ---
>  drivers/rpmsg/qcom_glink_native.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index 0e8a28c0..fc8ef66 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -1207,6 +1207,7 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
>  {
>  	struct glink_channel *channel = to_glink_channel(ept);
>  	struct qcom_glink *glink = channel->glink;
> +	struct rpmsg_channel_info chinfo;
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&channel->recv_lock, flags);
> @@ -1214,6 +1215,13 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
>  	spin_unlock_irqrestore(&channel->recv_lock, flags);
>  
>  	/* Decouple the potential rpdev from the channel */
> +	if (channel->rpdev) {

If we proceed this way no other channel can have an rpdev.  I would hope that
unregistration of rpdev would be more symetrical to what is done in patch 03.

Thanks,
Mathieu

> +		strncpy(chinfo.name, channel->name, sizeof(chinfo.name));
> +		chinfo.src = RPMSG_ADDR_ANY;
> +		chinfo.dst = RPMSG_ADDR_ANY;
> +
> +		rpmsg_unregister_device(glink->dev, &chinfo);
> +	}
>  	channel->rpdev = NULL;
>  
>  	qcom_glink_send_close_req(glink, channel);
> @@ -1477,6 +1485,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
>  
>  		rpmsg_unregister_device(glink->dev, &chinfo);
>  	}
> +	channel->rpdev = NULL;
>  
>  	qcom_glink_send_close_ack(glink, channel->rcid);
>  
> -- 
> 2.7.4

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

* Re: [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states
  2020-05-13 20:59   ` Mathieu Poirier
@ 2020-05-20  9:28     ` Arun Kumar Neelakantam
  0 siblings, 0 replies; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-20  9:28 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, bjorn.andersson, clew, sricharan, linux-remoteproc,
	linux-kernel, Andy Gross, open list:ARM/QUALCOMM SUPPORT


On 5/14/2020 2:29 AM, Mathieu Poirier wrote:
> Hi Arun,
>
> On Wed, May 13, 2020 at 10:40:02AM +0530, Arun Kumar Neelakantam wrote:
>> 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
> s/represet/represent
done added in patch set 6
>
>> races with waiters and using completion_done.
>>
>> Signed-off-by: Chris Lew <clew@codeaurora.org>
>> Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
>> ---
>>   drivers/rpmsg/qcom_glink_native.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
>> index 1995f5b..604f11f 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);
> If you do this and as per the note in the comment section above
> completion_done(), there shouldn't be a need to call completion_done() in
> qcom_glink_announce_create().
>
> Thanks,
> Mathieu
the completion_done() check still required to avoid sending intent 
request on channel which only opened by remote.
>   
>
>>   
>>   	return 0;
>>   }
>> @@ -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);
>> -- 
>> 2.7.4

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

* Re: [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy
  2020-05-13 22:13   ` Mathieu Poirier
@ 2020-05-20  9:32     ` Arun Kumar Neelakantam
  0 siblings, 0 replies; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2020-05-20  9:32 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, bjorn.andersson, clew, sricharan, linux-remoteproc,
	linux-kernel, Andy Gross, open list:ARM/QUALCOMM SUPPORT


On 5/14/2020 3:43 AM, Mathieu Poirier wrote:
> On Wed, May 13, 2020 at 10:40:06AM +0530, Arun Kumar Neelakantam wrote:
>> Rpmsg device unregister is not happening if channel close is triggered
>> from local side and causing re-registration of device failures.
>>
>> Unregister rpmsg device for local close in endpoint destroy path.
>>
>> Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
>> ---
>>   drivers/rpmsg/qcom_glink_native.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
>> index 0e8a28c0..fc8ef66 100644
>> --- a/drivers/rpmsg/qcom_glink_native.c
>> +++ b/drivers/rpmsg/qcom_glink_native.c
>> @@ -1207,6 +1207,7 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
>>   {
>>   	struct glink_channel *channel = to_glink_channel(ept);
>>   	struct qcom_glink *glink = channel->glink;
>> +	struct rpmsg_channel_info chinfo;
>>   	unsigned long flags;
>>   
>>   	spin_lock_irqsave(&channel->recv_lock, flags);
>> @@ -1214,6 +1215,13 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
>>   	spin_unlock_irqrestore(&channel->recv_lock, flags);
>>   
>>   	/* Decouple the potential rpdev from the channel */
>> +	if (channel->rpdev) {
> If we proceed this way no other channel can have an rpdev.  I would hope that
> unregistration of rpdev would be more symetrical to what is done in patch 03.
>
> Thanks,
> Mathieu
Unregister here also required along with in qcom_glink_rx_close() 
otherwise if the remote open the channel again it map to stale rpmsg 
device.
>
>> +		strncpy(chinfo.name, channel->name, sizeof(chinfo.name));
>> +		chinfo.src = RPMSG_ADDR_ANY;
>> +		chinfo.dst = RPMSG_ADDR_ANY;
>> +
>> +		rpmsg_unregister_device(glink->dev, &chinfo);
>> +	}
>>   	channel->rpdev = NULL;
>>   
>>   	qcom_glink_send_close_req(glink, channel);
>> @@ -1477,6 +1485,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
>>   
>>   		rpmsg_unregister_device(glink->dev, &chinfo);
>>   	}
>> +	channel->rpdev = NULL;
>>   
>>   	qcom_glink_send_close_ack(glink, channel->rcid);
>>   
>> -- 
>> 2.7.4

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

* [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states
       [not found] <1574417087-27594-1-git-send-email-aneela@codeaurora.org>
@ 2019-11-22 10:05 ` Arun Kumar Neelakantam
  0 siblings, 0 replies; 10+ messages in thread
From: Arun Kumar Neelakantam @ 2019-11-22 10:05 UTC (permalink / raw)
  To: ohad, bjorn.andersson, clew, sricharan
  Cc: linux-remoteproc, linux-kernel, Arun Kumar Neelakantam,
	Andy Gross, open list:ARM/QUALCOMM SUPPORT

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: Arun Kumar Neelakantam <aneela@codeaurora.org>
---
 drivers/rpmsg/qcom_glink_native.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 621f1af..609a150f 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -949,7 +949,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;
 }
@@ -1393,7 +1393,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);
-- 
1.9.1


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

end of thread, other threads:[~2020-05-20  9:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1589346606-15046-1-git-send-email-aneela@codeaurora.org>
2020-05-13  5:10 ` [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states Arun Kumar Neelakantam
2020-05-13 20:59   ` Mathieu Poirier
2020-05-20  9:28     ` Arun Kumar Neelakantam
2020-05-13  5:10 ` [PATCH V5 3/5] rpmsg: glink: Add support for rpmsg glink chrdev Arun Kumar Neelakantam
2020-05-13 21:56   ` Mathieu Poirier
2020-05-13  5:10 ` [PATCH V5 4/5] rpmsg: glink: Expose rpmsg name attr for glink Arun Kumar Neelakantam
2020-05-13  5:10 ` [PATCH V5 5/5] rpmsg: glink: unregister rpmsg device during endpoint destroy Arun Kumar Neelakantam
2020-05-13 22:13   ` Mathieu Poirier
2020-05-20  9:32     ` Arun Kumar Neelakantam
     [not found] <1574417087-27594-1-git-send-email-aneela@codeaurora.org>
2019-11-22 10:05 ` [PATCH V5 1/5] rpmsg: glink: Use complete_all for open states Arun Kumar Neelakantam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).