linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1
@ 2019-03-22  8:51 Chen-Yu Tsai
  2019-03-22  8:51 ` [PATCH 1/2] phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs Chen-Yu Tsai
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-03-22  8:51 UTC (permalink / raw)
  To: Maxime Ripard, Greg Kroah-Hartman, Kishon Vijay Abraham I
  Cc: Chen-Yu Tsai, Grygorii Strashko, linux-usb, linux-arm-kernel,
	linux-kernel

From: Chen-Yu Tsai <wens@csie.org>

Hi everyone,

As previously reported [1], USB EHCI/OHCI hosts are broken on Allwinner
SoCs on v5.1-rc1. This is partially triggered by commit b97a31348379
("usb: core: comply to PHY framework"), and partially due to how the
Allwinner USB PHY driver handles phy_set_mode for non-OTG PHYs.

This series fixes this in both places.

Patch 1 makes phy-sun4i-usb accept PHY_MODE_USB_HOST for non-OTG PHYs.

Patch 2 makes the usb core fall back to setting the mode
PHY_MODE_USB_HOST if set_mode with PHY_MODE_USB_HOST_SS fails. If that
fails then the failure path is the same as before. This should make it
so existing USB 3.0 drivers are affected.

The patches don't have any dependencies on each other, and could go in
through separate branches. However this affects usability of USB input
devices and Ethernet dongles, I'd rather they go in sooner than later.

Regards
ChenYu


[1] https://lkml.org/lkml/2019/3/18/74

Chen-Yu Tsai (2):
  phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs
  usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode
    fails

 drivers/phy/allwinner/phy-sun4i-usb.c | 5 ++++-
 drivers/usb/core/hcd.c                | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs
  2019-03-22  8:51 [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Chen-Yu Tsai
@ 2019-03-22  8:51 ` Chen-Yu Tsai
  2019-03-22  8:51 ` [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails Chen-Yu Tsai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-03-22  8:51 UTC (permalink / raw)
  To: Maxime Ripard, Greg Kroah-Hartman, Kishon Vijay Abraham I
  Cc: Chen-Yu Tsai, Grygorii Strashko, linux-usb, linux-arm-kernel,
	linux-kernel

From: Chen-Yu Tsai <wens@csie.org>

While only the first PHY supports mode switching, the remaining PHYs
work in USB host mode. They should support set_mode with mode=USB_HOST
instead of failing. This is especially needed now that the USB core does
set_mode for all USB ports, which was added in commit b97a31348379 ("usb:
core: comply to PHY framework").

Make set_mode with mode=USB_HOST a no-op instead of failing for the
non-OTG USB PHYs.

Fixes: 6ba43c291961 ("phy-sun4i-usb: Add support for phy_set_mode")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 5163097b43df..4bbd9ede38c8 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -485,8 +485,11 @@ static int sun4i_usb_phy_set_mode(struct phy *_phy,
 	struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
 	int new_mode;
 
-	if (phy->index != 0)
+	if (phy->index != 0) {
+		if (mode == PHY_MODE_USB_HOST)
+			return 0;
 		return -EINVAL;
+	}
 
 	switch (mode) {
 	case PHY_MODE_USB_HOST:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails
  2019-03-22  8:51 [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Chen-Yu Tsai
  2019-03-22  8:51 ` [PATCH 1/2] phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs Chen-Yu Tsai
@ 2019-03-22  8:51 ` Chen-Yu Tsai
  2019-03-22 12:56   ` Neil Armstrong
  2019-03-22  9:05 ` [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Maxime Ripard
  2019-03-26  7:49 ` Greg Kroah-Hartman
  3 siblings, 1 reply; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-03-22  8:51 UTC (permalink / raw)
  To: Maxime Ripard, Greg Kroah-Hartman, Kishon Vijay Abraham I
  Cc: Chen-Yu Tsai, Grygorii Strashko, linux-usb, linux-arm-kernel,
	linux-kernel

From: Chen-Yu Tsai <wens@csie.org>

Some PHYs do not support PHY_MODE_USB_HOST_SS, i.e. USB 3.0 or higher.
Fall back and try the more generic PHY_MODE_USB_HOST if it fails.

Fixes: b97a31348379 ("usb: core: comply to PHY framework")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/usb/core/hcd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 3189181bb628..975d7c1288e3 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2741,6 +2741,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
 
 		retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
 						  PHY_MODE_USB_HOST_SS);
