* [PATCH v3 net-next 1/3] net: phy: stop PHY if needed when entering phy_disconnect
2019-01-17 19:06 [PATCH v3 net-next 0/3] net: phy: improve stopping PHY Heiner Kallweit
@ 2019-01-17 19:07 ` Heiner Kallweit
2019-01-17 19:08 ` [PATCH v3 net-next 2/3] net: phy: ensure phylib state machine is stopped after calling phy_stop Heiner Kallweit
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2019-01-17 19:07 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, David Miller; +Cc: netdev@vger.kernel.org
Stop PHY if needed when entering phy_disconnect. This allows drivers
that don't need a separate call to phy_stop() to omit this call.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b5f5cda4c..9e588f03e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -999,6 +999,9 @@ EXPORT_SYMBOL(phy_connect);
*/
void phy_disconnect(struct phy_device *phydev)
{
+ if (phy_is_started(phydev))
+ phy_stop(phydev);
+
if (phydev->irq > 0)
phy_stop_interrupts(phydev);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 net-next 2/3] net: phy: ensure phylib state machine is stopped after calling phy_stop
2019-01-17 19:06 [PATCH v3 net-next 0/3] net: phy: improve stopping PHY Heiner Kallweit
2019-01-17 19:07 ` [PATCH v3 net-next 1/3] net: phy: stop PHY if needed when entering phy_disconnect Heiner Kallweit
@ 2019-01-17 19:08 ` Heiner Kallweit
2019-01-17 19:09 ` [PATCH v3 net-next 3/3] net: phy: remove phy_stop_interrupts Heiner Kallweit
2019-01-18 22:12 ` [PATCH v3 net-next 0/3] net: phy: improve stopping PHY David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2019-01-17 19:08 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, David Miller; +Cc: netdev@vger.kernel.org
The call to the phylib state machine in phy_stop() just ensures that
the state machine isn't re-triggered, but a state machine call may
be scheduled already. So lets's call phy_stop_machine().
This also allows to get rid of the call to phy_stop_machine() in
phy_disconnect().
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/phy/phy.c | 1 +
drivers/net/phy/phy_device.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2ffe08537..96e9ec252 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -853,6 +853,7 @@ void phy_stop(struct phy_device *phydev)
mutex_unlock(&phydev->lock);
phy_state_machine(&phydev->state_queue.work);
+ phy_stop_machine(phydev);
/* Cannot call flush_scheduled_work() here as desired because
* of rtnl_lock(), but PHY_HALTED shall guarantee irq handler
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9e588f03e..839e3247f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1005,8 +1005,6 @@ void phy_disconnect(struct phy_device *phydev)
if (phydev->irq > 0)
phy_stop_interrupts(phydev);
- phy_stop_machine(phydev);
-
phydev->adjust_link = NULL;
phy_detach(phydev);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 net-next 3/3] net: phy: remove phy_stop_interrupts
2019-01-17 19:06 [PATCH v3 net-next 0/3] net: phy: improve stopping PHY Heiner Kallweit
2019-01-17 19:07 ` [PATCH v3 net-next 1/3] net: phy: stop PHY if needed when entering phy_disconnect Heiner Kallweit
2019-01-17 19:08 ` [PATCH v3 net-next 2/3] net: phy: ensure phylib state machine is stopped after calling phy_stop Heiner Kallweit
@ 2019-01-17 19:09 ` Heiner Kallweit
2019-01-18 22:12 ` [PATCH v3 net-next 0/3] net: phy: improve stopping PHY David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2019-01-17 19:09 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, David Miller; +Cc: netdev@vger.kernel.org
Interrupts have been disabled in phy_stop() already. So we can remove
phy_stop_interrupts() and free the interrupt in phy_disconnect()
directly.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/phy/phy.c | 17 -----------------
drivers/net/phy/phy_device.c | 4 ++--
include/linux/phy.h | 1 -
3 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 96e9ec252..745a705a5 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -813,23 +813,6 @@ int phy_start_interrupts(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_start_interrupts);
-/**
- * phy_stop_interrupts - disable interrupts from a PHY device
- * @phydev: target phy_device struct
- */
-int phy_stop_interrupts(struct phy_device *phydev)
-{
- int err = phy_disable_interrupts(phydev);
-
- if (err)
- phy_error(phydev);
-
- free_irq(phydev->irq, phydev);
-
- return err;
-}
-EXPORT_SYMBOL(phy_stop_interrupts);
-
/**
* phy_stop - Bring down the PHY link, and stop checking the status
* @phydev: target phy_device struct
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 839e3247f..4f61ebf84 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1002,8 +1002,8 @@ void phy_disconnect(struct phy_device *phydev)
if (phy_is_started(phydev))
phy_stop(phydev);
- if (phydev->irq > 0)
- phy_stop_interrupts(phydev);
+ if (phy_interrupt_is_valid(phydev))
+ free_irq(phydev->irq, phydev);
phydev->adjust_link = NULL;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 00b0533de..1fa7c367b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -951,7 +951,6 @@ int phy_aneg_done(struct phy_device *phydev);
int phy_speed_down(struct phy_device *phydev, bool sync);
int phy_speed_up(struct phy_device *phydev);
-int phy_stop_interrupts(struct phy_device *phydev);
int phy_restart_aneg(struct phy_device *phydev);
int phy_reset_after_clk_enable(struct phy_device *phydev);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 net-next 0/3] net: phy: improve stopping PHY
2019-01-17 19:06 [PATCH v3 net-next 0/3] net: phy: improve stopping PHY Heiner Kallweit
` (2 preceding siblings ...)
2019-01-17 19:09 ` [PATCH v3 net-next 3/3] net: phy: remove phy_stop_interrupts Heiner Kallweit
@ 2019-01-18 22:12 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-01-18 22:12 UTC (permalink / raw)
To: hkallweit1; +Cc: f.fainelli, andrew, netdev
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Thu, 17 Jan 2019 20:06:46 +0100
> This patchset improves and simplifies stopping the PHY.
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread