2021-10-08 07:58:50

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 0/2] usb: dwc2: fill in gadget caps, configure it for stm32mp15

This patchset fills in 'otg_caps' of the usb_gadget structure, and
configures it on stm32mp15.

When dwc2 is configured as dual role (OTG), the USB gadget descriptors
(device mode) are configured via configfs. This lead in calling
usb_otg_descriptor_init().
In usb_otg_descriptor_init() (drivers/usb/gadget/config.c):
- If otg caps structure is provided -> use it
- If otg caps structure isn't provided -> HNP and SRP are enabled by default

This could lead to a configuration mismatch beetween:
- OTG controller: HNP and SRP aren't enabled
- gadget descriptors: HNP and SRP are advertised

---
Changes in v2:
- replace otg_cap bit field by otg_caps structure.
- Fix build issue when HOST only mode is selected [1]
- DT patch for stm32mp151 merged in v1, so not resent

[1] https://syzkaller.appspot.com/bug?extid=7af597ce2b38596c16ea

Fabrice Gasnier (2):
usb: dwc2: add otg_rev and otg_caps information for gadget driver
usb: dwc2: stm32mp15: set otg_rev

drivers/usb/dwc2/core.h | 19 ++++++------
drivers/usb/dwc2/debugfs.c | 4 ++-
drivers/usb/dwc2/gadget.c | 1 +
drivers/usb/dwc2/hcd.c | 12 +++-----
drivers/usb/dwc2/params.c | 75 ++++++++++++++++++++++++++--------------------
5 files changed, 59 insertions(+), 52 deletions(-)

--
2.7.4


2021-10-08 07:59:56

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 2/2] usb: dwc2: stm32mp15: set otg_rev

STM32MP15 complies with the OTG 2.0. Set OTG revision accordingly. It is
useful for the of_usb_update_otg_caps() routine to check and update
otg_rev to the lower value between DT and provided params.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
Changes in v2:
- set otg_rev in otg_caps structure directly
---
drivers/usb/dwc2/params.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 99d3b62..d300ae3 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -176,6 +176,7 @@ static void dwc2_set_stm32mp15_fsotg_params(struct dwc2_hsotg *hsotg)

p->otg_caps.hnp_support = false;
p->otg_caps.srp_support = false;
+ p->otg_caps.otg_rev = 0x200;
p->speed = DWC2_SPEED_PARAM_FULL;
p->host_rx_fifo_size = 128;
p->host_nperio_tx_fifo_size = 96;
@@ -197,6 +198,7 @@ static void dwc2_set_stm32mp15_hsotg_params(struct dwc2_hsotg *hsotg)

p->otg_caps.hnp_support = false;
p->otg_caps.srp_support = false;
+ p->otg_caps.otg_rev = 0x200;
p->activate_stm_id_vb_detection = !device_property_read_bool(hsotg->dev, "usb-role-switch");
p->host_rx_fifo_size = 440;
p->host_nperio_tx_fifo_size = 256;
--
2.7.4

2021-10-13 14:05:15

by Fabrice Gasnier

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] usb: dwc2: fill in gadget caps, configure it for stm32mp15

On 10/8/21 9:53 AM, Fabrice Gasnier wrote:
> This patchset fills in 'otg_caps' of the usb_gadget structure, and
> configures it on stm32mp15.
>
> When dwc2 is configured as dual role (OTG), the USB gadget descriptors
> (device mode) are configured via configfs. This lead in calling
> usb_otg_descriptor_init().
> In usb_otg_descriptor_init() (drivers/usb/gadget/config.c):
> - If otg caps structure is provided -> use it
> - If otg caps structure isn't provided -> HNP and SRP are enabled by default
>
> This could lead to a configuration mismatch beetween:
> - OTG controller: HNP and SRP aren't enabled
> - gadget descriptors: HNP and SRP are advertised
>
> ---

Hi All, I just sent a v3 of this series, to add the dt-bindings.

Please rather review the v3.

Thanks in advance,
Fabrice


> Changes in v2:
> - replace otg_cap bit field by otg_caps structure.
> - Fix build issue when HOST only mode is selected [1]
> - DT patch for stm32mp151 merged in v1, so not resent
>
> [1] https://syzkaller.appspot.com/bug?extid=7af597ce2b38596c16ea
>
> Fabrice Gasnier (2):
> usb: dwc2: add otg_rev and otg_caps information for gadget driver
> usb: dwc2: stm32mp15: set otg_rev
>
> drivers/usb/dwc2/core.h | 19 ++++++------
> drivers/usb/dwc2/debugfs.c | 4 ++-
> drivers/usb/dwc2/gadget.c | 1 +
> drivers/usb/dwc2/hcd.c | 12 +++-----
> drivers/usb/dwc2/params.c | 75 ++++++++++++++++++++++++++--------------------
> 5 files changed, 59 insertions(+), 52 deletions(-)
>