All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: Fix wrong transmission direction of EP0
@ 2022-09-26  7:59 3090101217
  2022-10-08 15:40 ` Greg KH
  2022-11-01  4:44 ` [PATCH v2] " Jing Leng
  0 siblings, 2 replies; 8+ messages in thread
From: 3090101217 @ 2022-09-26  7:59 UTC (permalink / raw)
  To: pawell, gregkh; +Cc: linux-usb, linux-kernel, Jing Leng

From: Jing Leng <jleng@ambarella.com>

EP0 transfer is bi-directional, but in the cdnsp gadget, the
transmission direction of EP0 is not changed after it is
initialized to IN, so the OUT data from EP0 received by the host
is invalid.

The value of ep0_expect_in will change according to the value of
bRequestType in the SETUP transaction of control transfer, so we
can use it as the transmission direction of EP0.

Signed-off-by: Jing Leng <jleng@ambarella.com>
---
 drivers/usb/cdns3/cdnsp-gadget.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
index c67715f6f756..526f80651d35 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.c
+++ b/drivers/usb/cdns3/cdnsp-gadget.c
@@ -345,6 +345,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 {
 	struct cdnsp_device *pdev = pep->pdev;
 	struct usb_request *request;
+	u8 direction;
 	int ret;
 
 	if (preq->epnum == 0 && !list_empty(&pep->pending_list)) {
@@ -355,11 +356,14 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	request = &preq->request;
 	request->actual = 0;
 	request->status = -EINPROGRESS;
-	preq->direction = pep->direction;
+
+	direction = usb_endpoint_xfer_control(pep->endpoint.desc) ?
+		    pdev->ep0_expect_in : pep->direction;
+	preq->direction = direction;
 	preq->epnum = pep->number;
 	preq->td.drbl = 0;
 
-	ret = usb_gadget_map_request_by_dev(pdev->dev, request, pep->direction);
+	ret = usb_gadget_map_request_by_dev(pdev->dev, request, direction);
 	if (ret) {
 		trace_cdnsp_request_enqueue_error(preq);
 		return ret;
@@ -387,8 +391,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	return 0;
 
 unmap:
-	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request,
-					pep->direction);
+	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request, direction);
 	list_del(&preq->list);
 	trace_cdnsp_request_enqueue_error(preq);
 
-- 
2.34.1


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

* Re: [PATCH] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-09-26  7:59 [PATCH] usb: cdnsp: Fix wrong transmission direction of EP0 3090101217
@ 2022-10-08 15:40 ` Greg KH
  2022-11-01  4:44 ` [PATCH v2] " Jing Leng
  1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2022-10-08 15:40 UTC (permalink / raw)
  To: 3090101217; +Cc: pawell, linux-usb, linux-kernel, Jing Leng

On Mon, Sep 26, 2022 at 03:59:02PM +0800, 3090101217@zju.edu.cn wrote:
> From: Jing Leng <jleng@ambarella.com>
> 
> EP0 transfer is bi-directional, but in the cdnsp gadget, the
> transmission direction of EP0 is not changed after it is
> initialized to IN, so the OUT data from EP0 received by the host
> is invalid.
> 
> The value of ep0_expect_in will change according to the value of
> bRequestType in the SETUP transaction of control transfer, so we
> can use it as the transmission direction of EP0.
> 
> Signed-off-by: Jing Leng <jleng@ambarella.com>

Your email does not match your From: line and the signature of it shows
that it is invalid and does not pass authentication :(

Please work with your university to get an email address that works
properly.

thanks,

greg k-h

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

* [PATCH v2] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-09-26  7:59 [PATCH] usb: cdnsp: Fix wrong transmission direction of EP0 3090101217
  2022-10-08 15:40 ` Greg KH
@ 2022-11-01  4:44 ` Jing Leng
  2022-11-01  5:09   ` Greg KH
  2022-11-01  6:17   ` [PATCH v3] " Jing Leng
  1 sibling, 2 replies; 8+ messages in thread
From: Jing Leng @ 2022-11-01  4:44 UTC (permalink / raw)
  To: 3090101217; +Cc: gregkh, jleng, linux-kernel, linux-usb, pawell

EP0 transfer is bi-directional, but in the cdnsp gadget, the
transmission direction of EP0 is not changed after it is
initialized to IN, so the OUT data from EP0 received by the host
is invalid.

The value of ep0_expect_in will change according to the value of
bRequestType in the SETUP transaction of control transfer, so we
can use it as the transmission direction of EP0.

Signed-off-by: Jing Leng <3090101217@zju.edu.cn>
Signed-off-by: Jing Leng <jleng@ambarella.com>
---
ChangeLog v1->v2:
- Rebase the patch.
- Make email addresses ('From' and 'Signed-off-by') consistent.
---
 drivers/usb/cdns3/cdnsp-gadget.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
index c67715f6f756..526f80651d35 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.c
+++ b/drivers/usb/cdns3/cdnsp-gadget.c
@@ -345,6 +345,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 {
 	struct cdnsp_device *pdev = pep->pdev;
 	struct usb_request *request;
+	u8 direction;
 	int ret;
 
 	if (preq->epnum == 0 && !list_empty(&pep->pending_list)) {
@@ -355,11 +356,14 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	request = &preq->request;
 	request->actual = 0;
 	request->status = -EINPROGRESS;
-	preq->direction = pep->direction;
+
+	direction = usb_endpoint_xfer_control(pep->endpoint.desc) ?
+		    pdev->ep0_expect_in : pep->direction;
+	preq->direction = direction;
 	preq->epnum = pep->number;
 	preq->td.drbl = 0;
 
-	ret = usb_gadget_map_request_by_dev(pdev->dev, request, pep->direction);
+	ret = usb_gadget_map_request_by_dev(pdev->dev, request, direction);
 	if (ret) {
 		trace_cdnsp_request_enqueue_error(preq);
 		return ret;
@@ -387,8 +391,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	return 0;
 
 unmap:
-	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request,
-					pep->direction);
+	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request, direction);
 	list_del(&preq->list);
 	trace_cdnsp_request_enqueue_error(preq);
 
-- 
2.17.1


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

* Re: [PATCH v2] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-11-01  4:44 ` [PATCH v2] " Jing Leng
@ 2022-11-01  5:09   ` Greg KH
  2022-11-01  6:17   ` [PATCH v3] " Jing Leng
  1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2022-11-01  5:09 UTC (permalink / raw)
  To: Jing Leng; +Cc: jleng, linux-kernel, linux-usb, pawell

On Tue, Nov 01, 2022 at 12:44:33PM +0800, Jing Leng wrote:
> EP0 transfer is bi-directional, but in the cdnsp gadget, the
> transmission direction of EP0 is not changed after it is
> initialized to IN, so the OUT data from EP0 received by the host
> is invalid.
> 
> The value of ep0_expect_in will change according to the value of
> bRequestType in the SETUP transaction of control transfer, so we
> can use it as the transmission direction of EP0.
> 
> Signed-off-by: Jing Leng <3090101217@zju.edu.cn>
> Signed-off-by: Jing Leng <jleng@ambarella.com>
> ---
> ChangeLog v1->v2:
> - Rebase the patch.
> - Make email addresses ('From' and 'Signed-off-by') consistent.

That didn't happen.  You list yourself twice, and the last one does not
match the From: line on the patch.

Also the verification did not even work showing that this is an invalid
email from 3090101217@zju.edu.cn, so I can't trust it at all.

Please fix up your email system to properly send email from
ambarella.com with the correct verification.

thanks,

greg k-h

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

* [PATCH v3] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-11-01  4:44 ` [PATCH v2] " Jing Leng
  2022-11-01  5:09   ` Greg KH
@ 2022-11-01  6:17   ` Jing Leng
  2022-11-01  9:43     ` Greg KH
  1 sibling, 1 reply; 8+ messages in thread
From: Jing Leng @ 2022-11-01  6:17 UTC (permalink / raw)
  To: gregkh, pawell; +Cc: linux-kernel, linux-usb, Jing Leng

EP0 transfer is bi-directional, but in the cdnsp gadget, the
transmission direction of EP0 is not changed after it is
initialized to IN, so the OUT data from EP0 received by the host
is invalid.

The value of ep0_expect_in will change according to the value of
bRequestType in the SETUP transaction of control transfer, so we
can use it as the transmission direction of EP0.

Signed-off-by: Jing Leng <jleng@ambarella.com>
---
ChangeLog v2->v3:
- Repair my email address.
ChangeLog v1->v2:
- Rebase the patch.
- Make email addresses ('From' and 'Signed-off-by') consistent.
---
 drivers/usb/cdns3/cdnsp-gadget.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
index c67715f6f756..526f80651d35 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.c
+++ b/drivers/usb/cdns3/cdnsp-gadget.c
@@ -345,6 +345,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 {
 	struct cdnsp_device *pdev = pep->pdev;
 	struct usb_request *request;
+	u8 direction;
 	int ret;
 
 	if (preq->epnum == 0 && !list_empty(&pep->pending_list)) {
@@ -355,11 +356,14 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	request = &preq->request;
 	request->actual = 0;
 	request->status = -EINPROGRESS;
-	preq->direction = pep->direction;
+
+	direction = usb_endpoint_xfer_control(pep->endpoint.desc) ?
+		    pdev->ep0_expect_in : pep->direction;
+	preq->direction = direction;
 	preq->epnum = pep->number;
 	preq->td.drbl = 0;
 
-	ret = usb_gadget_map_request_by_dev(pdev->dev, request, pep->direction);
+	ret = usb_gadget_map_request_by_dev(pdev->dev, request, direction);
 	if (ret) {
 		trace_cdnsp_request_enqueue_error(preq);
 		return ret;
@@ -387,8 +391,7 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 	return 0;
 
 unmap:
-	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request,
-					pep->direction);
+	usb_gadget_unmap_request_by_dev(pdev->dev, &preq->request, direction);
 	list_del(&preq->list);
 	trace_cdnsp_request_enqueue_error(preq);
 
-- 
2.17.1


**********************************************************************
This email and attachments contain Ambarella Proprietary and/or Confidential Information and is intended solely for the use of the individual(s) to whom it is addressed. Any unauthorized review, use, disclosure, distribute, copy, or print is prohibited. If you are not an intended recipient, please contact the sender by reply email and destroy all copies of the original message. Thank you.

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

* Re: [PATCH v3] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-11-01  6:17   ` [PATCH v3] " Jing Leng
@ 2022-11-01  9:43     ` Greg KH
  2022-11-02  7:35       ` Pawel Laszczak
  2022-11-03 14:45       ` Greg KH
  0 siblings, 2 replies; 8+ messages in thread
From: Greg KH @ 2022-11-01  9:43 UTC (permalink / raw)
  To: Jing Leng; +Cc: pawell, linux-kernel, linux-usb

On Tue, Nov 01, 2022 at 02:17:30PM +0800, Jing Leng wrote:
> EP0 transfer is bi-directional, but in the cdnsp gadget, the
> transmission direction of EP0 is not changed after it is
> initialized to IN, so the OUT data from EP0 received by the host
> is invalid.
> 
> The value of ep0_expect_in will change according to the value of
> bRequestType in the SETUP transaction of control transfer, so we
> can use it as the transmission direction of EP0.
> 
> Signed-off-by: Jing Leng <jleng@ambarella.com>
> ---
> ChangeLog v2->v3:
> - Repair my email address.

Yes, it works, and it's validated!

Nice job, thanks.  I'll let the cdns3 maintainer review it first, but
just wanted to say thanks for fixing this up, it makes my life a lot
easier when accepting patches.

greg k-h

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

* RE: [PATCH v3] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-11-01  9:43     ` Greg KH
@ 2022-11-02  7:35       ` Pawel Laszczak
  2022-11-03 14:45       ` Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: Pawel Laszczak @ 2022-11-02  7:35 UTC (permalink / raw)
  To: Greg KH, Jing Leng; +Cc: linux-kernel, linux-usb


>
>On Tue, Nov 01, 2022 at 02:17:30PM +0800, Jing Leng wrote:
>> EP0 transfer is bi-directional, but in the cdnsp gadget, the
>> transmission direction of EP0 is not changed after it is initialized
>> to IN, so the OUT data from EP0 received by the host is invalid.
>>
>> The value of ep0_expect_in will change according to the value of
>> bRequestType in the SETUP transaction of control transfer, so we can
>> use it as the transmission direction of EP0.
>>
>> Signed-off-by: Jing Leng <jleng@ambarella.com>

Acked-by: Pawel Laszczak <pawell@cadence.com>

Thanks,
Pawel Laaszczak

>> ---
>> ChangeLog v2->v3:
>> - Repair my email address.
>
>Yes, it works, and it's validated!
>
>Nice job, thanks.  I'll let the cdns3 maintainer review it first, but just wanted to
>say thanks for fixing this up, it makes my life a lot easier when accepting
>patches.
>
>greg k-h

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

* Re: [PATCH v3] usb: cdnsp: Fix wrong transmission direction of EP0
  2022-11-01  9:43     ` Greg KH
  2022-11-02  7:35       ` Pawel Laszczak
@ 2022-11-03 14:45       ` Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2022-11-03 14:45 UTC (permalink / raw)
  To: Jing Leng; +Cc: pawell, linux-kernel, linux-usb

On Tue, Nov 01, 2022 at 10:43:21AM +0100, Greg KH wrote:
> On Tue, Nov 01, 2022 at 02:17:30PM +0800, Jing Leng wrote:
> > EP0 transfer is bi-directional, but in the cdnsp gadget, the
> > transmission direction of EP0 is not changed after it is
> > initialized to IN, so the OUT data from EP0 received by the host
> > is invalid.
> > 
> > The value of ep0_expect_in will change according to the value of
> > bRequestType in the SETUP transaction of control transfer, so we
> > can use it as the transmission direction of EP0.
> > 
> > Signed-off-by: Jing Leng <jleng@ambarella.com>
> > ---
> > ChangeLog v2->v3:
> > - Repair my email address.
> 
> Yes, it works, and it's validated!
> 
> Nice job, thanks.  I'll let the cdns3 maintainer review it first, but
> just wanted to say thanks for fixing this up, it makes my life a lot
> easier when accepting patches.

Oops, I missed that email footer, sorry.  That is NOT compatible with
Linux kernel development, and as per the recommendation from my legal
people, I have to go revert that change as we can't take it as-is
because it might have been sent out incorrectly as it was stated to be
"Proprietary and/or Confidential Information" which is not allowed in
the Linux kernel.

thanks,

greg k-h

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

end of thread, other threads:[~2022-11-03 14:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26  7:59 [PATCH] usb: cdnsp: Fix wrong transmission direction of EP0 3090101217
2022-10-08 15:40 ` Greg KH
2022-11-01  4:44 ` [PATCH v2] " Jing Leng
2022-11-01  5:09   ` Greg KH
2022-11-01  6:17   ` [PATCH v3] " Jing Leng
2022-11-01  9:43     ` Greg KH
2022-11-02  7:35       ` Pawel Laszczak
2022-11-03 14:45       ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.