net: axienet: allow setups without MDIO
PATCH v2 1/1 net: axienet: allow setups without MDIO
In setups with fixed-link settings there is no mdio node in DTS. axienet_probe() already handles that gracefully but lp->mii_bus is then NULL.
Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional.
---
v2:
* Also fix axienet_dma_err_handler, as pointed out by Andrew Lunn
drivers/net/ethernet/xilinx/xilinx_axienet.h | 12 ++++++++++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +12 -0
@@ -504,6 +504,18 @@ static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)return axienet_ior (lp,XAE_MDIO_MCR_OFFSET ); } +static inline void axienet_lock_mii (struct axienet_local *lp) +{ +if (lp->mii_bus) +mutex_lock (&lp->mii_bus->mdio_lock); +} + +static inline void axienet_unlock_mii (struct axienet_local *lp) +{ +if (lp->mii_bus) +mutex_unlock (&lp->mii_bus->mdio_lock); +} +/** * axienet_iow - Memory mapped Axi Ethernet register write * @lp: Pointer to axienet local structure
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6 -6
@@ -1053,9 +1053,9 @@ static int axienet_open(struct net_device *ndev)* including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp); ret =axienet_device_reset (ndev); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp); ret =phylink_of_phy_connect (lp->phylink, lp->dev->of_node,0 );if (ret) {
@@ -1148,9 +1148,9 @@ static int axienet_stop(struct net_device *ndev) }/* Do a reset to ensure DMA is really stopped */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp);__axienet_device_reset (lp); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp);cancel_work_sync (&lp->dma_err_task);
@@ -1709,9 +1709,9 @@ static void axienet_dma_err_handler(struct work_struct *work)* including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp);__axienet_device_reset (lp); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp);for (i =0 ; i < lp->tx_bd_num; i++) { cur_p = &lp->tx_bd_v[i];
Signature · 1 line
2.30.2
Quoted 8 lines
-----Original Message-----
From: Daniel Mack <[email protected]>
Sent: Wednesday, March 24, 2021 6:36 PM
To: Radhey Shyam Pandey <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Daniel Mack <[email protected]>
Subject: [PATCH v2] net: axienet: allow setups without MDIO
Quoted 8 lines
In setups with fixed-link settings there is no mdio node in DTS.
axienet_probe()already handles that gracefully butlp->mii_busis then NULL.Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional.
Signed-off-by Daniel Mack <[email protected]>
Thanks!
Quoted 74 lines
---
v2:
* Also fixaxienet_dma_err_handler, as pointed out by Andrew Lunndrivers/net/ethernet/xilinx/xilinx_axienet.h | 12 ++++++++++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +10
-0@@ -504,6 +504,18 @@ static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)return axienet_ior (lp,XAE_MDIO_MCR_OFFSET ); } +static inline void axienet_lock_mii (struct axienet_local *lp) { +if (lp->mii_bus) +mutex_lock (&lp->mii_bus->mdio_lock); +} + +static inline void axienet_unlock_mii (struct axienet_local *lp) { +if (lp->mii_bus) +mutex_unlock (&lp->mii_bus->mdio_lock); +} +/** * axienet_iow - Memory mapped Axi Ethernet register write * @lp: Pointer to axienet local structure drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-6@@ -1053,9 +1053,9 @@ static int axienet_open(struct net_device *ndev)* including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp); ret =axienet_device_reset (ndev); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp); ret =phylink_of_phy_connect (lp->phylink, lp->dev->of_node,0 );if (ret) {@@ -1148,9 +1148,9 @@ static int axienet_stop(struct net_device *ndev) }/* Do a reset to ensure DMA is really stopped */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp);__axienet_device_reset (lp); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp);cancel_work_sync (&lp->dma_err_task);@@ -1709,9 +1709,9 @@ static void axienet_dma_err_handler(structwork_struct *work) * including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ -mutex_lock (&lp->mii_bus->mdio_lock); +axienet_lock_mii (lp);__axienet_device_reset (lp); -mutex_unlock (&lp->mii_bus->mdio_lock); +axienet_unlock_mii (lp);for (i =0 ; i < lp->tx_bd_num; i++) {
cur_p= &lp->tx_bd_v[i];
--
2.30.2
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Wed, 24 Mar 2021 14:05:36 +0100 you wrote:
In setups with fixed-link settings there is no mdio node in DTS.
axienet_probe()already handles that gracefully butlp->mii_busis then NULL.Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional.
[...]
Here is the summary with links:
- [v2] net: axienet: allow setups without MDIO
https://git.kernel.org/netdev/net/c/de9c7854e6e1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html