lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BYAPR12MB339967000494531F9B700611A7AD9@BYAPR12MB3399.namprd12.prod.outlook.com>
Date:   Wed, 1 Mar 2023 11:34:19 +0000
From:   Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To:     Ziyang Huang <hzyitc@...look.com>
CC:     "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "fabrice.gasnier@...s.st.com" <fabrice.gasnier@...s.st.com>,
        "amelie.delaunay@...s.st.com" <amelie.delaunay@...s.st.com>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2] usb: dwc2: drd: fix inconsistent mode if
 role-switch-default-mode="host"

Hi Ziyang,

On 2/21/2023 2:30 PM, Ziyang Huang <hzyitc@...look.com> wrote:
>From: Ziyang Huang <hzyitc@...look.com>
>Sent: Tuesday, February 21, 2023 2:30 PM
>To: Minas Harutyunyan <hminas@...opsys.com>
>Cc: gregkh@...uxfoundation.org; fabrice.gasnier@...s.st.com;
>amelie.delaunay@...s.st.com; linux-usb@...r.kernel.org; linux-
>kernel@...r.kernel.org; Ziyang Huang <hzyitc@...look.com>
>Subject: [PATCH v2] usb: dwc2: drd: fix inconsistent mode if role-switch-
>default-mode="host"
>
>Some boards might use USB-A female connector for USB ports, however, the
>port could be connected to a dual-mode USB controller, making it also
>behaves as a peripheral device if male-to-male cable is connected.
>
>In this case, the dts looks like this:
>
>	&usb0 {
>		status = "okay";
>		dr_mode = "otg";
>		usb-role-switch;
>		role-switch-default-mode = "host";
>	};
>
>After boot, dwc2_ovr_init() sets GOTGCTL to GOTGCTL_AVALOVAL and call
>dwc2_force_mode() with parameter host=false, which causes inconsistent mode
>- The hardware is in peripheral mode while the kernel status is in host
>mode.
>
>What we can do now is to call dwc2_drd_role_sw_set() to switch to device
>mode, and everything should work just fine now, even switching back to
>none(default) mode afterwards.
>
>Fixes: e14acb876985 ("usb: dwc2: drd: add role-switch-default-node support")
>Signed-off-by: Ziyang Huang <hzyitc@...look.com>

Reviewed-by: Amelie Delaunay <amelie.delaunay@...s.st.com>
Tested-by: Fabrice Gasnier <fabrice.gasnier@...s.st.com>
Acked-by: Minas Harutyunyan <hminas@...opsys.com>


Thanks,
Minas


>---
>Changes since v1
>- Use corrent name in Signed-off-by
>
> drivers/usb/dwc2/drd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c index
>d8d6493bc457..a8605b02115b 100644
>--- a/drivers/usb/dwc2/drd.c
>+++ b/drivers/usb/dwc2/drd.c
>@@ -35,7 +35,8 @@ static void dwc2_ovr_init(struct dwc2_hsotg *hsotg)
>
> 	spin_unlock_irqrestore(&hsotg->lock, flags);
>
>-	dwc2_force_mode(hsotg, (hsotg->dr_mode == USB_DR_MODE_HOST));
>+	dwc2_force_mode(hsotg, (hsotg->dr_mode == USB_DR_MODE_HOST) ||
>+				(hsotg->role_sw_default_mode == USB_DR_MODE_HOST));
> }
>
> static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid)
>--
>2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