All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM
@ 2017-03-13  6:24 Yoshihiro Shimoda
  2017-03-13  9:04 ` Sergei Shtylyov
  0 siblings, 1 reply; 4+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-13  6:24 UTC (permalink / raw)
  To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda

This patch fixes an issue that this driver doesn't take care of the runtime
PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev),
but it misunderstood the dev_phy_create()'s specification.
This driver should call the own pm_runtime_pm() before dev_phy_create().

Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/phy-rcar-gen3-usb2.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
index afb4d04..23c4e86 100644
--- a/drivers/phy/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/phy-rcar-gen3-usb2.c
@@ -20,6 +20,7 @@
 #include <linux/of_address.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/workqueue.h>
 
@@ -395,7 +396,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	struct rcar_gen3_chan *channel;
 	struct phy_provider *provider;
 	struct resource *res;
-	int irq;
+	int irq, ret = 0;
 
 	if (!dev->of_node) {
 		dev_err(dev, "This driver needs device tree\n");
@@ -434,17 +435,24 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 		}
 	}
 
-	/* devm_phy_create() will call pm_runtime_enable(dev); */
+	/*
+	 * devm_phy_create() will call pm_runtime_enable(&phy->dev);
+	 * And then, phy-core will manage runtime pm for this device.
+	 */
+	pm_runtime_enable(dev);
 	channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops);
 	if (IS_ERR(channel->phy)) {
 		dev_err(dev, "Failed to create USB2 PHY\n");
-		return PTR_ERR(channel->phy);
+		ret = PTR_ERR(channel->phy);
+		goto error;
 	}
 
 	channel->vbus = devm_regulator_get_optional(dev, "vbus");
 	if (IS_ERR(channel->vbus)) {
-		if (PTR_ERR(channel->vbus) == -EPROBE_DEFER)
-			return PTR_ERR(channel->vbus);
+		if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) {
+			ret = PTR_ERR(channel->vbus);
+			goto error;
+		}
 		channel->vbus = NULL;
 	}
 
@@ -454,15 +462,22 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
 	if (IS_ERR(provider)) {
 		dev_err(dev, "Failed to register PHY provider\n");
+		ret = PTR_ERR(provider);
+		goto error;
 	} else if (channel->has_otg) {
 		int ret;
 
 		ret = device_create_file(dev, &dev_attr_role);
 		if (ret < 0)
-			return ret;
+			goto error;
 	}
 
 	return PTR_ERR_OR_ZERO(provider);
+
+error:
+	pm_runtime_disable(dev);
+
+	return ret;
 }
 
 static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
@@ -472,6 +487,8 @@ static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
 	if (channel->has_otg)
 		device_remove_file(&pdev->dev, &dev_attr_role);
 
+	pm_runtime_disable(&pdev->dev);
+
 	return 0;
 };
 
-- 
1.9.1

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

* Re: [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM
  2017-03-13  6:24 [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM Yoshihiro Shimoda
@ 2017-03-13  9:04 ` Sergei Shtylyov
  2017-03-13  9:38     ` Yoshihiro Shimoda
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2017-03-13  9:04 UTC (permalink / raw)
  To: Yoshihiro Shimoda, kishon; +Cc: linux-kernel, linux-renesas-soc

Hello!

On 3/13/2017 9:24 AM, Yoshihiro Shimoda wrote:

> This patch fixes an issue that this driver doesn't take care of the runtime
> PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev),
> but it misunderstood the dev_phy_create()'s specification.
> This driver should call the own pm_runtime_pm() before dev_phy_create().

    Its own?

> Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/phy/phy-rcar-gen3-usb2.c | 29 +++++++++++++++++++++++------
>  1 file changed, 23 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
> index afb4d04..23c4e86 100644
> --- a/drivers/phy/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/phy-rcar-gen3-usb2.c
[...]
> @@ -454,15 +462,22 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
>  	if (IS_ERR(provider)) {
>  		dev_err(dev, "Failed to register PHY provider\n");
> +		ret = PTR_ERR(provider);
> +		goto error;
>  	} else if (channel->has_otg) {
>  		int ret;
>
>  		ret = device_create_file(dev, &dev_attr_role);
>  		if (ret < 0)
> -			return ret;
> +			goto error;
>  	}
>
>  	return PTR_ERR_OR_ZERO(provider);

    Here 'provider' can no longer contain error -- *return* 0 seems to fit better.

> +
> +error:
> +	pm_runtime_disable(dev);
> +
> +	return ret;
>  }
>
>  static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
[...]

MBR, Sergei

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

* RE: [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM
  2017-03-13  9:04 ` Sergei Shtylyov
