usb: gadget: configfs: Add lpm_Ux_disable
Subsystems (2)
PATCH 1/1 usb: gadget: configfs: Add lpm_Ux_disable
When combining dwc3 with an redriver for a USB Type-C device solution, it sometimes have problems with leaving U1/U2 for certain hosts, resulting in link training errors and reconnects. This create an interface via configfs for disabling U1/U2, enabling a workaround for devices based on dwc3.
--- drivers/usb/dwc3/ep0.c | 9 ++++++- drivers/usb/gadget/configfs.c | 56 +++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gadget.h | 6 ++++- 3 files changed, 69 insertions(+), 2 deletions(-)
drivers/usb/dwc3/ep0.c +8 -1
@@ -379,6 +379,8 @@ static int dwc3_ep0_handle_u1(struct dwc3 *dwc, enum usb_device_state state,if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; +if (dwc->gadget_driver->lpm_U1_disable) +return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (set)
@@ -401,6 +403,8 @@ static int dwc3_ep0_handle_u2(struct dwc3 *dwc, enum usb_device_state state,if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; +if (dwc->gadget_driver->lpm_U2_disable) +return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (set)
@@ -626,7 +630,10 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)* nothing is pending from application. */ reg =dwc3_readl (dwc->regs,DWC3_DCTL ); - reg |= (DWC3_DCTL_ACCEPTU1ENA |DWC3_DCTL_ACCEPTU2ENA ); +if (!dwc->gadget_driver->lpm_U1_disable) + reg |=DWC3_DCTL_ACCEPTU1ENA ; +if (!dwc->gadget_driver->lpm_U2_disable) + reg |=DWC3_DCTL_ACCEPTU2ENA ;dwc3_writel (dwc->regs,DWC3_DCTL , reg); }break ;
drivers/usb/gadget/configfs.c +56 -0
80 lines not on this page · raw message
include/linux/usb/gadget.h +5 -1
@@ -619,7 +619,9 @@ static inline int usb_gadget_activate(struct usb_gadget *gadget)* this driver will be bound to any available UDC. * @pending: UDC core private data used for deferred probe of this driver. * @match_existing_only: If udc is not found, return an error and don't add this -* gadget driver to list of pending driver +* gadget driver to list of pending driver. +* @lpm_U1_disable: Instruct the UDC to disable U1 if possible. +* @lpm_U2_disable: Instruct the UDC to disable U2 if possible. * * Devices are disabled till a gadget driver successfully bind()s, which * means the driver will handle setup() requests needed to enumerate (and
@@ -684,6 +686,8 @@ struct usb_gadget_driver {char *udc_name;struct list_head pending; unsigned match_existing_only:1; + unsigned lpm_U1_disable:1; + unsigned lpm_U2_disable:1; };
Signature · 1 line
2.7.4
Quoted 9 lines · Claus H. Stovgaard
When combining dwc3 with an redriver for a USB Type-C device solution, it
sometimes have problems with leaving U1/U2 for certain hosts, resulting in
link training errors and reconnects. This create an interface via configfs for disabling U1/U2, enabling a workaround for devices based on
dwc3.
Sorry messed up a bit with a missing cover letter.
This feature relates to Anurag patch [1] and a thread [2] from earlier
Where Anurags patch focus on setting U1/U2 latency in the BOS descriptor from the devicetree, this patch focuses on having a configfs interface for forcing the UDC (here the dwc3) to not enable U1/U2 and reject the SET_SEL(U1/U2).
Looking forward to input.
[1] https://www.spinics.net/lists/linux-usb/msg179732.html
[2] https://www.spinics.net/lists/linux-usb/msg179393.html
Thinh Nguyen
maintainerHi Claus,
Quoted 18 lines · Claus H. Stovgaard
Quoted 9 lines · Claus H. Stovgaard
When combining dwc3 with an redriver for a USB Type-C device solution, it
sometimes have problems with leaving U1/U2 for certain hosts, resulting in
link training errors and reconnects. This create an interface via configfs for disabling U1/U2, enabling a workaround for devices based on
dwc3.Sorry messed up a bit with a missing cover letter.
This feature relates to Anurag patch [1] and a thread [2] from earlierWhere Anurags patch focus on setting U1/U2 latency in the BOS descriptor from the devicetree, this patch focuses on having a configfs interface for forcing the UDC (here the dwc3) to not enable U1/U2 and reject the
SET_SEL(U1/U2).
Quoted 6 lines
Looking forward to input.
[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinics.net_lists_linux-2Dusb_msg179732.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyhjrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY-w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=es7kki6iuLJUp2rJnzP9alXKyfJPNSfyxTVCKKDd_rQ&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinics.net_lists_linux-2Dusb_msg179393.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyhjrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY-w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=cFTmO9wPf7b6TZxFUAAIJM0Z_wM1ttNIc1rct0uR6co&e=
I'm not sure who will submit the patch to make change to DWC3 for disabling U1/U2 (Anurag or you), but can you split your patch between dwc3 and configfs.
Thanks,
Thinh
Hi Thinh
Quoted 26 lines · Thinh Nguyen
Quoted 10 lines · Claus H. Stovgaard
Where Anurags patch focus on setting U1/U2 latency in the BOS descriptor from the devicetree, this patch focuses on having a configfs
interface for forcing the UDC (here the dwc3) to not enable U1/U2 and
reject theSET_SEL(U1/U2).Looking forward to input.
Quoted 14 lines
[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinic
s.net_lists_linux- 2Dusb_msg179732.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyh jrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY- w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=es7kki6iuLJUp2rJn zP9alXKyfJPNSfyxTVCKKDd_rQ&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinic
s.net_lists_linux- 2Dusb_msg179393.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyh jrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY- w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=cFTmO9wPf7b6TZxFU AAIJM0Z_wM1ttNIc1rct0uR6co&e=
Quoted 3 lines
I'm not sure who will submit the patch to make change to DWC3 for disabling U1/U2 (Anurag or you), but can you split your patch between dwc3 and configfs.
Have just written with Anurag, and he will submit a new patch set, where he has taken the control in ep0.c from my patch, and combined with his devicetree bindings. So the plan is to drop the configfs interface completely, keep the devicetree binding names (dis-u1-entry- quirk) and let it do 3 things.
*Sets the latency to 0 in the BOS
*Disable U1/U2 acceptence
*Disable U1/U2 initiating
This also include rejecting SET_SEL.
We think this is the best option, and then dropping this patch as it is.
I will just send and email later on this thread, when the patch is available on marc.info as a link for reference to the future.
Thanks
Claus
Hi Claus & Thinh,
Quoted 57 lines
-----Original Message-----
From: Claus H. Stovgaard [mailto:[email protected]]
Sent: Wednesday, May 08, 2019 2:59 AM
To: Thinh Nguyen <[email protected]>; [email protected]
Cc: Felipe Balbi <[email protected]>; Greg Kroah-Hartman <[email protected]>; [email protected]; Anurag Kumar Vulisha <[email protected]>
Subject: Re: [PATCH] usb: gadget: configfs: Addlpm_Ux_disableHi Thinh
Quoted 9 lines · Thinh Nguyen
Quoted 8 lines · Claus H. Stovgaard
Where Anurags patch focus on setting U1/U2 latency in the BOS descriptor from the devicetree, this patch focuses on having a configfs
interface for forcing the UDC (here the dwc3) to not enable U1/U2 and
reject theSET_SEL(U1/U2).Quoted 5 lines
Quoted 5 lines
Looking forward to input.
[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinic
s.net_lists_linux-2Dusb_msg179732.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyh
Quoted 2 lines
Quoted 2 lines
jrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY-
w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=es7kki6iuLJUp2rJn
Quoted 4 lines
Quoted 4 lines
zP9alXKyfJPNSfyxTVCKKDd_rQ&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinic
s.net_lists_linux-2Dusb_msg179393.html&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=u9FYoxKtyh
Quoted 2 lines
Quoted 2 lines
jrGFcyixFYqTjw1ZX0VsG2d8FCmzkTY-
w&m=wKdyWmYpbW791LAm7rYwvFYx5E0bjENyXZzHvK4vyFo&s=cFTmO9wPf7b6TZx FU
Quoted 7 lines
Quoted 3 lines
AAIJM0Z_wM1ttNIc1rct0uR6co&e=
I'm not sure who will submit the patch to make change to DWC3 for disabling U1/U2 (Anurag or you), but can you split your patch between dwc3 and configfs.
Have just written with Anurag, and he will submit a new patch set, where he has taken the control in
ep0.cfrom my patch, and combined with his devicetree bindings. So the plan is to drop the configfs interface completely, keep the devicetree binding names (dis-u1-entry- quirk) and let it do 3 things.
*Sets the latency to 0 in the BOS
*Disable U1/U2 acceptence
*Disable U1/U2 initiating
This also include rejectingSET_SEL.
Quoted 6 lines
We think this is the best option, and then dropping this patch as it is.
I will just send and email later on this thread, when the patch is available on marc.info as a link for reference to the future.
I have sent the v2 patch series with the changes that Claus mentioned above. The patch can be found here https://marc.info/?l=linux-kernel&m=155730212618388&w=2
Thanks,
Anurag Kumar Vulisha