From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:32:57
These patches clean up some things I noticed while fixing suspend/resume
behavior. The first four are minor code improvements. The last one adds
a shutdown hook to minimize power consumption on boards without a PMIC.
Now that the fixes series is merged, I'm resending this series rebased
on top of net-next and with Chen-Yu's Reviewed-by tags.
Samuel Holland (5):
net: stmmac: dwmac-sun8i: Return void from PHY unpower
net: stmmac: dwmac-sun8i: Remove unnecessary PHY power check
net: stmmac: dwmac-sun8i: Use reset_control_reset
net: stmmac: dwmac-sun8i: Minor probe function cleanup
net: stmmac: dwmac-sun8i: Add a shutdown callback
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 31 ++++++++++++-------
1 file changed, 19 insertions(+), 12 deletions(-)
--
2.26.2
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:30:10
In commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"), error
pointers to optional clocks were replaced by NULL to simplify the resume
callback implementation. However, that commit missed that the IS_ERR
check in mv64xxx_of_config should be replaced with a NULL check. As a
result, the check always passes, even for an invalid device tree.
Fixes: e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support")
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/i2c/busses/i2c-mv64xxx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:30:43
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
@@ -806,11 +806,9 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)/* Make sure the EPHY is properly reseted, as U-Boot may leave*itatdeassertedstate,andthusitmayfailtoresetEMAC.*/-reset_control_assert(gmac->rst_ephy);--ret=reset_control_deassert(gmac->rst_ephy);+ret=reset_control_reset(gmac->rst_ephy);if(ret){-dev_err(priv->device,"Cannot deassert internal phy\n");+dev_err(priv->device,"Cannot reset internal PHY\n");clk_disable_unprepare(gmac->ephy_clk);returnret;}
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:31:23
This is a deinitialization function that always returned zero, and that
return value was always ignored. Have it return void instead.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:32:12
sun8i_dwmac_unpower_internal_phy already checks if the PHY is powered,
so there is no need to do it again here.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:33:20
Adjust the spacing and use an explicit "return 0" in the success path
to make the function easier to parse.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -1227,6 +1227,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)ndev=dev_get_drvdata(&pdev->dev);priv=netdev_priv(ndev);+/* The mux must be registered after parent MDIO*soafterstmmac_dvr_probe()*/
@@ -1245,7 +1246,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)gotodwmac_remove;}-returnret;+return0;+dwmac_mux:reset_control_put(gmac->rst_ephy);clk_put(gmac->ephy_clk);
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:34:03
The Ethernet MAC and PHY are usually major consumers of power on boards
which may not be able to fully power off (those with no PMIC). Powering
down the MAC and internal PHY saves power while these boards are "off".
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 10 ++++++++++
1 file changed, 10 insertions(+)
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-08 06:35:25
On 2/8/21 12:28 AM, Samuel Holland wrote:
In commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"), error
pointers to optional clocks were replaced by NULL to simplify the resume
callback implementation. However, that commit missed that the IS_ERR
check in mv64xxx_of_config should be replaced with a NULL check. As a
result, the check always passes, even for an invalid device tree.
Sorry, please ignore this unrelated patch. I accidentally copied it to
the wrong directory before sending this series.
Samuel
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-02-08 13:24:55
On Mon, Feb 08, 2021 at 12:31:34AM -0600, Samuel Holland wrote:
On 2/8/21 12:28 AM, Samuel Holland wrote:
quoted
In commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"), error
pointers to optional clocks were replaced by NULL to simplify the resume
callback implementation. However, that commit missed that the IS_ERR
check in mv64xxx_of_config should be replaced with a NULL check. As a
result, the check always passes, even for an invalid device tree.
Sorry, please ignore this unrelated patch. I accidentally copied it to
the wrong directory before sending this series.
Hi Samuel
This patch looks correct. But i don't see it in i2c/for-next, where as
e5c02cf54154 is. I just want to make sure it does not get lost...
Andrew
From: Alexander Duyck <hidden> Date: 2021-02-08 18:37:56
On Sun, Feb 7, 2021 at 10:32 PM Samuel Holland [off-list ref] wrote:
quoted hunk
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
@@ -806,11 +806,9 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)/* Make sure the EPHY is properly reseted, as U-Boot may leave*itatdeassertedstate,andthusitmayfailtoresetEMAC.*/-reset_control_assert(gmac->rst_ephy);--ret=reset_control_deassert(gmac->rst_ephy);+ret=reset_control_reset(gmac->rst_ephy);if(ret){-dev_err(priv->device,"Cannot deassert internal phy\n");+dev_err(priv->device,"Cannot reset internal PHY\n");clk_disable_unprepare(gmac->ephy_clk);returnret;}
I'm assuming you have exclusive access to the phy and this isn't a
shared line? Just wanting to confirm since the function call has the
following comment in the header for the documentation.
* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.
*
If that is the case it might not hurt to add some documentation to
your call to reset_control_reset here explaining that it is safe to do
so since you have exclusive access.
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-02-08 21:43:15
On Mon, 8 Feb 2021 00:31:34 -0600 Samuel Holland wrote:
On 2/8/21 12:28 AM, Samuel Holland wrote:
quoted
In commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"), error
pointers to optional clocks were replaced by NULL to simplify the resume
callback implementation. However, that commit missed that the IS_ERR
check in mv64xxx_of_config should be replaced with a NULL check. As a
result, the check always passes, even for an invalid device tree.
Sorry, please ignore this unrelated patch. I accidentally copied it to
the wrong directory before sending this series.
Unfortunately patchwork decided to take this patch in instead of the
real 1/5 patch. Please make a clean repost even if there are no review
comments to address.
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-09 03:13:04
On 2/8/21 7:20 AM, Andrew Lunn wrote:
On Mon, Feb 08, 2021 at 12:31:34AM -0600, Samuel Holland wrote:
quoted
On 2/8/21 12:28 AM, Samuel Holland wrote:
quoted
In commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"), error
pointers to optional clocks were replaced by NULL to simplify the resume
callback implementation. However, that commit missed that the IS_ERR
check in mv64xxx_of_config should be replaced with a NULL check. As a
result, the check always passes, even for an invalid device tree.
Sorry, please ignore this unrelated patch. I accidentally copied it to
the wrong directory before sending this series.
Hi Samuel
This patch looks correct. But i don't see it in i2c/for-next, where as
e5c02cf54154 is. I just want to make sure it does not get lost...
From: Samuel Holland <samuel@sholland.org> Date: 2021-02-09 03:34:19
On 2/8/21 10:29 AM, Alexander Duyck wrote:
On Sun, Feb 7, 2021 at 10:32 PM Samuel Holland [off-list ref] wrote:
quoted
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.
Reviewed-by: Chen-Yu Tsai <redacted>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
@@ -806,11 +806,9 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)/* Make sure the EPHY is properly reseted, as U-Boot may leave*itatdeassertedstate,andthusitmayfailtoresetEMAC.*/-reset_control_assert(gmac->rst_ephy);--ret=reset_control_deassert(gmac->rst_ephy);+ret=reset_control_reset(gmac->rst_ephy);if(ret){-dev_err(priv->device,"Cannot deassert internal phy\n");+dev_err(priv->device,"Cannot reset internal PHY\n");clk_disable_unprepare(gmac->ephy_clk);returnret;}
I'm assuming you have exclusive access to the phy and this isn't a
shared line? Just wanting to confirm since the function call has the
following comment in the header for the documentation.
Yes, this driver has exclusive access:
gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL);
And this is a reset line for the Ethernet PHY inside the SoC, that as
far as I can tell is not shared with anything else.
* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.
*
If that is the case it might not hurt to add some documentation to
your call to reset_control_reset here explaining that it is safe to do
so since you have exclusive access.
I can expand the comment above this line for v2.
Cheers,
Samuel