+		if (retval)
+			retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
+							  PHY_MODE_USB_HOST);
 		if (retval)
 			goto err_usb_phy_roothub_power_on;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1
  2019-03-22  8:51 [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Chen-Yu Tsai
  2019-03-22  8:51 ` [PATCH 1/2] phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs Chen-Yu Tsai
  2019-03-22  8:51 ` [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails Chen-Yu Tsai
@ 2019-03-22  9:05 ` Maxime Ripard
  2019-03-26  7:49 ` Greg Kroah-Hartman
  3 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2019-03-22  9:05 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Greg Kroah-Hartman, Kishon Vijay Abraham I, Chen-Yu Tsai,
	Grygorii Strashko, linux-usb, linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

On Fri, Mar 22, 2019 at 04:51:06PM +0800, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
>
> Hi everyone,
>
> As previously reported [1], USB EHCI/OHCI hosts are broken on Allwinner
> SoCs on v5.1-rc1. This is partially triggered by commit b97a31348379
> ("usb: core: comply to PHY framework"), and partially due to how the
> Allwinner USB PHY driver handles phy_set_mode for non-OTG PHYs.
>
> This series fixes this in both places.
>
> Patch 1 makes phy-sun4i-usb accept PHY_MODE_USB_HOST for non-OTG PHYs.
>
> Patch 2 makes the usb core fall back to setting the mode
> PHY_MODE_USB_HOST if set_mode with PHY_MODE_USB_HOST_SS fails. If that
> fails then the failure path is the same as before. This should make it
> so existing USB 3.0 drivers are affected.
>
> The patches don't have any dependencies on each other, and could go in
> through separate branches. However this affects usability of USB input
> devices and Ethernet dongles, I'd rather they go in sooner than later.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails
  2019-03-22  8:51 ` [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails Chen-Yu Tsai
@ 2019-03-22 12:56   ` Neil Armstrong
  0 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2019-03-22 12:56 UTC (permalink / raw)
  To: Chen-Yu Tsai, Maxime Ripard, Greg Kroah-Hartman, Kishon Vijay Abraham I
  Cc: Chen-Yu Tsai, Grygorii Strashko, linux-usb, linux-arm-kernel,
	linux-kernel, open list:ARM/Amlogic Meson...

On 22/03/2019 09:51, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
> 
> Some PHYs do not support PHY_MODE_USB_HOST_SS, i.e. USB 3.0 or higher.
> Fall back and try the more generic PHY_MODE_USB_HOST if it fails.
> 
> Fixes: b97a31348379 ("usb: core: comply to PHY framework")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  drivers/usb/core/hcd.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 3189181bb628..975d7c1288e3 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2741,6 +2741,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
>  
>  		retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
>  						  PHY_MODE_USB_HOST_SS);
> +		if (retval)
> +			retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
> +							  PHY_MODE_USB_HOST);
>  		if (retval)
>  			goto err_usb_phy_roothub_power_on;
>  
> 

Tested-by: Neil Armstrong <narmstrong@baylibre.com>

This fixes USB on Amlogic GXL/GXL, tested on a Nexbox A1 with a S912 SoC running v5.1-rc1

Error was :
[    4.851477] phy phy-d0078080.phy.3: unsupported PHY mode 5
[    4.856266] xhci-hcd: probe of xhci-hcd.0.auto failed with error -22

Neil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1
  2019-03-22  8:51 [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Chen-Yu Tsai
                   ` (2 preceding siblings ...)
  2019-03-22  9:05 ` [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Maxime Ripard
@ 2019-03-26  7:49 ` Greg Kroah-Hartman
  3 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2019-03-26  7:49 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Maxime Ripard, Kishon Vijay Abraham I, Chen-Yu Tsai,
	Grygorii Strashko, linux-usb, linux-arm-kernel, linux-kernel

On Fri, Mar 22, 2019 at 04:51:06PM +0800, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
> 
> Hi everyone,
> 
> As previously reported [1], USB EHCI/OHCI hosts are broken on Allwinner
> SoCs on v5.1-rc1. This is partially triggered by commit b97a31348379
> ("usb: core: comply to PHY framework"), and partially due to how the
> Allwinner USB PHY driver handles phy_set_mode for non-OTG PHYs.
> 
> This series fixes this in both places.
> 
> Patch 1 makes phy-sun4i-usb accept PHY_MODE_USB_HOST for non-OTG PHYs.
> 
> Patch 2 makes the usb core fall back to setting the mode
> PHY_MODE_USB_HOST if set_mode with PHY_MODE_USB_HOST_SS fails. If that
> fails then the failure path is the same as before. This should make it
> so existing USB 3.0 drivers are affected.
> 
> The patches don't have any dependencies on each other, and could go in
> through separate branches. However this affects usability of USB input
> devices and Ethernet dongles, I'd rather they go in sooner than later.

I'll take them both now, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-26  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22  8:51 [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Chen-Yu Tsai
2019-03-22  8:51 ` [PATCH 1/2] phy: sun4i-usb: Support set_mode to USB_HOST for non-OTG PHYs Chen-Yu Tsai
2019-03-22  8:51 ` [PATCH 2/2] usb: core: Try generic PHY_MODE_USB_HOST if usb_phy_roothub_set_mode fails Chen-Yu Tsai
2019-03-22 12:56   ` Neil Armstrong
2019-03-22  9:05 ` [PATCH 0/2] ARM: sunxi: Fix USB host init fail on v5.1-rc1 Maxime Ripard
2019-03-26  7:49 ` Greg Kroah-Hartman

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).