linux-kernel.vger.kernel.org archive mirror
 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 2/4] rpmsg: Guard against null endpoint ops in destroy Deepak Kumar Singh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ 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] 7+ messages in thread

* [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy
       [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-08-07  7:59   ` Greg KH
  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
  3 siblings, 1 reply; 7+ 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, Ohad Ben-Cohen,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM,
	open list

From: Chris Lew <clew@codeaurora.org>

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.

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/rpmsg_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index a6361ca..91de940 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -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);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 7+ 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 ` [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy 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
  3 siblings, 0 replies; 7+ 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] 7+ 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>
                   ` (2 preceding siblings ...)
  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
  3 siblings, 0 replies; 7+ 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] 7+ messages in thread

* Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy
  2020-06-24 16:45 ` [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy Deepak Kumar Singh
@ 2020-08-07  7:59   ` Greg KH
  2020-08-08  0:33     ` Chris Lew
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2020-08-07  7:59 UTC (permalink / raw)
  To: Deepak Kumar Singh
  Cc: bjorn.andersson, clew, mathieu.poirier, Arun Kumar Neelakantam,
	Ohad Ben-Cohen,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM,
	open list

On Wed, Jun 24, 2020 at 10:15:19PM +0530, Deepak Kumar Singh wrote:
> From: Chris Lew <clew@codeaurora.org>
> 
> 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.
> 
> 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>

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

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

* Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy
  2020-08-07  7:59   ` Greg KH
@ 2020-08-08  0:33     ` Chris Lew
  2020-08-08  5:55       ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Lew @ 2020-08-08  0:33 UTC (permalink / raw)
  To: Greg KH, Deepak Kumar Singh
  Cc: bjorn.andersson, mathieu.poirier, Arun Kumar Neelakantam,
	Ohad Ben-Cohen,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM,
	open list

Hi Greg,

On 8/7/2020 12:59 AM, Greg KH wrote:
> On Wed, Jun 24, 2020 at 10:15:19PM +0530, Deepak Kumar Singh wrote:
>> From: Chris Lew <clew@codeaurora.org>
>>
>> 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.
>>
>> 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>
> 
> 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.

> 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

> thanks,
> 
> greg k-h
> 

Thanks,
Chris

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a 
Linux Foundation Collaborative Project

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

* Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy
  2020-08-08  0:33     ` Chris Lew
@ 2020-08-08  5:55       ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2020-08-08  5:55 UTC (permalink / raw)
  To: Chris Lew
  Cc: Deepak Kumar Singh, bjorn.andersson, mathieu.poirier,
	Arun Kumar Neelakantam, Ohad Ben-Cohen,
	open list:REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM,
	open list

On Fri, Aug 07, 2020 at 05:33:53PM -0700, Chris Lew wrote:
> Hi Greg,
> 
> On 8/7/2020 12:59 AM, Greg KH wrote:
> > On Wed, Jun 24, 2020 at 10:15:19PM +0530, Deepak Kumar Singh wrote:
> > > From: Chris Lew <clew@codeaurora.org>
> > > 
> > > 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.
> > > 
> > > 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>
> > 
> > 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.

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?

> > 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

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

end of thread, other threads:[~2020-08-08  5:55 UTC | newest]

Thread overview: 7+ 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 2/4] rpmsg: Guard against null endpoint ops in destroy Deepak Kumar Singh
2020-08-07  7:59   ` Greg KH
2020-08-08  0:33     ` Chris Lew
2020-08-08  5:55       ` Greg KH
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;
as well as URLs for NNTP newsgroup(s).