* [PATCH net-next 1/6] net: fec: add return value check after calling .of_property_read_u32()
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 2/6] net: fec: avoid BD pointer type cast to 32bit Fugang Duan
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
Add return value check after calling .of_property_read_u32() to avoid
the warning reported by coverity.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 91a1664..886a9c9 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3197,9 +3197,9 @@ static void fec_reset_phy(struct platform_device *pdev)
if (!np)
return;
- of_property_read_u32(np, "phy-reset-duration", &msec);
+ err = of_property_read_u32(np, "phy-reset-duration", &msec);
/* A sane reset duration should not be longer than 1s */
- if (msec > 1000)
+ if (!err && msec > 1000)
msec = 1;
phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/6] net: fec: avoid BD pointer type cast to 32bit
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 1/6] net: fec: add return value check after calling .of_property_read_u32() Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 3/6] net: fec: pass ->dev to dma_alloc__coherent() API Fugang Duan
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
In aarch64 system, the BD pointer is 64bit, and the high-order 32-bits
of the address is effective, so replace usigned with (void *) type to
aovid 64bit address is casted to 32bit in .fec_enet_get_nextdesc() and
.fec_enet_get_prevdesc() functions.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 886a9c9..172624c 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -235,14 +235,14 @@ static struct bufdesc *fec_enet_get_nextdesc(struct bufdesc *bdp,
struct bufdesc_prop *bd)
{
return (bdp >= bd->last) ? bd->base
- : (struct bufdesc *)(((unsigned)bdp) + bd->dsize);
+ : (struct bufdesc *)(((void *)bdp) + bd->dsize);
}
static struct bufdesc *fec_enet_get_prevdesc(struct bufdesc *bdp,
struct bufdesc_prop *bd)
{
return (bdp <= bd->base) ? bd->last
- : (struct bufdesc *)(((unsigned)bdp) - bd->dsize);
+ : (struct bufdesc *)(((void *)bdp) - bd->dsize);
}
static int fec_enet_get_bd_index(struct bufdesc *bdp,
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/6] net: fec: pass ->dev to dma_alloc__coherent() API
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 1/6] net: fec: add return value check after calling .of_property_read_u32() Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 2/6] net: fec: avoid BD pointer type cast to 32bit Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 4/6] net: fec: add phy-reset-gpios PROBE_DEFER check Fugang Duan
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
In aarch64 system, it requires to trasfer ->dev to dma_alloc_coherent()
API, otherwise allocate failed and print kernel warning.
Signed-off-by: Fugang Duan <B38611@freescale.com>
---
drivers/net/ethernet/freescale/fec_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 172624c..bcf8675 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2651,7 +2651,7 @@ static void fec_enet_free_queue(struct net_device *ndev)
for (i = 0; i < fep->num_tx_queues; i++)
if (fep->tx_queue[i] && fep->tx_queue[i]->tso_hdrs) {
txq = fep->tx_queue[i];
- dma_free_coherent(NULL,
+ dma_free_coherent(&fep->pdev->dev,
txq->bd.ring_size * TSO_HEADER_SIZE,
txq->tso_hdrs,
txq->tso_hdrs_dma);
@@ -2685,7 +2685,7 @@ static int fec_enet_alloc_queue(struct net_device *ndev)
txq->tx_wake_threshold =
(txq->bd.ring_size - txq->tx_stop_threshold) / 2;
- txq->tso_hdrs = dma_alloc_coherent(NULL,
+ txq->tso_hdrs = dma_alloc_coherent(&fep->pdev->dev,
txq->bd.ring_size * TSO_HEADER_SIZE,
&txq->tso_hdrs_dma,
GFP_KERNEL);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 4/6] net: fec: add phy-reset-gpios PROBE_DEFER check
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
` (2 preceding siblings ...)
2017-04-11 11:13 ` [PATCH net-next 3/6] net: fec: pass ->dev to dma_alloc__coherent() API Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 5/6] net: fec: correct the errata number comment typo Fugang Duan
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
Many boards use i2c/spi expander gpio as phy-reset-gpios and these
gpios maybe registered after fec port, driver should check the return
value of .of_get_named_gpio().
Signed-off-by: Fugang Duan <B38611@freescale.com>
---
drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index bcf8675..3cec94e 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3187,7 +3187,7 @@ static int fec_enet_init(struct net_device *ndev)
}
#ifdef CONFIG_OF
-static void fec_reset_phy(struct platform_device *pdev)
+static int fec_reset_phy(struct platform_device *pdev)
{
int err, phy_reset;
bool active_high = false;
@@ -3195,7 +3195,7 @@ static void fec_reset_phy(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
if (!np)
- return;
+ return 0;
err = of_property_read_u32(np, "phy-reset-duration", &msec);
/* A sane reset duration should not be longer than 1s */
@@ -3203,8 +3203,10 @@ static void fec_reset_phy(struct platform_device *pdev)
msec = 1;
phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
- if (!gpio_is_valid(phy_reset))
- return;
+ if (phy_reset == -EPROBE_DEFER)
+ return phy_reset;
+ else if (!gpio_is_valid(phy_reset))
+ return 0;
active_high = of_property_read_bool(np, "phy-reset-active-high");
@@ -3213,7 +3215,7 @@ static void fec_reset_phy(struct platform_device *pdev)
"phy-reset");
if (err) {
dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
- return;
+ return err;
}
if (msec > 20)
@@ -3222,14 +3224,17 @@ static void fec_reset_phy(struct platform_device *pdev)
usleep_range(msec * 1000, msec * 1000 + 1000);
gpio_set_value_cansleep(phy_reset, !active_high);
+
+ return 0;
}
#else /* CONFIG_OF */
-static void fec_reset_phy(struct platform_device *pdev)
+static int fec_reset_phy(struct platform_device *pdev)
{
/*
* In case of platform probe, the reset has been done
* by machine code.
*/
+ return 0;
}
#endif /* CONFIG_OF */
@@ -3400,6 +3405,7 @@ static void fec_reset_phy(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev,
"Failed to enable phy regulator: %d\n", ret);
+ clk_disable_unprepare(fep->clk_ipg);
goto failed_regulator;
}
} else {
@@ -3412,7 +3418,9 @@ static void fec_reset_phy(struct platform_device *pdev)
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
- fec_reset_phy(pdev);
+ ret = fec_reset_phy(pdev);
+ if (ret)
+ goto failed_reset;
if (fep->bufdesc_ex)
fec_ptp_init(pdev);
@@ -3473,8 +3481,10 @@ static void fec_reset_phy(struct platform_device *pdev)
fec_ptp_stop(pdev);
if (fep->reg_phy)
regulator_disable(fep->reg_phy);
+failed_reset:
+ pm_runtime_put(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
failed_regulator:
- clk_disable_unprepare(fep->clk_ipg);
failed_clk_ipg:
fec_enet_clk_enable(ndev, false);
failed_clk:
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 5/6] net: fec: correct the errata number comment typo
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
` (3 preceding siblings ...)
2017-04-11 11:13 ` [PATCH net-next 4/6] net: fec: add phy-reset-gpios PROBE_DEFER check Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 11:13 ` [PATCH net-next 6/6] net: fec: add ERR007885 for i.MX6ul enet IP Fugang Duan
2017-04-11 18:36 ` [PATCH net-next 0/6] net: fec: driver code clean David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
Correct the errata number ERR006358 comment typo.
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 3cec94e..f3a7835 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1266,7 +1266,7 @@ static void fec_enet_timeout_work(struct work_struct *work)
}
}
- /* ERR006538: Keep the transmitter going */
+ /* ERR006358: Keep the transmitter going */
if (bdp != txq->bd.cur &&
readl(txq->bd.reg_desc_active) == 0)
writel(0, txq->bd.reg_desc_active);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 6/6] net: fec: add ERR007885 for i.MX6ul enet IP
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
` (4 preceding siblings ...)
2017-04-11 11:13 ` [PATCH net-next 5/6] net: fec: correct the errata number comment typo Fugang Duan
@ 2017-04-11 11:13 ` Fugang Duan
2017-04-11 18:36 ` [PATCH net-next 0/6] net: fec: driver code clean David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Fugang Duan @ 2017-04-11 11:13 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, stephen, fugang.duan
The errata ERR007885 HW fix don't add to i.MX6ul ENET IP version,
so add sw workaroud for the chip.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f3a7835..a92bf94 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -117,8 +117,9 @@
.name = "imx6ul-fec",
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
- FEC_QUIRK_HAS_VLAN | FEC_QUIRK_BUG_CAPTURE |
- FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE,
+ FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR007885 |
+ FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_HAS_RACC |
+ FEC_QUIRK_HAS_COALESCE,
}, {
/* sentinel */
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/6] net: fec: driver code clean
2017-04-11 11:13 [PATCH net-next 0/6] net: fec: driver code clean Fugang Duan
` (5 preceding siblings ...)
2017-04-11 11:13 ` [PATCH net-next 6/6] net: fec: add ERR007885 for i.MX6ul enet IP Fugang Duan
@ 2017-04-11 18:36 ` David Miller
6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-04-11 18:36 UTC (permalink / raw)
To: fugang.duan; +Cc: netdev, bhutchings, stephen
From: Fugang Duan <fugang.duan@nxp.com>
Date: Tue, 11 Apr 2017 19:13:02 +0800
> The patch series are for fec ethernet driver code clean up, each patch is
> independent.
> Patch #1,#4,#5 are code clean up.
> Patch #2,#3 are for aarch64 platform.
> Patch #6 is for i.MX6UL to add lost errata workaround.
Series applied, thank you.
^ permalink raw reply [flat|nested] 8+ messages in thread