@ 2017-03-13  9:38     ` Yoshihiro Shimoda
  0 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-13  9:38 UTC (permalink / raw)
  To: Sergei Shtylyov, kishon; +Cc: linux-kernel, linux-renesas-soc

Hello!

> -----Original Message-----
> From: Sergei Shtylyov
> Sent: Monday, March 13, 2017 6:04 PM
> 
> Hello!
> 
> On 3/13/2017 9:24 AM, Yoshihiro Shimoda wrote:
> 
> > This patch fixes an issue that this driver doesn't take care of the runtime
> > PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev),
> > but it misunderstood the dev_phy_create()'s specification.
> > This driver should call the own pm_runtime_pm() before dev_phy_create().
> 
>     Its own?

Yes. So, I will revise it.

> > Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver")
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/phy/phy-rcar-gen3-usb2.c | 29 +++++++++++++++++++++++------
> >  1 file changed, 23 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
> > index afb4d04..23c4e86 100644
> > --- a/drivers/phy/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/phy-rcar-gen3-usb2.c
> [...]
> > @@ -454,15 +462,22 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> >  	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> >  	if (IS_ERR(provider)) {
> >  		dev_err(dev, "Failed to register PHY provider\n");
> > +		ret = PTR_ERR(provider);
> > +		goto error;
> >  	} else if (channel->has_otg) {
> >  		int ret;
> >
> >  		ret = device_create_file(dev, &dev_attr_role);
> >  		if (ret < 0)
> > -			return ret;
> > +			goto error;
> >  	}
> >
> >  	return PTR_ERR_OR_ZERO(provider);
> 
>     Here 'provider' can no longer contain error -- *return* 0 seems to fit better.

Oops, I will fix it.

Best regards,
Yoshihiro Shimoda

> > +
> > +error:
> > +	pm_runtime_disable(dev);
> > +
> > +	return ret;
> >  }
> >
> >  static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
> [...]
> 
> MBR, Sergei

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

* RE: [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM
@ 2017-03-13  9:38     ` Yoshihiro Shimoda
  0 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2017-03-13  9:38 UTC (permalink / raw)
  To: Sergei Shtylyov, kishon; +Cc: linux-kernel, linux-renesas-soc

Hello!

> -----Original Message-----
> From: Sergei Shtylyov
> Sent: Monday, March 13, 2017 6:04 PM
> 
> Hello!
> 
> On 3/13/2017 9:24 AM, Yoshihiro Shimoda wrote:
> 
> > This patch fixes an issue that this driver doesn't take care of the runtime
> > PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev),
> > but it misunderstood the dev_phy_create()'s specification.
> > This driver should call the own pm_runtime_pm() before dev_phy_create().
> 
>     Its own?

Yes. So, I will revise it.

> > Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver")
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/phy/phy-rcar-gen3-usb2.c | 29 +++++++++++++++++++++++------
> >  1 file changed, 23 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
> > index afb4d04..23c4e86 100644
> > --- a/drivers/phy/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/phy-rcar-gen3-usb2.c
> [...]
> > @@ -454,15 +462,22 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> >  	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> >  	if (IS_ERR(provider)) {
> >  		dev_err(dev, "Failed to register PHY provider\n");
> > +		ret = PTR_ERR(provider);
> > +		goto error;
> >  	} else if (channel->has_otg) {
> >  		int ret;
> >
> >  		ret = device_create_file(dev, &dev_attr_role);
> >  		if (ret < 0)
> > -			return ret;
> > +			goto error;
> >  	}
> >
> >  	return PTR_ERR_OR_ZERO(provider);
> 
>     Here 'provider' can no longer contain error -- *return* 0 seems to fit better.

Oops, I will fix it.

Best regards,
Yoshihiro Shimoda

> > +
> > +error:
> > +	pm_runtime_disable(dev);
> > +
> > +	return ret;
> >  }
> >
> >  static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
> [...]
> 
> MBR, Sergei


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

end of thread, other threads:[~2017-03-13  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13  6:24 [PATCH] phy: rcar-gen3-usb2: fix implementation for runtime PM Yoshihiro Shimoda
2017-03-13  9:04 ` Sergei Shtylyov
2017-03-13  9:38   ` Yoshihiro Shimoda
2017-03-13  9:38     ` Yoshihiro Shimoda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.