From: Jing Leng <jleng@ambarella.com>
To: gregkh@linuxfoundation.org, pawell@cadence.com
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Jing Leng <jleng@ambarella.com>
Subject: [PATCH v3] usb: cdnsp: Fix wrong transmission direction of EP0
Date: Tue, 1 Nov 2022 14:17:30 +0800 [thread overview]
Message-ID: <20221101061730.8991-1-jleng@ambarella.com> (raw)
In-Reply-To: <20221101044433.5627-1-3090101217@zju.edu.cn>
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.
next prev parent reply other threads:[~2022-11-01 7:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 7:59 [PATCH] " 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 ` Jing Leng [this message]
2022-11-01 9:43 ` [PATCH v3] " Greg KH
2022-11-02 7:35 ` Pawel Laszczak
2022-11-03 14:45 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221101061730.8991-1-jleng@ambarella.com \
--to=jleng@ambarella.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®