2020-04-23 14:01:38

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 0/4] usb: gadget: serial: add supend resume support

This series handles an issue seen when doing basic testing using ACM or SERIAL
gadget functions like in [1], and using the DWC2 gadget driver. It occurs when
the HOST has suspended the bus before testing, in this order:
- On the device:
cat /dev/ttyGS<Y>
Dmesg error log is seen on device side:
configfs-gadget gadget: acm ttyGS0 can't notify serial state, -11
- On the host:
echo test > /dev/ttyACM<X>
The bus resumes, but the serial link isn't functional.

So, implement suspend/resume callbacks in gadget serial drivers to handle this.
There is a precursor patch in DWC2 to enable submitting usb requests from the
gadget resume routine, once in L0 state.

[1] https://www.kernel.org/doc/html/latest/usb/gadget-testing.html#testing-the-acm-function

Changes in v2:
- update dwc2 with Minas suggestions

Fabrice Gasnier (4):
usb: dwc2: gadget: move gadget resume after the core is in L0 state
usb: gadget: u_serial: add suspend resume callbacks
usb: gadget: f_serial: add suspend resume callbacks
usb: gadget: f_acm: add suspend resume callbacks

drivers/usb/dwc2/core_intr.c | 7 +++--
drivers/usb/gadget/function/f_acm.c | 16 ++++++++++
drivers/usb/gadget/function/f_serial.c | 16 ++++++++++
drivers/usb/gadget/function/u_serial.c | 57 +++++++++++++++++++++++++++++-----
drivers/usb/gadget/function/u_serial.h | 2 ++
5 files changed, 88 insertions(+), 10 deletions(-)

--
2.7.4


2020-04-23 18:46:27

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 4/4] usb: gadget: f_acm: add suspend resume callbacks

Add suspend resume callbacks to notify u_serial of the bus suspend/resume
state.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
drivers/usb/gadget/function/f_acm.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 7c152c2..200596e 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -723,6 +723,20 @@ static void acm_free_func(struct usb_function *f)
kfree(acm);
}

+static void acm_resume(struct usb_function *f)
+{
+ struct f_acm *acm = func_to_acm(f);
+
+ gserial_resume(&acm->port);
+}
+
+static void acm_suspend(struct usb_function *f)
+{
+ struct f_acm *acm = func_to_acm(f);
+
+ gserial_suspend(&acm->port);
+}
+
static struct usb_function *acm_alloc_func(struct usb_function_instance *fi)
{
struct f_serial_opts *opts;
@@ -750,6 +764,8 @@ static struct usb_function *acm_alloc_func(struct usb_function_instance *fi)
acm->port_num = opts->port_num;
acm->port.func.unbind = acm_unbind;
acm->port.func.free_func = acm_free_func;
+ acm->port.func.resume = acm_resume;
+ acm->port.func.suspend = acm_suspend;

return &acm->port.func;
}
--
2.7.4