* [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync
@ 2022-08-22 10:32 Peter Geis
2022-08-23 3:41 ` Samuel Holland
2022-08-23 11:26 ` Heiko Stübner
0 siblings, 2 replies; 4+ messages in thread
From: Peter Geis @ 2022-08-22 10:32 UTC (permalink / raw)
To: Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul,
Samuel Holland, Peter Geis
Cc: Markus Reichl, Michael Riesch, linux-phy, linux-arm-kernel,
linux-rockchip, linux-kernel
The otg sync state patch reuses the ret variable, but fails to set it to
zero after use. This leads to a situation when the otg port is in
peripheral mode where the otg phy aborts halfway through setup. Fix this
by setting ret to zero after use.
Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
Reported-by: Markus Reichl <m.reichl@fivetechno.de>
Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
Tested-by: Markus Reichl <m.reichl@fivetechno.de>
---
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 0b1e9337ee8e..5fc7c374a6b4 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
/* do initial sync of usb state */
ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+ ret = 0;
}
}
--
2.25.1
_______________________________________________
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] 4+ messages in thread* Re: [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync
2022-08-22 10:32 [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
@ 2022-08-23 3:41 ` Samuel Holland
2022-08-23 5:46 ` Peter Geis
2022-08-23 11:26 ` Heiko Stübner
1 sibling, 1 reply; 4+ messages in thread
From: Samuel Holland @ 2022-08-23 3:41 UTC (permalink / raw)
To: Peter Geis, Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul
Cc: Markus Reichl, Michael Riesch, linux-phy, linux-arm-kernel,
linux-rockchip, linux-kernel
On 8/22/22 5:32 AM, Peter Geis wrote:
> The otg sync state patch reuses the ret variable, but fails to set it to
> zero after use. This leads to a situation when the otg port is in
> peripheral mode where the otg phy aborts halfway through setup. Fix this
> by setting ret to zero after use.
>
> Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
>
> Reported-by: Markus Reichl <m.reichl@fivetechno.de>
> Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
> Tested-by: Markus Reichl <m.reichl@fivetechno.de>
> ---
> drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 0b1e9337ee8e..5fc7c374a6b4 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
> /* do initial sync of usb state */
> ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
> + ret = 0;
The bug was caused by the unexpected consequence of (mis|re)using the "ret"
variable for a temporary value. Please introduce a new variable here, else the
use of "ret" is even more confusing. This code also wipes out any error returned
by devm_extcon_register_notifier().
Regards,
Samuel
_______________________________________________
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] 4+ messages in thread* Re: [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync
2022-08-23 3:41 ` Samuel Holland
@ 2022-08-23 5:46 ` Peter Geis
0 siblings, 0 replies; 4+ messages in thread
From: Peter Geis @ 2022-08-23 5:46 UTC (permalink / raw)
To: Samuel Holland
Cc: Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul, Markus Reichl,
Michael Riesch, open list:GENERIC PHY FRAMEWORK, arm-mail-list,
open list:ARM/Rockchip SoC..., Linux Kernel Mailing List
On Tue, Aug 23, 2022 at 5:41 AM Samuel Holland <samuel@sholland.org> wrote:
>
> On 8/22/22 5:32 AM, Peter Geis wrote:
> > The otg sync state patch reuses the ret variable, but fails to set it to
> > zero after use. This leads to a situation when the otg port is in
> > peripheral mode where the otg phy aborts halfway through setup. Fix this
> > by setting ret to zero after use.
> >
> > Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
> >
> > Reported-by: Markus Reichl <m.reichl@fivetechno.de>
> > Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
> > Tested-by: Markus Reichl <m.reichl@fivetechno.de>
> > ---
> > drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > index 0b1e9337ee8e..5fc7c374a6b4 100644
> > --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > @@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
> > /* do initial sync of usb state */
> > ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> > extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
> > + ret = 0;
>
> The bug was caused by the unexpected consequence of (mis|re)using the "ret"
> variable for a temporary value. Please introduce a new variable here, else the
> use of "ret" is even more confusing. This code also wipes out any error returned
> by devm_extcon_register_notifier().
I see your point here, I also need to skip this if
devm_extcon_register_notifier() fails as well. I'll spin up a v2.
Thanks for catching that!
>
> Regards,
> Samuel
_______________________________________________
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] 4+ messages in thread
* Re: [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync
2022-08-22 10:32 [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
2022-08-23 3:41 ` Samuel Holland
@ 2022-08-23 11:26 ` Heiko Stübner
1 sibling, 0 replies; 4+ messages in thread
From: Heiko Stübner @ 2022-08-23 11:26 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul, Samuel Holland, Peter Geis,
Peter Geis
Cc: Markus Reichl, Michael Riesch, linux-phy, linux-arm-kernel,
linux-rockchip, linux-kernel
Am Montag, 22. August 2022, 12:32:18 CEST schrieb Peter Geis:
> The otg sync state patch reuses the ret variable, but fails to set it to
> zero after use. This leads to a situation when the otg port is in
> peripheral mode where the otg phy aborts halfway through setup. Fix this
> by setting ret to zero after use.
>
> Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
>
> Reported-by: Markus Reichl <m.reichl@fivetechno.de>
> Reported-by: Michael Riesch <michael.riesch@wolfvision.net>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
> Tested-by: Markus Reichl <m.reichl@fivetechno.de>
> ---
> drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 0b1e9337ee8e..5fc7c374a6b4 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
> /* do initial sync of usb state */
> ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
> + ret = 0;
> }
> }
I also ran into that issue just now :-) .
So am looking forward to v2.
Thanks
Heiko
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2022-08-23 11:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-22 10:32 [PATCH] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
2022-08-23 3:41 ` Samuel Holland
2022-08-23 5:46 ` Peter Geis
2022-08-23 11:26 ` Heiko Stübner
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).