From: andrey.konovalov@linux.dev
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>,
Felipe Balbi <balbi@kernel.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Pawel Laszczak <pawell@cadence.com>,
Chunfeng Yun <chunfeng.yun@mediatek.com>,
Minas Harutyunyan <hminas@synopsys.com>,
Justin Chen <justin.chen@broadcom.com>,
Al Cooper <alcooperx@gmail.com>,
Herve Codina <herve.codina@bootlin.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/3] usb: raw-gadget: return USB_GADGET_DELAYED_STATUS from setup()
Date: Mon, 28 Aug 2023 17:43:03 +0200 [thread overview]
Message-ID: <c56077322f0d3fc6d504092a266cb89d75701087.1693237258.git.andreyknvl@gmail.com> (raw)
In-Reply-To: <7f0ee06c68c7241c844cd50f8565fdd5ead79b1b.1693237258.git.andreyknvl@gmail.com>
From: Andrey Konovalov <andreyknvl@gmail.com>
Return USB_GADGET_DELAYED_STATUS from the setup() callback for 0-length
transfers as a workaround to stop some UDC drivers (e.g. dwc3) from
automatically proceeding with the status stage.
This workaround should be removed once all UDC drivers are fixed to
always delay the status stage until a response is queued to EP0.
Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com>
---
drivers/usb/gadget/legacy/raw_gadget.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c
index e549022642e5..b9ecc55a2ce2 100644
--- a/drivers/usb/gadget/legacy/raw_gadget.c
+++ b/drivers/usb/gadget/legacy/raw_gadget.c
@@ -25,6 +25,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/ch11.h>
#include <linux/usb/gadget.h>
+#include <linux/usb/composite.h>
#include <uapi/linux/usb/raw_gadget.h>
@@ -363,6 +364,16 @@ static int gadget_setup(struct usb_gadget *gadget,
out_unlock:
spin_unlock_irqrestore(&dev->lock, flags);
out:
+ if (ret == 0 && ctrl->wLength == 0) {
+ /*
+ * Return USB_GADGET_DELAYED_STATUS as a workaround to stop
+ * some UDC drivers (e.g. dwc3) from automatically proceeding
+ * with the status stage for 0-length transfers.
+ * Should be removed once all UDC drivers are fixed to always
+ * delay the status stage until a response is queued to EP0.
+ */
+ return USB_GADGET_DELAYED_STATUS;
+ }
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2023-08-28 15:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 15:43 [PATCH v2 1/3] usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS andrey.konovalov
2023-08-28 15:43 ` andrey.konovalov [this message]
2023-08-28 15:43 ` [PATCH v2 3/3] usb: gadgetfs: return USB_GADGET_DELAYED_STATUS from setup() andrey.konovalov
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=c56077322f0d3fc6d504092a266cb89d75701087.1693237258.git.andreyknvl@gmail.com \
--to=andrey.konovalov@linux.dev \
--cc=Thinh.Nguyen@synopsys.com \
--cc=alcooperx@gmail.com \
--cc=andreyknvl@gmail.com \
--cc=balbi@kernel.org \
--cc=chunfeng.yun@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=herve.codina@bootlin.com \
--cc=hminas@synopsys.com \
--cc=justin.chen@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=stern@rowland.harvard.edu \
/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®