* [PATCH] net: axienet: allow setups without MDIO
@ 2021-03-24 9:48 Daniel Mack
2021-03-24 12:38 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Mack @ 2021-03-24 9:48 UTC (permalink / raw)
To: radhey.shyam.pandey; +Cc: davem, kuba, netdev, Daniel Mack
In setups with fixed-link settings on the hardware bus 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.
Signed-off-by: Daniel Mack <daniel@zonque.org>
---
drivers/net/ethernet/xilinx/xilinx_axienet.h | 12 ++++++++++++
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 8 ++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 1e966a39967e5..aca7f82f6791b 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -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
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 3a8775e0ca552..ce33e0a468912 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -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);
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: axienet: allow setups without MDIO
2021-03-24 9:48 [PATCH] net: axienet: allow setups without MDIO Daniel Mack
@ 2021-03-24 12:38 ` Andrew Lunn
2021-03-24 13:03 ` Daniel Mack
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2021-03-24 12:38 UTC (permalink / raw)
To: Daniel Mack; +Cc: radhey.shyam.pandey, davem, kuba, netdev
On Wed, Mar 24, 2021 at 10:48:55AM +0100, Daniel Mack wrote:
> In setups with fixed-link settings on the hardware bus 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.
Hi Danial
What about axienet_dma_err_handler()?
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: axienet: allow setups without MDIO
2021-03-24 12:38 ` Andrew Lunn
@ 2021-03-24 13:03 ` Daniel Mack
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Mack @ 2021-03-24 13:03 UTC (permalink / raw)
To: Andrew Lunn; +Cc: radhey.shyam.pandey, davem, kuba, netdev
On 3/24/21 1:38 PM, Andrew Lunn wrote:
> On Wed, Mar 24, 2021 at 10:48:55AM +0100, Daniel Mack wrote:
>> In setups with fixed-link settings on the hardware bus 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.
>
> Hi Danial
>
> What about axienet_dma_err_handler()?
Ah, I missed that one. Thanks a lot! Will send a v2.
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-24 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 9:48 [PATCH] net: axienet: allow setups without MDIO Daniel Mack
2021-03-24 12:38 ` Andrew Lunn
2021-03-24 13:03 ` Daniel Mack
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.