* [PATCH 0/4] Fix DWC2 USB role switch support
@ 2020-07-24 12:37 Amelie Delaunay
2020-07-24 12:37 ` [PATCH 1/4] dt-bindings: usb: dwc2: add optional usb-role-switch property Amelie Delaunay
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Amelie Delaunay @ 2020-07-24 12:37 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre Torgue
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice Gasnier, Amelie Delaunay,
Martin Blumenstingl
This patchset adds missing documentation for usb-role-switch support in DWC2
bindings. It also fixes build issue when config is DWC2_HOST only,
sleeping while atomic issue and missing usb-role-switch unregistration in probe
error path.
Amelie Delaunay (4):
dt-bindings: usb: dwc2: add optional usb-role-switch property
usb: dwc2: fix build issue when config is USB_DWC2_HOST only
usb: dwc2: drd: fix sleeping while spinlock atomic context
usb: dwc2: fix error path with missing dwc2_drd_exit
.../devicetree/bindings/usb/dwc2.yaml | 4 +++
drivers/usb/dwc2/core.h | 1 +
drivers/usb/dwc2/drd.c | 30 +++++++------------
drivers/usb/dwc2/platform.c | 2 ++
4 files changed, 17 insertions(+), 20 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] dt-bindings: usb: dwc2: add optional usb-role-switch property
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
@ 2020-07-24 12:37 ` Amelie Delaunay
2020-07-24 12:37 ` [PATCH 2/4] usb: dwc2: fix build issue when config is USB_DWC2_HOST only Amelie Delaunay
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Amelie Delaunay @ 2020-07-24 12:37 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre Torgue
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice Gasnier, Amelie Delaunay,
Martin Blumenstingl
This patch documents the usb-role-switch property in dwc2 bindings, now
that usb-role-switch support is available in dwc2 driver.
Fixes: bc0f0d4a5853 ("usb: dwc2: override PHY input signals with usb role switch support")
Reported-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
Documentation/devicetree/bindings/usb/dwc2.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/dwc2.yaml b/Documentation/devicetree/bindings/usb/dwc2.yaml
index 9352a8ef60a6..7b226eeffe82 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.yaml
+++ b/Documentation/devicetree/bindings/usb/dwc2.yaml
@@ -100,6 +100,10 @@ properties:
dr_mode:
enum: [host, peripheral, otg]
+ usb-role-switch:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description: Support role switch.
+
g-rx-fifo-size:
$ref: /schemas/types.yaml#/definitions/uint32
description: size of rx fifo size in gadget mode.
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] usb: dwc2: fix build issue when config is USB_DWC2_HOST only
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
2020-07-24 12:37 ` [PATCH 1/4] dt-bindings: usb: dwc2: add optional usb-role-switch property Amelie Delaunay
@ 2020-07-24 12:37 ` Amelie Delaunay
2020-07-24 12:37 ` [PATCH 3/4] usb: dwc2: drd: fix sleeping while spinlock atomic context Amelie Delaunay
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Amelie Delaunay @ 2020-07-24 12:37 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre Torgue
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice Gasnier, Amelie Delaunay,
Martin Blumenstingl
This patch add missing definition of dwc2_hsotg_core_disconnect and
check configuration before using hsotg->test_mode, to fix build issue when
config USB_DWC2_PERIPHERAL or USB_DWC2_DUAL_ROLE are not set.
Fixes: bc0f0d4a5853 ("usb: dwc2: override PHY input signals with usb role switch support")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/usb/dwc2/core.h | 1 +
drivers/usb/dwc2/drd.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 33e790ccefb3..7161344c6522 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1425,6 +1425,7 @@ static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
{ return 0; }
static inline void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
bool reset) {}
+static inline void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) {}
static inline void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
static inline void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c
index 032efffa37ab..5099841b1417 100644
--- a/drivers/usb/dwc2/drd.c
+++ b/drivers/usb/dwc2/drd.c
@@ -76,11 +76,14 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
(role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL))
return -EINVAL;
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
/* Skip session if core is in test mode */
if (role == USB_ROLE_NONE && hsotg->test_mode) {
dev_dbg(hsotg->dev, "Core is in test mode\n");
return -EBUSY;
}
+#endif
spin_lock_irqsave(&hsotg->lock, flags);
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] usb: dwc2: drd: fix sleeping while spinlock atomic context
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
2020-07-24 12:37 ` [PATCH 1/4] dt-bindings: usb: dwc2: add optional usb-role-switch property Amelie Delaunay
2020-07-24 12:37 ` [PATCH 2/4] usb: dwc2: fix build issue when config is USB_DWC2_HOST only Amelie Delaunay
@ 2020-07-24 12:37 ` Amelie Delaunay
2020-07-24 12:37 ` [PATCH 4/4] usb: dwc2: fix error path with missing dwc2_drd_exit Amelie Delaunay
2020-07-27 9:39 ` [PATCH 0/4] Fix DWC2 USB role switch support Amelie DELAUNAY
4 siblings, 0 replies; 6+ messages in thread
From: Amelie Delaunay @ 2020-07-24 12:37 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre Torgue
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice Gasnier, Amelie Delaunay,
Martin Blumenstingl
If GINTSTS.CURMODE is not yet reflecting the expecting mode after calling
dwc2_force_mode, we enter in the dwc2_wait_for_mode function while under
spinlock atomic context.
To avoid this situation, move the call to dwc2_force_mode after the
spinlock atomic context.
Fixes: bc0f0d4a5853 ("usb: dwc2: override PHY input signals with usb role switch support")
Reported-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/usb/dwc2/drd.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c
index 5099841b1417..2d4176f5788e 100644
--- a/drivers/usb/dwc2/drd.c
+++ b/drivers/usb/dwc2/drd.c
@@ -70,6 +70,7 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
{
struct dwc2_hsotg *hsotg = usb_role_switch_get_drvdata(sw);
unsigned long flags;
+ int already = 0;
/* Skip session not in line with dr_mode */
if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) ||
@@ -88,26 +89,9 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
spin_lock_irqsave(&hsotg->lock, flags);
if (role == USB_ROLE_HOST) {
- if (dwc2_ovr_avalid(hsotg, true))
- goto unlock;
-
- if (hsotg->dr_mode == USB_DR_MODE_OTG)
- /*
- * This will raise a Connector ID Status Change
- * Interrupt - connID A
- */
- dwc2_force_mode(hsotg, true);
+ already = dwc2_ovr_avalid(hsotg, true);
} else if (role == USB_ROLE_DEVICE) {
- if (dwc2_ovr_bvalid(hsotg, true))
- goto unlock;
-
- if (hsotg->dr_mode == USB_DR_MODE_OTG)
- /*
- * This will raise a Connector ID Status Change
- * Interrupt - connID B
- */
- dwc2_force_mode(hsotg, false);
-
+ already = dwc2_ovr_bvalid(hsotg, true);
/* This clear DCTL.SFTDISCON bit */
dwc2_hsotg_core_connect(hsotg);
} else {
@@ -120,9 +104,12 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
}
}
-unlock:
spin_unlock_irqrestore(&hsotg->lock, flags);
+ if (!already && hsotg->dr_mode == USB_DR_MODE_OTG)
+ /* This will raise a Connector ID Status Change Interrupt */
+ dwc2_force_mode(hsotg, role == USB_ROLE_HOST);
+
dev_dbg(hsotg->dev, "%s-session valid\n",
role == USB_ROLE_NONE ? "No" :
role == USB_ROLE_HOST ? "A" : "B");
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] usb: dwc2: fix error path with missing dwc2_drd_exit
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
` (2 preceding siblings ...)
2020-07-24 12:37 ` [PATCH 3/4] usb: dwc2: drd: fix sleeping while spinlock atomic context Amelie Delaunay
@ 2020-07-24 12:37 ` Amelie Delaunay
2020-07-27 9:39 ` [PATCH 0/4] Fix DWC2 USB role switch support Amelie DELAUNAY
4 siblings, 0 replies; 6+ messages in thread
From: Amelie Delaunay @ 2020-07-24 12:37 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre Torgue
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice Gasnier, Amelie Delaunay,
Martin Blumenstingl
In case of failure, role switch has to be unregistered. It is done by
dwc2_drd_exit.
Fixes: bc0f0d4a5853 ("usb: dwc2: override PHY input signals with usb role switch support")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/usb/dwc2/platform.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 68b56b43a45e..f4a0371c3e89 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -600,6 +600,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
return 0;
error_init:
+ dwc2_drd_exit(hsotg);
+
if (hsotg->params.activate_stm_id_vb_detection)
regulator_disable(hsotg->usb33d);
error:
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Fix DWC2 USB role switch support
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
` (3 preceding siblings ...)
2020-07-24 12:37 ` [PATCH 4/4] usb: dwc2: fix error path with missing dwc2_drd_exit Amelie Delaunay
@ 2020-07-27 9:39 ` Amelie DELAUNAY
4 siblings, 0 replies; 6+ messages in thread
From: Amelie DELAUNAY @ 2020-07-27 9:39 UTC (permalink / raw)
To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
Maxime Coquelin, Alexandre TORGUE
Cc: linux-usb, devicetree, linux-kernel, linux-arm-kernel,
linux-stm32, Fabrice GASNIER, Martin Blumenstingl
On 7/24/20 2:37 PM, Amelie DELAUNAY wrote:
> This patchset adds missing documentation for usb-role-switch support in DWC2
> bindings. It also fixes build issue when config is DWC2_HOST only,
> sleeping while atomic issue and missing usb-role-switch unregistration
> in probe
> error path.
>
> Amelie Delaunay (4):
> dt-bindings: usb: dwc2: add optional usb-role-switch property
> usb: dwc2: fix build issue when config is USB_DWC2_HOST only
> usb: dwc2: drd: fix sleeping while spinlock atomic context
> usb: dwc2: fix error path with missing dwc2_drd_exit
>
> .../devicetree/bindings/usb/dwc2.yaml | 4 +++
> drivers/usb/dwc2/core.h | 1 +
> drivers/usb/dwc2/drd.c | 30 +++++++------------
> drivers/usb/dwc2/platform.c | 2 ++
> 4 files changed, 17 insertions(+), 20 deletions(-)
>
> --
> 2.17.1
>
Patchset dropped.
Regards,
Amelie
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-27 9:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 12:37 [PATCH 0/4] Fix DWC2 USB role switch support Amelie Delaunay
2020-07-24 12:37 ` [PATCH 1/4] dt-bindings: usb: dwc2: add optional usb-role-switch property Amelie Delaunay
2020-07-24 12:37 ` [PATCH 2/4] usb: dwc2: fix build issue when config is USB_DWC2_HOST only Amelie Delaunay
2020-07-24 12:37 ` [PATCH 3/4] usb: dwc2: drd: fix sleeping while spinlock atomic context Amelie Delaunay
2020-07-24 12:37 ` [PATCH 4/4] usb: dwc2: fix error path with missing dwc2_drd_exit Amelie Delaunay
2020-07-27 9:39 ` [PATCH 0/4] Fix DWC2 USB role switch support Amelie DELAUNAY
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).