* [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address
@ 2019-05-23 1:55 Andy Duan
2019-05-23 1:55 ` [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path Andy Duan
2019-05-24 20:11 ` [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address David Miller
0 siblings, 2 replies; 6+ messages in thread
From: Andy Duan @ 2019-05-23 1:55 UTC (permalink / raw)
To: davem; +Cc: netdev, baruch, Andy Duan
If MAC address read from nvmem efuse by calling .of_get_mac_address(),
but nvmem efuse is registerred later than the driver, then it
return -EPROBE_DEFER value. So modify the driver to support
defer probe when read MAC address from nvmem efuse.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 848defa..a76b609 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1634,7 +1634,7 @@ static int fec_enet_rx_napi(struct napi_struct *napi, int budget)
}
/* ------------------------------------------------------------------------- */
-static void fec_get_mac(struct net_device *ndev)
+static int fec_get_mac(struct net_device *ndev)
{
struct fec_enet_private *fep = netdev_priv(ndev);
struct fec_platform_data *pdata = dev_get_platdata(&fep->pdev->dev);
@@ -1657,6 +1657,8 @@ static void fec_get_mac(struct net_device *ndev)
const char *mac = of_get_mac_address(np);
if (!IS_ERR(mac))
iap = (unsigned char *) mac;
+ else if (PTR_ERR(mac) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
}
}
@@ -1693,7 +1695,7 @@ static void fec_get_mac(struct net_device *ndev)
eth_hw_addr_random(ndev);
netdev_info(ndev, "Using random MAC address: %pM\n",
ndev->dev_addr);
- return;
+ return 0;
}
memcpy(ndev->dev_addr, iap, ETH_ALEN);
@@ -1701,6 +1703,8 @@ static void fec_get_mac(struct net_device *ndev)
/* Adjust MAC if using macaddr */
if (iap == macaddr)
ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id;
+
+ return 0;
}
/* ------------------------------------------------------------------------- */
@@ -3146,7 +3150,10 @@ static int fec_enet_init(struct net_device *ndev)
memset(cbd_base, 0, bd_size);
/* Get the Ethernet address */
- fec_get_mac(ndev);
+ ret = fec_get_mac(ndev);
+ if (ret)
+ return ret;
+
/* make sure MAC we just acquired is programmed into the hw */
fec_set_mac_address(ndev, NULL);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path
2019-05-23 1:55 [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address Andy Duan
@ 2019-05-23 1:55 ` Andy Duan
2019-05-23 8:06 ` Baruch Siach
2019-05-24 20:14 ` David Miller
2019-05-24 20:11 ` [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address David Miller
1 sibling, 2 replies; 6+ messages in thread
From: Andy Duan @ 2019-05-23 1:55 UTC (permalink / raw)
To: davem; +Cc: netdev, baruch, Andy Duan
Fix the clk mismatch in the error path "failed_reset" because
below error path will disable clk_ahb and clk_ipg directly, it
should use pm_runtime_put_noidle() instead of pm_runtime_put()
to avoid to call runtime resume callback.
Reported-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f63eb2b..848defa 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3555,7 +3555,7 @@ fec_probe(struct platform_device *pdev)
if (fep->reg_phy)
regulator_disable(fep->reg_phy);
failed_reset:
- pm_runtime_put(&pdev->dev);
+ pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
failed_regulator:
clk_disable_unprepare(fep->clk_ahb);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path
2019-05-23 1:55 ` [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path Andy Duan
@ 2019-05-23 8:06 ` Baruch Siach
2019-05-24 20:14 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Baruch Siach @ 2019-05-23 8:06 UTC (permalink / raw)
To: Andy Duan; +Cc: David S. Miller, netdev, Shawn Guo, NXP Linux Team
Hi Andy,
On Thu, May 23, 2019 at 01:55:28AM +0000, Andy Duan wrote:
> Fix the clk mismatch in the error path "failed_reset" because
> below error path will disable clk_ahb and clk_ipg directly, it
> should use pm_runtime_put_noidle() instead of pm_runtime_put()
> to avoid to call runtime resume callback.
>
> Reported-by: Baruch Siach <baruch@tkos.co.il>
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Tested-by: Baruch Siach <baruch@tkos.co.il>
Tested on SolidRun Hummingboard Pulse.
Thanks.
But please avoid sending patched in base64 encoded emails. Plaintext is much
easier when dealing with 'git am'.
baruch
> ---
> drivers/net/ethernet/freescale/fec_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index f63eb2b..848defa 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3555,7 +3555,7 @@ fec_probe(struct platform_device *pdev)
> if (fep->reg_phy)
> regulator_disable(fep->reg_phy);
> failed_reset:
> - pm_runtime_put(&pdev->dev);
> + pm_runtime_put_noidle(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> failed_regulator:
> clk_disable_unprepare(fep->clk_ahb);
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address
2019-05-23 1:55 [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address Andy Duan
2019-05-23 1:55 ` [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path Andy Duan
@ 2019-05-24 20:11 ` David Miller
2019-05-27 1:31 ` [EXT] " Andy Duan
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2019-05-24 20:11 UTC (permalink / raw)
To: fugang.duan; +Cc: netdev, baruch
From: Andy Duan <fugang.duan@nxp.com>
Date: Thu, 23 May 2019 01:55:23 +0000
> @@ -3146,7 +3150,10 @@ static int fec_enet_init(struct net_device *ndev)
> memset(cbd_base, 0, bd_size);
>
> /* Get the Ethernet address */
> - fec_get_mac(ndev);
> + ret = fec_get_mac(ndev);
> + if (ret)
> + return ret;
You're leaking the queues allocated by fec_enet_alloc_queue().
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path
2019-05-23 1:55 ` [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path Andy Duan
2019-05-23 8:06 ` Baruch Siach
@ 2019-05-24 20:14 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2019-05-24 20:14 UTC (permalink / raw)
To: fugang.duan; +Cc: netdev, baruch
From: Andy Duan <fugang.duan@nxp.com>
Date: Thu, 23 May 2019 01:55:28 +0000
> Fix the clk mismatch in the error path "failed_reset" because
> below error path will disable clk_ahb and clk_ipg directly, it
> should use pm_runtime_put_noidle() instead of pm_runtime_put()
> to avoid to call runtime resume callback.
>
> Reported-by: Baruch Siach <baruch@tkos.co.il>
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXT] Re: [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address
2019-05-24 20:11 ` [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address David Miller
@ 2019-05-27 1:31 ` Andy Duan
0 siblings, 0 replies; 6+ messages in thread
From: Andy Duan @ 2019-05-27 1:31 UTC (permalink / raw)
To: David Miller; +Cc: netdev, baruch
From: David Miller <davem@davemloft.net> Sent: Saturday, May 25, 2019 4:12 AM
> From: Andy Duan <fugang.duan@nxp.com>
> Date: Thu, 23 May 2019 01:55:23 +0000
>
> > @@ -3146,7 +3150,10 @@ static int fec_enet_init(struct net_device *ndev)
> > memset(cbd_base, 0, bd_size);
> >
> > /* Get the Ethernet address */
> > - fec_get_mac(ndev);
> > + ret = fec_get_mac(ndev);
> > + if (ret)
> > + return ret;
>
> You're leaking the queues allocated by fec_enet_alloc_queue().
Good caught, thanks David.
I will send two patches for the V2 to fix the exisited queue memory leak.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-27 1:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 1:55 [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address Andy Duan
2019-05-23 1:55 ` [PATCH net,stable 1/1] net: fec: fix the clk mismatch in failed_reset path Andy Duan
2019-05-23 8:06 ` Baruch Siach
2019-05-24 20:14 ` David Miller
2019-05-24 20:11 ` [PATCH net,stable 1/1] net: fec: add defer probe for of_get_mac_address David Miller
2019-05-27 1:31 ` [EXT] " Andy Duan
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.