|
@@ -1,7 +1,7 @@
|
|
-From f43e3aaaacaaf0482f0aaa6fbad03572f3a0c614 Mon Sep 17 00:00:00 2001
|
|
|
|
|
|
+From 781eb70655d4f25af51aafcc010851918d49b2d7 Mon Sep 17 00:00:00 2001
|
|
From: John Crispin <[email protected]>
|
|
From: John Crispin <[email protected]>
|
|
Date: Wed, 23 Mar 2016 18:31:48 +0100
|
|
Date: Wed, 23 Mar 2016 18:31:48 +0100
|
|
-Subject: [PATCH 88/91] net-next: mediatek: add support for IRQ grouping
|
|
|
|
|
|
+Subject: [PATCH 88/90] net-next: mediatek: add support for IRQ grouping
|
|
|
|
|
|
The ethernet core has 3 IRQs. using the IRQ grouping registers we are able
|
|
The ethernet core has 3 IRQs. using the IRQ grouping registers we are able
|
|
to separate TX and RX IRQs, which allows us to service them on separate
|
|
to separate TX and RX IRQs, which allows us to service them on separate
|
|
@@ -11,15 +11,15 @@ Instead we use a tasklet to handle housekeeping.
|
|
|
|
|
|
Signed-off-by: John Crispin <[email protected]>
|
|
Signed-off-by: John Crispin <[email protected]>
|
|
---
|
|
---
|
|
- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 165 ++++++++++++++++++---------
|
|
|
|
|
|
+ drivers/net/ethernet/mediatek/mtk_eth_soc.c | 164 ++++++++++++++++++---------
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 16 ++-
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 16 ++-
|
|
- 2 files changed, 125 insertions(+), 56 deletions(-)
|
|
|
|
|
|
+ 2 files changed, 124 insertions(+), 56 deletions(-)
|
|
|
|
|
|
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
-index f821820..b5e364c 100644
|
|
|
|
|
|
+index f86d551..6557026 100644
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
-@@ -789,7 +789,7 @@ drop:
|
|
|
|
|
|
+@@ -790,7 +790,7 @@ drop:
|
|
}
|
|
}
|
|
|
|
|
|
static int mtk_poll_rx(struct napi_struct *napi, int budget,
|
|
static int mtk_poll_rx(struct napi_struct *napi, int budget,
|
|
@@ -28,7 +28,7 @@ index f821820..b5e364c 100644
|
|
{
|
|
{
|
|
struct mtk_rx_ring *ring = ð->rx_ring;
|
|
struct mtk_rx_ring *ring = ð->rx_ring;
|
|
int idx = ring->calc_idx;
|
|
int idx = ring->calc_idx;
|
|
-@@ -877,19 +877,18 @@ release_desc:
|
|
|
|
|
|
+@@ -878,19 +878,18 @@ release_desc:
|
|
}
|
|
}
|
|
|
|
|
|
if (done < budget)
|
|
if (done < budget)
|
|
@@ -51,11 +51,9 @@ index f821820..b5e364c 100644
|
|
u32 cpu, dma;
|
|
u32 cpu, dma;
|
|
static int condition;
|
|
static int condition;
|
|
int i;
|
|
int i;
|
|
-@@ -941,64 +940,82 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
|
|
|
|
- continue;
|
|
|
|
- netdev_completed_queue(eth->netdev[i], done, bytes);
|
|
|
|
|
|
+@@ -944,63 +943,80 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
|
|
}
|
|
}
|
|
-+
|
|
|
|
|
|
+
|
|
/* read hw index again make sure no new tx packet */
|
|
/* read hw index again make sure no new tx packet */
|
|
- if (cpu != dma || cpu != mtk_r32(eth, MTK_QTX_DRX_PTR))
|
|
- if (cpu != dma || cpu != mtk_r32(eth, MTK_QTX_DRX_PTR))
|
|
- *tx_again = true;
|
|
- *tx_again = true;
|
|
@@ -103,7 +101,7 @@ index f821820..b5e364c 100644
|
|
mtk_w32(eth, status_intr, MTK_INT_STATUS2);
|
|
mtk_w32(eth, status_intr, MTK_INT_STATUS2);
|
|
}
|
|
}
|
|
+}
|
|
+}
|
|
-+
|
|
|
|
|
|
+
|
|
+static int mtk_napi_tx(struct napi_struct *napi, int budget)
|
|
+static int mtk_napi_tx(struct napi_struct *napi, int budget)
|
|
+{
|
|
+{
|
|
+ struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi);
|
|
+ struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi);
|
|
@@ -114,21 +112,27 @@ index f821820..b5e364c 100644
|
|
+
|
|
+
|
|
+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
+ tx_done = mtk_poll_tx(eth, budget);
|
|
+ tx_done = mtk_poll_tx(eth, budget);
|
|
-+ if (unlikely(netif_msg_intr(eth))) {
|
|
|
|
-+ mask = mtk_r32(eth, MTK_QDMA_INT_MASK);
|
|
|
|
|
|
+ if (unlikely(netif_msg_intr(eth))) {
|
|
|
|
+ mask = mtk_r32(eth, MTK_QDMA_INT_MASK);
|
|
|
|
+- netdev_info(eth->netdev[0],
|
|
|
|
+- "done tx %d, rx %d, intr 0x%08x/0x%x\n",
|
|
|
|
+- tx_done, rx_done, status, mask);
|
|
+ dev_info(eth->dev,
|
|
+ dev_info(eth->dev,
|
|
+ "done tx %d, intr 0x%08x/0x%x\n",
|
|
+ "done tx %d, intr 0x%08x/0x%x\n",
|
|
+ tx_done, status, mask);
|
|
+ tx_done, status, mask);
|
|
-+ }
|
|
|
|
-+
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+- if (tx_again || rx_done == budget)
|
|
+ if (tx_done == budget)
|
|
+ if (tx_done == budget)
|
|
-+ return budget;
|
|
|
|
-+
|
|
|
|
-+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
|
|
|
|
+ return budget;
|
|
|
|
+
|
|
|
|
+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
|
|
+- if (status & (tx_intr | rx_intr))
|
|
+ if (status & MTK_TX_DONE_INT)
|
|
+ if (status & MTK_TX_DONE_INT)
|
|
-+ return budget;
|
|
|
|
-+
|
|
|
|
-+ napi_complete(napi);
|
|
|
|
|
|
+ return budget;
|
|
|
|
+
|
|
|
|
+ napi_complete(napi);
|
|
|
|
+- mtk_irq_enable(eth, tx_intr | rx_intr);
|
|
+ mtk_irq_enable(eth, MTK_TX_DONE_INT);
|
|
+ mtk_irq_enable(eth, MTK_TX_DONE_INT);
|
|
+
|
|
+
|
|
+ return tx_done;
|
|
+ return tx_done;
|
|
@@ -139,35 +143,29 @@ index f821820..b5e364c 100644
|
|
+ struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi);
|
|
+ struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi);
|
|
+ u32 status, mask;
|
|
+ u32 status, mask;
|
|
+ int rx_done = 0;
|
|
+ int rx_done = 0;
|
|
-
|
|
|
|
|
|
++
|
|
+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
+ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
+ rx_done = mtk_poll_rx(napi, budget, eth);
|
|
+ rx_done = mtk_poll_rx(napi, budget, eth);
|
|
- if (unlikely(netif_msg_intr(eth))) {
|
|
|
|
- mask = mtk_r32(eth, MTK_QDMA_INT_MASK);
|
|
|
|
-- netdev_info(eth->netdev[0],
|
|
|
|
-- "done tx %d, rx %d, intr 0x%08x/0x%x\n",
|
|
|
|
-- tx_done, rx_done, status, mask);
|
|
|
|
|
|
++ if (unlikely(netif_msg_intr(eth))) {
|
|
|
|
++ mask = mtk_r32(eth, MTK_QDMA_INT_MASK);
|
|
+ dev_info(eth->dev,
|
|
+ dev_info(eth->dev,
|
|
+ "done rx %d, intr 0x%08x/0x%x\n",
|
|
+ "done rx %d, intr 0x%08x/0x%x\n",
|
|
+ rx_done, status, mask);
|
|
+ rx_done, status, mask);
|
|
- }
|
|
|
|
-
|
|
|
|
-- if (tx_again || rx_done == budget)
|
|
|
|
|
|
++ }
|
|
|
|
++
|
|
+ if (rx_done == budget)
|
|
+ if (rx_done == budget)
|
|
- return budget;
|
|
|
|
-
|
|
|
|
- status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
|
|
-- if (status & (tx_intr | rx_intr))
|
|
|
|
|
|
++ return budget;
|
|
|
|
++
|
|
|
|
++ status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
|
|
+ if (status & MTK_RX_DONE_INT)
|
|
+ if (status & MTK_RX_DONE_INT)
|
|
- return budget;
|
|
|
|
-
|
|
|
|
- napi_complete(napi);
|
|
|
|
-- mtk_irq_enable(eth, tx_intr | rx_intr);
|
|
|
|
|
|
++ return budget;
|
|
|
|
++
|
|
|
|
++ napi_complete(napi);
|
|
+ mtk_irq_enable(eth, MTK_RX_DONE_INT);
|
|
+ mtk_irq_enable(eth, MTK_RX_DONE_INT);
|
|
|
|
|
|
return rx_done;
|
|
return rx_done;
|
|
}
|
|
}
|
|
-@@ -1235,22 +1252,44 @@ static void mtk_tx_timeout(struct net_device *dev)
|
|
|
|
|
|
+@@ -1237,22 +1253,44 @@ static void mtk_tx_timeout(struct net_device *dev)
|
|
schedule_work(ð->pending_work);
|
|
schedule_work(ð->pending_work);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -190,8 +188,7 @@ index f821820..b5e364c 100644
|
|
- } else {
|
|
- } else {
|
|
- mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
- mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
+ mtk_irq_disable(eth, MTK_RX_DONE_INT);
|
|
+ mtk_irq_disable(eth, MTK_RX_DONE_INT);
|
|
- }
|
|
|
|
-- mtk_irq_disable(eth, (MTK_RX_DONE_INT | MTK_TX_DONE_INT));
|
|
|
|
|
|
++ }
|
|
+ mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
+ mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
+
|
|
+
|
|
+ return IRQ_HANDLED;
|
|
+ return IRQ_HANDLED;
|
|
@@ -212,12 +209,13 @@ index f821820..b5e364c 100644
|
|
+ if (likely(napi_schedule_prep(ð->tx_napi)))
|
|
+ if (likely(napi_schedule_prep(ð->tx_napi)))
|
|
+ __napi_schedule(ð->tx_napi);
|
|
+ __napi_schedule(ð->tx_napi);
|
|
+ mtk_irq_disable(eth, MTK_TX_DONE_INT);
|
|
+ mtk_irq_disable(eth, MTK_TX_DONE_INT);
|
|
-+ }
|
|
|
|
|
|
+ }
|
|
|
|
+- mtk_irq_disable(eth, (MTK_RX_DONE_INT | MTK_TX_DONE_INT));
|
|
+ mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
+ mtk_w32(eth, status, MTK_QMTK_INT_STATUS);
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
return IRQ_HANDLED;
|
|
}
|
|
}
|
|
-@@ -1263,7 +1302,7 @@ static void mtk_poll_controller(struct net_device *dev)
|
|
|
|
|
|
+@@ -1265,7 +1303,7 @@ static void mtk_poll_controller(struct net_device *dev)
|
|
u32 int_mask = MTK_TX_DONE_INT | MTK_RX_DONE_INT;
|
|
u32 int_mask = MTK_TX_DONE_INT | MTK_RX_DONE_INT;
|
|
|
|
|
|
mtk_irq_disable(eth, int_mask);
|
|
mtk_irq_disable(eth, int_mask);
|
|
@@ -226,7 +224,7 @@ index f821820..b5e364c 100644
|
|
mtk_irq_enable(eth, int_mask);
|
|
mtk_irq_enable(eth, int_mask);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
-@@ -1299,6 +1338,7 @@ static int mtk_open(struct net_device *dev)
|
|
|
|
|
|
+@@ -1301,6 +1339,7 @@ static int mtk_open(struct net_device *dev)
|
|
if (err)
|
|
if (err)
|
|
return err;
|
|
return err;
|
|
|
|
|
|
@@ -234,7 +232,7 @@ index f821820..b5e364c 100644
|
|
napi_enable(ð->rx_napi);
|
|
napi_enable(ð->rx_napi);
|
|
mtk_irq_enable(eth, MTK_TX_DONE_INT | MTK_RX_DONE_INT);
|
|
mtk_irq_enable(eth, MTK_TX_DONE_INT | MTK_RX_DONE_INT);
|
|
}
|
|
}
|
|
-@@ -1347,6 +1387,7 @@ static int mtk_stop(struct net_device *dev)
|
|
|
|
|
|
+@@ -1349,6 +1388,7 @@ static int mtk_stop(struct net_device *dev)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
mtk_irq_disable(eth, MTK_TX_DONE_INT | MTK_RX_DONE_INT);
|
|
mtk_irq_disable(eth, MTK_TX_DONE_INT | MTK_RX_DONE_INT);
|
|
@@ -242,7 +240,7 @@ index f821820..b5e364c 100644
|
|
napi_disable(ð->rx_napi);
|
|
napi_disable(ð->rx_napi);
|
|
|
|
|
|
mtk_stop_dma(eth, MTK_QDMA_GLO_CFG);
|
|
mtk_stop_dma(eth, MTK_QDMA_GLO_CFG);
|
|
-@@ -1384,7 +1425,11 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
|
|
|
|
|
|
+@@ -1386,7 +1426,11 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
|
|
/* Enable RX VLan Offloading */
|
|
/* Enable RX VLan Offloading */
|
|
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
|
|
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
|
|
|
|
|
|
@@ -255,7 +253,7 @@ index f821820..b5e364c 100644
|
|
dev_name(eth->dev), eth);
|
|
dev_name(eth->dev), eth);
|
|
if (err)
|
|
if (err)
|
|
return err;
|
|
return err;
|
|
-@@ -1400,7 +1445,11 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
|
|
|
|
|
|
+@@ -1402,7 +1446,11 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
|
|
mtk_w32(eth, 0, MTK_RST_GL);
|
|
mtk_w32(eth, 0, MTK_RST_GL);
|
|
|
|
|
|
/* FE int grouping */
|
|
/* FE int grouping */
|
|
@@ -268,7 +266,7 @@ index f821820..b5e364c 100644
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
for (i = 0; i < 2; i++) {
|
|
u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
|
|
u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
|
|
-@@ -1448,7 +1497,9 @@ static void mtk_uninit(struct net_device *dev)
|
|
|
|
|
|
+@@ -1450,7 +1498,9 @@ static void mtk_uninit(struct net_device *dev)
|
|
phy_disconnect(mac->phy_dev);
|
|
phy_disconnect(mac->phy_dev);
|
|
mtk_mdio_cleanup(eth);
|
|
mtk_mdio_cleanup(eth);
|
|
mtk_irq_disable(eth, ~0);
|
|
mtk_irq_disable(eth, ~0);
|
|
@@ -279,7 +277,7 @@ index f821820..b5e364c 100644
|
|
}
|
|
}
|
|
|
|
|
|
static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
-@@ -1723,10 +1774,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
|
|
|
|
|
+@@ -1725,10 +1775,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
|
dev_err(eth->dev, "error bringing up device\n");
|
|
dev_err(eth->dev, "error bringing up device\n");
|
|
goto free_netdev;
|
|
goto free_netdev;
|
|
}
|
|
}
|
|
@@ -292,7 +290,7 @@ index f821820..b5e364c 100644
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
-@@ -1743,6 +1794,7 @@ static int mtk_probe(struct platform_device *pdev)
|
|
|
|
|
|
+@@ -1745,6 +1795,7 @@ static int mtk_probe(struct platform_device *pdev)
|
|
struct mtk_soc_data *soc;
|
|
struct mtk_soc_data *soc;
|
|
struct mtk_eth *eth;
|
|
struct mtk_eth *eth;
|
|
int err;
|
|
int err;
|
|
@@ -300,7 +298,7 @@ index f821820..b5e364c 100644
|
|
|
|
|
|
match = of_match_device(of_mtk_match, &pdev->dev);
|
|
match = of_match_device(of_mtk_match, &pdev->dev);
|
|
soc = (struct mtk_soc_data *)match->data;
|
|
soc = (struct mtk_soc_data *)match->data;
|
|
-@@ -1778,10 +1830,12 @@ static int mtk_probe(struct platform_device *pdev)
|
|
|
|
|
|
+@@ -1780,10 +1831,12 @@ static int mtk_probe(struct platform_device *pdev)
|
|
return PTR_ERR(eth->rstc);
|
|
return PTR_ERR(eth->rstc);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -317,7 +315,7 @@ index f821820..b5e364c 100644
|
|
}
|
|
}
|
|
|
|
|
|
eth->clk_ethif = devm_clk_get(&pdev->dev, "ethif");
|
|
eth->clk_ethif = devm_clk_get(&pdev->dev, "ethif");
|
|
-@@ -1822,7 +1876,9 @@ static int mtk_probe(struct platform_device *pdev)
|
|
|
|
|
|
+@@ -1824,7 +1877,9 @@ static int mtk_probe(struct platform_device *pdev)
|
|
* for NAPI to work
|
|
* for NAPI to work
|
|
*/
|
|
*/
|
|
init_dummy_netdev(ð->dummy_dev);
|
|
init_dummy_netdev(ð->dummy_dev);
|
|
@@ -328,7 +326,7 @@ index f821820..b5e364c 100644
|
|
MTK_NAPI_WEIGHT);
|
|
MTK_NAPI_WEIGHT);
|
|
|
|
|
|
platform_set_drvdata(pdev, eth);
|
|
platform_set_drvdata(pdev, eth);
|
|
-@@ -1843,6 +1899,7 @@ static int mtk_remove(struct platform_device *pdev)
|
|
|
|
|
|
+@@ -1845,6 +1900,7 @@ static int mtk_remove(struct platform_device *pdev)
|
|
clk_disable_unprepare(eth->clk_gp1);
|
|
clk_disable_unprepare(eth->clk_gp1);
|
|
clk_disable_unprepare(eth->clk_gp2);
|
|
clk_disable_unprepare(eth->clk_gp2);
|
|
|
|
|