linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: mtu3: fix USB 3.0 dual-role-switch from device to host
@ 2022-04-19  8:12 Macpaul Lin
  2022-04-20  9:18 ` Chunfeng Yun
  0 siblings, 1 reply; 2+ messages in thread
From: Macpaul Lin @ 2022-04-19  8:12 UTC (permalink / raw)
  To: Chunfeng Yun, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
	linux-arm-kernel, linux-mediatek, linux-kernel
  Cc: Miles Chen, Bear Wang, Pablo Sun, Fabien Parent,
	Mediatek WSD Upstream, Macpaul Lin, Macpaul Lin, stable,
	Tainping Fang

Issue description:
  When an OTG port has been switched to device role and then switch back
  to host role again, the USB 3.0 Host (XHCI) will not be able to detect
  "plug in event of a connected USB 2.0/1.0 ((Highspeed and Fullspeed)
  devices until system reboot.

Root cause and Solution:
  There is a condition checking flag "ssusb->otg_switch.is_u3_drd" in
  toggle_opstate(). At the end of role switch procedure, toggle_opstate()
  will be called to set DC_SESSION and SOFT_CONN bit. If "is_u3_drd" was
  set and switched the role to USB host 3.0, bit DC_SESSION and SOFT_CONN
  will be skipped hence caused the port cannot detect connected USB 2.0
  (Highspeed and Fullspeed) devices. Simply remove the condition check to
  solve this issue.

Fixes: d0ed062a8b75 ("usb: mtu3: dual-role mode support")
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Signed-off-by: Tainping Fang <tianping.fang@mediatek.com>
Tested-by: Fabien Parent <fparent@baylibre.com>
Cc: stable@vger.kernel.org
---
 drivers/usb/mtu3/mtu3_dr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
index ec6ec621838b..b820724c56e4 100644
--- a/drivers/usb/mtu3/mtu3_dr.c
+++ b/drivers/usb/mtu3/mtu3_dr.c
@@ -21,10 +21,8 @@ static inline struct ssusb_mtk *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)
 
 static void toggle_opstate(struct ssusb_mtk *ssusb)
 {
-	if (!ssusb->otg_switch.is_u3_drd) {
-		mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
-		mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
-	}
+	mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
+	mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
 }
 
 /* only port0 supports dual-role mode */
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] usb: mtu3: fix USB 3.0 dual-role-switch from device to host
  2022-04-19  8:12 [PATCH] usb: mtu3: fix USB 3.0 dual-role-switch from device to host Macpaul Lin
@ 2022-04-20  9:18 ` Chunfeng Yun
  0 siblings, 0 replies; 2+ messages in thread
From: Chunfeng Yun @ 2022-04-20  9:18 UTC (permalink / raw)
  To: Macpaul Lin, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
	linux-arm-kernel, linux-mediatek, linux-kernel
  Cc: Miles Chen, Bear Wang, Pablo Sun, Fabien Parent,
	Mediatek WSD Upstream, Macpaul Lin, stable, Tainping Fang

On Tue, 2022-04-19 at 16:12 +0800, Macpaul Lin wrote:
> Issue description:
>   When an OTG port has been switched to device role and then switch
> back
>   to host role again, the USB 3.0 Host (XHCI) will not be able to
> detect
>   "plug in event of a connected USB 2.0/1.0 ((Highspeed and
> Fullspeed)
>   devices until system reboot.
> 
> Root cause and Solution:
>   There is a condition checking flag "ssusb->otg_switch.is_u3_drd" in
>   toggle_opstate(). At the end of role switch procedure,
> toggle_opstate()
>   will be called to set DC_SESSION and SOFT_CONN bit. If "is_u3_drd"
> was
>   set and switched the role to USB host 3.0, bit DC_SESSION and
> SOFT_CONN
>   will be skipped hence caused the port cannot detect connected USB
> 2.0
>   (Highspeed and Fullspeed) devices. Simply remove the condition
> check to
>   solve this issue.
> 
> Fixes: d0ed062a8b75 ("usb: mtu3: dual-role mode support")
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
> Signed-off-by: Tainping Fang <tianping.fang@mediatek.com>
> Tested-by: Fabien Parent <fparent@baylibre.com>
> Cc: stable@vger.kernel.org
> ---
>  drivers/usb/mtu3/mtu3_dr.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
> index ec6ec621838b..b820724c56e4 100644
> --- a/drivers/usb/mtu3/mtu3_dr.c
> +++ b/drivers/usb/mtu3/mtu3_dr.c
> @@ -21,10 +21,8 @@ static inline struct ssusb_mtk
> *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)
>  
>  static void toggle_opstate(struct ssusb_mtk *ssusb)
>  {
> -	if (!ssusb->otg_switch.is_u3_drd) {
> -		mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL,
> DC_SESSION);
> -		mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT,
> SOFT_CONN);
> -	}
> +	mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
> +	mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
>  }
>  
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks

>  /* only port0 supports dual-role mode */
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-04-20  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19  8:12 [PATCH] usb: mtu3: fix USB 3.0 dual-role-switch from device to host Macpaul Lin
2022-04-20  9:18 ` Chunfeng Yun

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