All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Gregory Clement <gregory.clement@bootlin.com>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: devicetree@vger.kernel.org,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	linux-usb@vger.kernel.org,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 03/10] usb: ehci-orion: avoid double PHY initialization
Date: Mon, 21 Jan 2019 12:23:29 +0100	[thread overview]
Message-ID: <20190121112336.23489-4-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20190121112336.23489-1-miquel.raynal@bootlin.com>

No need to initialize the PHY from the driver's probe. It is done by
the core automatically and doing it twice would increment the
phy->powercount counter to 2 instead of 1. During later suspend
operation, the counter will be decremented to one, no phy->power_off()
will occur and worse than that, the following phy->power_on() at
resume time will also be skipped, failing the whole S2RAM operation.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/usb/host/ehci-orion.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 1ad72647a069..3109f082949e 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -257,15 +257,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->phy)) {
 		err = PTR_ERR(priv->phy);
 		if (err != -ENOSYS)
-			goto err_phy_get;
-	} else {
-		err = phy_init(priv->phy);
-		if (err)
-			goto err_phy_init;
-
-		err = phy_power_on(priv->phy);
-		if (err)
-			goto err_phy_power_on;
+			goto err_dis_clk;
 	}
 
 	/*
@@ -297,19 +289,12 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 
 	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (err)
-		goto err_add_hcd;
+		goto err_dis_clk;
 
 	device_wakeup_enable(hcd->self.controller);
 	return 0;
 
-err_add_hcd:
-	if (!IS_ERR(priv->phy))
-		phy_power_off(priv->phy);
-err_phy_power_on:
-	if (!IS_ERR(priv->phy))
-		phy_exit(priv->phy);
-err_phy_init:
-err_phy_get:
+err_dis_clk:
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 	usb_put_hcd(hcd);
@@ -327,11 +312,6 @@ static int ehci_orion_drv_remove(struct platform_device *pdev)
 
 	usb_remove_hcd(hcd);
 
-	if (!IS_ERR(priv->phy)) {
-		phy_power_off(priv->phy);
-		phy_exit(priv->phy);
-	}
-
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 
-- 
2.19.1

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Gregory Clement <gregory.clement@bootlin.com>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-usb@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [v3,03/10] usb: ehci-orion: avoid double PHY initialization
Date: Mon, 21 Jan 2019 12:23:29 +0100	[thread overview]
Message-ID: <20190121112336.23489-4-miquel.raynal@bootlin.com> (raw)

No need to initialize the PHY from the driver's probe. It is done by
the core automatically and doing it twice would increment the
phy->powercount counter to 2 instead of 1. During later suspend
operation, the counter will be decremented to one, no phy->power_off()
will occur and worse than that, the following phy->power_on() at
resume time will also be skipped, failing the whole S2RAM operation.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/usb/host/ehci-orion.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 1ad72647a069..3109f082949e 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -257,15 +257,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->phy)) {
 		err = PTR_ERR(priv->phy);
 		if (err != -ENOSYS)
-			goto err_phy_get;
-	} else {
-		err = phy_init(priv->phy);
-		if (err)
-			goto err_phy_init;
-
-		err = phy_power_on(priv->phy);
-		if (err)
-			goto err_phy_power_on;
+			goto err_dis_clk;
 	}
 
 	/*
@@ -297,19 +289,12 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 
 	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (err)
-		goto err_add_hcd;
+		goto err_dis_clk;
 
 	device_wakeup_enable(hcd->self.controller);
 	return 0;
 
-err_add_hcd:
-	if (!IS_ERR(priv->phy))
-		phy_power_off(priv->phy);
-err_phy_power_on:
-	if (!IS_ERR(priv->phy))
-		phy_exit(priv->phy);
-err_phy_init:
-err_phy_get:
+err_dis_clk:
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 	usb_put_hcd(hcd);
@@ -327,11 +312,6 @@ static int ehci_orion_drv_remove(struct platform_device *pdev)
 
 	usb_remove_hcd(hcd);
 
-	if (!IS_ERR(priv->phy)) {
-		phy_power_off(priv->phy);
-		phy_exit(priv->phy);
-	}
-
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Gregory Clement <gregory.clement@bootlin.com>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: devicetree@vger.kernel.org,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	linux-usb@vger.kernel.org,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 03/10] usb: ehci-orion: avoid double PHY initialization
Date: Mon, 21 Jan 2019 12:23:29 +0100	[thread overview]
Message-ID: <20190121112336.23489-4-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20190121112336.23489-1-miquel.raynal@bootlin.com>

No need to initialize the PHY from the driver's probe. It is done by
the core automatically and doing it twice would increment the
phy->powercount counter to 2 instead of 1. During later suspend
operation, the counter will be decremented to one, no phy->power_off()
will occur and worse than that, the following phy->power_on() at
resume time will also be skipped, failing the whole S2RAM operation.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/usb/host/ehci-orion.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 1ad72647a069..3109f082949e 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -257,15 +257,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->phy)) {
 		err = PTR_ERR(priv->phy);
 		if (err != -ENOSYS)
-			goto err_phy_get;
-	} else {
-		err = phy_init(priv->phy);
-		if (err)
-			goto err_phy_init;
-
-		err = phy_power_on(priv->phy);
-		if (err)
-			goto err_phy_power_on;
+			goto err_dis_clk;
 	}
 
 	/*
@@ -297,19 +289,12 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 
 	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (err)
-		goto err_add_hcd;
+		goto err_dis_clk;
 
 	device_wakeup_enable(hcd->self.controller);
 	return 0;
 
-err_add_hcd:
-	if (!IS_ERR(priv->phy))
-		phy_power_off(priv->phy);
-err_phy_power_on:
-	if (!IS_ERR(priv->phy))
-		phy_exit(priv->phy);
-err_phy_init:
-err_phy_get:
+err_dis_clk:
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 	usb_put_hcd(hcd);
@@ -327,11 +312,6 @@ static int ehci_orion_drv_remove(struct platform_device *pdev)
 
 	usb_remove_hcd(hcd);
 
-	if (!IS_ERR(priv->phy)) {
-		phy_power_off(priv->phy);
-		phy_exit(priv->phy);
-	}
-
 	if (!IS_ERR(priv->clk))
 		clk_disable_unprepare(priv->clk);
 
-- 
2.19.1


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

  parent reply	other threads:[~2019-01-21 11:23 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 11:23 [PATCH v3 00/10] A3700 USB S2RAM support Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 01/10] usb: core: comply to PHY framework Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,01/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 02/10] usb: host: xhci: mvebu: add reset on resume quirk Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,02/10] " Miquel Raynal
2019-01-21 11:23 ` Miquel Raynal [this message]
2019-01-21 11:23   ` [PATCH v3 03/10] usb: ehci-orion: avoid double PHY initialization Miquel Raynal
2019-01-21 11:23   ` [v3,03/10] " Miquel Raynal
2019-01-23 20:01   ` [PATCH v3 03/10] " Alan Stern
2019-01-23 20:01     ` Alan Stern
2019-01-23 20:01     ` [v3,03/10] " Alan Stern
2019-01-21 11:23 ` [PATCH v3 04/10] usb: ehci-orion: add S2RAM support Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,04/10] " Miquel Raynal
2019-01-23 19:58   ` [PATCH v3 04/10] " Alan Stern
2019-01-23 19:58     ` Alan Stern
2019-01-23 19:58     ` [v3,04/10] " Alan Stern
2019-01-25 10:35     ` [PATCH v3 04/10] " Miquel Raynal
2019-01-25 10:35       ` [v3,04/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 05/10] phy: add A3700 UTMI PHY driver Miquel Raynal
2019-01-21 11:23   ` [v3,05/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 06/10] dt-bindings: phy: mvebu-utmi: add UTMI PHY bindings Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,06/10] " Miquel Raynal
2019-01-21 15:44   ` [PATCH v3 06/10] " Rob Herring
2019-01-21 15:44     ` Rob Herring
2019-01-21 15:44     ` [v3,06/10] " Rob Herring
2019-01-21 15:47     ` [PATCH v3 06/10] " Gregory CLEMENT
2019-01-21 15:47       ` Gregory CLEMENT
2019-01-21 15:47       ` [v3,06/10] " Gregory CLEMENT
2019-01-22 16:08       ` [PATCH v3 06/10] " Rob Herring
2019-01-22 16:08         ` Rob Herring
2019-01-22 16:08         ` [v3,06/10] " Rob Herring
2019-01-22 16:13         ` [PATCH v3 06/10] " Miquel Raynal
2019-01-22 16:13           ` [v3,06/10] " Miquel Raynal
2019-01-22 17:38   ` [PATCH v3 06/10] " Thomas Petazzoni
2019-01-22 17:38     ` Thomas Petazzoni
2019-01-22 17:38     ` [v3,06/10] " Thomas Petazzoni
2019-01-22 19:16     ` [PATCH v3 06/10] " Miquel Raynal
2019-01-22 19:16       ` [v3,06/10] " Miquel Raynal
2019-01-23 13:51       ` [PATCH v3 06/10] " Thomas Petazzoni
2019-01-23 13:51         ` Thomas Petazzoni
2019-01-23 13:51         ` [v3,06/10] " Thomas Petazzoni
2019-01-21 11:23 ` [PATCH v3 07/10] MAINTAINERS: phy: fill Armada 3700 PHY drivers entry Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,07/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 08/10] ARM64: dts: marvell: armada-37xx: fix USB2 memory region Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,08/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 09/10] ARM64: dts: marvell: armada-37xx: declare USB2 UTMI PHYs Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,09/10] " Miquel Raynal
2019-01-21 11:23 ` [PATCH v3 10/10] ARM64: dts: marvell: armada-37xx: link USB hosts with their PHYs Miquel Raynal
2019-01-21 11:23   ` Miquel Raynal
2019-01-21 11:23   ` [v3,10/10] " Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190121112336.23489-4-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@bootlin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=jason@lakedaemon.net \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathias.nyman@intel.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=nadavh@marvell.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.