diff mbox series

[1/1] usb: dwc3: Do not get extcon device when usb-role-switch is used

Message ID 20221106214804.2814-1-j@jannau.net
State New
Headers show
Series [1/1] usb: dwc3: Do not get extcon device when usb-role-switch is used | expand

Commit Message

Janne Grunau Nov. 6, 2022, 9:48 p.m. UTC
The change breaks device tree based platforms with PHY device and use
usb-role-switch instead of an extcon switch. extcon_find_edev_by_node()
will return EPROBE_DEFER if it can not find a device so probing without
an extcon device will be deferred indefinitely. Fix this by
explicitly checking for usb-role-switch.
At least the out-of-tree USB3 support on Apple silicon based platforms
using dwc3 with tipd USB Type-C and PD controller is affected by this
issue.

Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
Cc: stable@kernel.org
Signed-off-by: Janne Grunau <j@jannau.net>
---
 drivers/usb/dwc3/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Thinh Nguyen Nov. 8, 2022, 2:02 a.m. UTC | #1
Hi,

On Sun, Nov 06, 2022, Janne Grunau wrote:
> The change breaks device tree based platforms with PHY device and use
> usb-role-switch instead of an extcon switch. extcon_find_edev_by_node()
> will return EPROBE_DEFER if it can not find a device so probing without
> an extcon device will be deferred indefinitely. Fix this by
> explicitly checking for usb-role-switch.
> At least the out-of-tree USB3 support on Apple silicon based platforms
> using dwc3 with tipd USB Type-C and PD controller is affected by this
> issue.
> 
> Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
> Cc: stable@kernel.org
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
>  drivers/usb/dwc3/core.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index c0e7c76dc5c8..1f348bc867c2 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
>  	if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
>  		return extcon_get_extcon_dev(name);
>  
> +	/*
> +	 * Check explicitly if "usb-role-switch" is used since
> +	 * extcon_find_edev_by_node() can not be used to check the absence of

can not -> can't or cannot

> +	 * an extcon device. In the absence of an device it will always return

"a" device,

> +	 * EPROBE_DEFER.
> +	 */
> +	if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) &&
> +	    device_property_read_bool(dev, "usb-role-switch"))
> +		return NULL;
> +
>  	/*
>  	 * Try to get an extcon device from the USB PHY controller's "port"
>  	 * node. Check if it has the "port" node first, to avoid printing the
> -- 
> 2.37.3
> 

Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd:
Avoid error when extcon is missing") did not account for this platform
setup.

This looks fine to me. Should we cleanup the incomplete check and stale
comment right after this too (as a separate patch)?

Thanks,
Thinh
Greg Kroah-Hartman Nov. 8, 2022, 3:43 p.m. UTC | #2
On Tue, Nov 08, 2022 at 02:02:19AM +0000, Thinh Nguyen wrote:
> Hi,
> 
> On Sun, Nov 06, 2022, Janne Grunau wrote:
> > The change breaks device tree based platforms with PHY device and use
> > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node()
> > will return EPROBE_DEFER if it can not find a device so probing without
> > an extcon device will be deferred indefinitely. Fix this by
> > explicitly checking for usb-role-switch.
> > At least the out-of-tree USB3 support on Apple silicon based platforms
> > using dwc3 with tipd USB Type-C and PD controller is affected by this
> > issue.
> > 
> > Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
> > Cc: stable@kernel.org
> > Signed-off-by: Janne Grunau <j@jannau.net>
> > ---
> >  drivers/usb/dwc3/core.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index c0e7c76dc5c8..1f348bc867c2 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> >  	if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
> >  		return extcon_get_extcon_dev(name);
> >  
> > +	/*
> > +	 * Check explicitly if "usb-role-switch" is used since
> > +	 * extcon_find_edev_by_node() can not be used to check the absence of
> 
> can not -> can't or cannot

"can not" is fine.

> 
> > +	 * an extcon device. In the absence of an device it will always return
> 
> "a" device,

Not an issue.

> > +	 * EPROBE_DEFER.
> > +	 */
> > +	if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) &&
> > +	    device_property_read_bool(dev, "usb-role-switch"))
> > +		return NULL;
> > +
> >  	/*
> >  	 * Try to get an extcon device from the USB PHY controller's "port"
> >  	 * node. Check if it has the "port" node first, to avoid printing the
> > -- 
> > 2.37.3
> > 
> 
> Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd:
> Avoid error when extcon is missing") did not account for this platform
> setup.
> 
> This looks fine to me. Should we cleanup the incomplete check and stale
> comment right after this too (as a separate patch)?

Is this a Reviewed-by: ?

thanks,

greg k-h
Thinh Nguyen Nov. 8, 2022, 5:54 p.m. UTC | #3
On Tue, Nov 08, 2022, Greg Kroah-Hartman wrote:
> On Tue, Nov 08, 2022 at 02:02:19AM +0000, Thinh Nguyen wrote:
> > Hi,
> > 
> > On Sun, Nov 06, 2022, Janne Grunau wrote:
> > > The change breaks device tree based platforms with PHY device and use
> > > usb-role-switch instead of an extcon switch. extcon_find_edev_by_node()
> > > will return EPROBE_DEFER if it can not find a device so probing without
> > > an extcon device will be deferred indefinitely. Fix this by
> > > explicitly checking for usb-role-switch.
> > > At least the out-of-tree USB3 support on Apple silicon based platforms
> > > using dwc3 with tipd USB Type-C and PD controller is affected by this
> > > issue.
> > > 
> > > Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
> > > Cc: stable@kernel.org
> > > Signed-off-by: Janne Grunau <j@jannau.net>
> > > ---
> > >  drivers/usb/dwc3/core.c | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > index c0e7c76dc5c8..1f348bc867c2 100644
> > > --- a/drivers/usb/dwc3/core.c
> > > +++ b/drivers/usb/dwc3/core.c
> > > @@ -1710,6 +1710,16 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> > >  	if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
> > >  		return extcon_get_extcon_dev(name);
> > >  
> > > +	/*
> > > +	 * Check explicitly if "usb-role-switch" is used since
> > > +	 * extcon_find_edev_by_node() can not be used to check the absence of
> > 
> > can not -> can't or cannot
> 
> "can not" is fine.
> 
> > 
> > > +	 * an extcon device. In the absence of an device it will always return
> > 
> > "a" device,
> 
> Not an issue.
> 
> > > +	 * EPROBE_DEFER.
> > > +	 */
> > > +	if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) &&
> > > +	    device_property_read_bool(dev, "usb-role-switch"))
> > > +		return NULL;
> > > +
> > >  	/*
> > >  	 * Try to get an extcon device from the USB PHY controller's "port"
> > >  	 * node. Check if it has the "port" node first, to avoid printing the
> > > -- 
> > > 2.37.3
> > > 
> > 
> > Looks like the "port" node check from c824c73a5e08 ("usb: dwc3: drd:
> > Avoid error when extcon is missing") did not account for this platform
> > setup.
> > 
> > This looks fine to me. Should we cleanup the incomplete check and stale
> > comment right after this too (as a separate patch)?
> 
> Is this a Reviewed-by: ?
> 

Please pick up this fix.

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c0e7c76dc5c8..1f348bc867c2 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1710,6 +1710,16 @@  static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
 	if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
 		return extcon_get_extcon_dev(name);
 
+	/*
+	 * Check explicitly if "usb-role-switch" is used since
+	 * extcon_find_edev_by_node() can not be used to check the absence of
+	 * an extcon device. In the absence of an device it will always return
+	 * EPROBE_DEFER.
+	 */
+	if (IS_ENABLED(CONFIG_USB_ROLE_SWITCH) &&
+	    device_property_read_bool(dev, "usb-role-switch"))
+		return NULL;
+
 	/*
 	 * Try to get an extcon device from the USB PHY controller's "port"
 	 * node. Check if it has the "port" node first, to avoid printing the