linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync
@ 2022-08-23 14:47 Peter Geis
  2022-08-23 18:48 ` Heiko Stübner
  2022-08-24  5:33 ` Michael Riesch
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Geis @ 2022-08-23 14:47 UTC (permalink / raw)
  To: Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul, Peter Geis,
	Samuel Holland
  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.  It also
fails to account for a failure to register the extcon notifier. Fix this
by using our own variable and skipping otg sync in case of failure.

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 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 0b1e9337ee8e..d579a22c61df 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 					  struct rockchip_usb2phy_port *rport,
 					  struct device_node *child_np)
 {
-	int ret;
+	int ret, id;
 
 	rport->port_id = USB2PHY_PORT_OTG;
 	rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
@@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 					EXTCON_USB_HOST, &rport->event_nb);
 		if (ret)
 			dev_err(rphy->dev, "register USB HOST notifier failed\n");
+			goto out;
 
 		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
 			/* 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);
+			id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id);
 		}
 	}
 
-- 
2.25.1


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

* Re: [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync
  2022-08-23 14:47 [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
@ 2022-08-23 18:48 ` Heiko Stübner
  2022-08-24  5:33 ` Michael Riesch
  1 sibling, 0 replies; 4+ messages in thread
From: Heiko Stübner @ 2022-08-23 18:48 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Peter Geis, Samuel Holland,
	Peter Geis
  Cc: Markus Reichl, Michael Riesch, linux-phy, linux-arm-kernel,
	linux-rockchip, linux-kernel

Am Dienstag, 23. August 2022, 16:47:28 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.  It also
> fails to account for a failure to register the extcon notifier. Fix this
> by using our own variable and skipping otg sync in case of failure.
> 
> 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>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>

> ---
>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 0b1e9337ee8e..d579a22c61df 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
>  					  struct rockchip_usb2phy_port *rport,
>  					  struct device_node *child_np)
>  {
> -	int ret;
> +	int ret, id;
>  
>  	rport->port_id = USB2PHY_PORT_OTG;
>  	rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
> @@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
>  					EXTCON_USB_HOST, &rport->event_nb);
>  		if (ret)
>  			dev_err(rphy->dev, "register USB HOST notifier failed\n");
> +			goto out;
>  
>  		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
>  			/* 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);
> +			id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> +			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id);
>  		}
>  	}
>  
> 





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

* Re: [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync
  2022-08-23 14:47 [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
  2022-08-23 18:48 ` Heiko Stübner
@ 2022-08-24  5:33 ` Michael Riesch
  2022-08-24 10:17   ` Peter Geis
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Riesch @ 2022-08-24  5:33 UTC (permalink / raw)
  To: Peter Geis, Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul,
	Samuel Holland
  Cc: Markus Reichl, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel

Hi Peter,

On 8/23/22 16:47, 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.  It also
> fails to account for a failure to register the extcon notifier. Fix this
> by using our own variable and skipping otg sync in case of failure.
> 
> 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 | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 0b1e9337ee8e..d579a22c61df 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
>  					  struct rockchip_usb2phy_port *rport,
>  					  struct device_node *child_np)
>  {
> -	int ret;
> +	int ret, id;
>  
>  	rport->port_id = USB2PHY_PORT_OTG;
>  	rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
> @@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
>  					EXTCON_USB_HOST, &rport->event_nb);
>  		if (ret)

This needs braces, right?

	if (ret) {
>  			dev_err(rphy->dev, "register USB HOST notifier failed\n");
> +			goto out;

	}

With the braces the patch works as expected.

Thanks and best regards,
Michael

>  
>  		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
>  			/* 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);
> +			id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> +			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id);
>  		}
>  	}
>  

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

* Re: [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync
  2022-08-24  5:33 ` Michael Riesch
@ 2022-08-24 10:17   ` Peter Geis
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Geis @ 2022-08-24 10:17 UTC (permalink / raw)
  To: Michael Riesch
  Cc: Heiko Stuebner, Kishon Vijay Abraham I, Vinod Koul,
	Samuel Holland, Markus Reichl, open list:GENERIC PHY FRAMEWORK,
	arm-mail-list, open list:ARM/Rockchip SoC...,
	Linux Kernel Mailing List

On Wed, Aug 24, 2022 at 7:33 AM Michael Riesch
<michael.riesch@wolfvision.net> wrote:
>
> Hi Peter,
>
> On 8/23/22 16:47, 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.  It also
> > fails to account for a failure to register the extcon notifier. Fix this
> > by using our own variable and skipping otg sync in case of failure.
> >
> > 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 | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > index 0b1e9337ee8e..d579a22c61df 100644
> > --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > @@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
> >                                         struct rockchip_usb2phy_port *rport,
> >                                         struct device_node *child_np)
> >  {
> > -     int ret;
> > +     int ret, id;
> >
> >       rport->port_id = USB2PHY_PORT_OTG;
> >       rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
> > @@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
> >                                       EXTCON_USB_HOST, &rport->event_nb);
> >               if (ret)
>
> This needs braces, right?
>
>         if (ret) {
> >                       dev_err(rphy->dev, "register USB HOST notifier failed\n");
> > +                     goto out;
>
>         }
>
> With the braces the patch works as expected.

Yup, thanks for that. I hate working without access to my hardware.

>
> Thanks and best regards,
> Michael
>
> >
> >               if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
> >                       /* 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);
> > +                     id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
> > +                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id);
> >               }
> >       }
> >

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

end of thread, other threads:[~2022-08-24 10:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 14:47 [PATCH v2] phy: rockchip-inno-usb2: Return zero after otg sync Peter Geis
2022-08-23 18:48 ` Heiko Stübner
2022-08-24  5:33 ` Michael Riesch
2022-08-24 10:17   ` Peter Geis

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