[PATCH net-next RESEND 2/5] net: stmmac: dwmac-sun8i: Remove unnecessary PHY power check

50 views
Skip to first unread message

Samuel Holland

unread,
Feb 8, 2021, 1:29:06 AM2/8/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
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 <we...@csie.org>
Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 8e505019adf8..3c3d0b99d3e8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1018,10 +1018,8 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
{
struct sunxi_priv_data *gmac = priv;

- if (gmac->variant->soc_has_internal_phy) {
- if (gmac->internal_phy_powered)
- sun8i_dwmac_unpower_internal_phy(gmac);
- }
+ if (gmac->variant->soc_has_internal_phy)
+ sun8i_dwmac_unpower_internal_phy(gmac);

clk_disable_unprepare(gmac->tx_clk);

--
2.26.2

Samuel Holland

unread,
Feb 8, 2021, 1:29:06 AM2/8/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
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

Samuel Holland

unread,
Feb 8, 2021, 1:29:06 AM2/8/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.

Reviewed-by: Chen-Yu Tsai <we...@csie.org>
Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 3c3d0b99d3e8..0e8d88417251 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -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
* it at deasserted state, and thus it may fail to reset EMAC.
*/
- 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);
return ret;
}
--
2.26.2

Samuel Holland

unread,
Feb 8, 2021, 10:24:33 PM2/8/21
to Alexander Duyck, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, Netdev, linux-ar...@lists.infradead.org, LKML, linux...@googlegroups.com
On 2/8/21 10:29 AM, Alexander Duyck wrote:
> 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

Samuel Holland

unread,
Feb 16, 2021, 11:20:12 PM2/16/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.

Reviewed-by: Chen-Yu Tsai <we...@csie.org>
Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 3c3d0b99d3e8c..b61f442ed3033 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -805,12 +805,12 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)

/* Make sure the EPHY is properly reseted, as U-Boot may leave
* it at deasserted state, and thus it may fail to reset EMAC.
+ *
+ * This assumes the driver has exclusive access to the EPHY reset.
*/
- 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);
return ret;
}
--
2.26.2

Samuel Holland

unread,
Feb 16, 2021, 11:20:12 PM2/16/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
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 <we...@csie.org>
Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 8e505019adf85..3c3d0b99d3e8c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

Samuel Holland

unread,
Feb 16, 2021, 11:20:14 PM2/16/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
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.

Changes v1 to v2:
- Note the assumption of exclusive reset controller access in patch 3

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 | 33 ++++++++++++-------
1 file changed, 21 insertions(+), 12 deletions(-)

--
2.26.2

Reply all
Reply to author
Forward
0 new messages