Re: [PATCH V2 4/4] net-next: mediatek: add support for IRQ grouping

2016-06-29 Thread kbuild test robot
Hi,

[auto build test ERROR on net/master]
[also build test ERROR on next-20160629]
[cannot apply to net-next/master v4.7-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/John-Crispin/net-next-mediatek-IRQ-cleanups-fixes-and-grouping/20160629-194341
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 
'mtk_poll_controller':
>> drivers/net/ethernet/mediatek/mtk_eth_soc.c:1300:2: error: implicit 
>> declaration of function 'mtk_handle_irq' 
>> [-Werror=implicit-function-declaration]
 mtk_handle_irq(dev->irq[0], dev);
 ^
>> drivers/net/ethernet/mediatek/mtk_eth_soc.c:1300:25: error: subscripted 
>> value is neither array nor pointer nor vector
 mtk_handle_irq(dev->irq[0], dev);
^
   cc1: some warnings being treated as errors

vim +/mtk_handle_irq +1300 drivers/net/ethernet/mediatek/mtk_eth_soc.c

  1294  {
  1295  struct mtk_mac *mac = netdev_priv(dev);
  1296  struct mtk_eth *eth = mac->hw;
  1297  u32 int_mask = MTK_TX_DONE_INT | MTK_RX_DONE_INT;
  1298  
  1299  mtk_irq_disable(eth, int_mask);
> 1300  mtk_handle_irq(dev->irq[0], dev);
  1301  mtk_irq_enable(eth, int_mask);
  1302  }
  1303  #endif

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH V2 4/4] net-next: mediatek: add support for IRQ grouping

2016-06-29 Thread John Crispin
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
cores. This patch splits the IRQ handler into 2 separate functions, one for
TX and another for RX. The TX housekeeping is split out into its own NAPI
handler.

Signed-off-by: John Crispin 
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c |  155 +--
 drivers/net/ethernet/mediatek/mtk_eth_soc.h |   15 ++-
 2 files changed, 111 insertions(+), 59 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 698caba..7056a37 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -893,17 +893,17 @@ release_desc:
return done;
 }
 
-static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
+static int mtk_poll_tx(struct mtk_eth *eth, int budget)
 {
struct mtk_tx_ring *ring = >tx_ring;
struct mtk_tx_dma *desc;
struct sk_buff *skb;
struct mtk_tx_buf *tx_buf;
-   int total = 0, done[MTK_MAX_DEVS];
+   unsigned int done[MTK_MAX_DEVS];
unsigned int bytes[MTK_MAX_DEVS];
u32 cpu, dma;
static int condition;
-   int i;
+   int total = 0, i;
 
memset(done, 0, sizeof(done));
memset(bytes, 0, sizeof(bytes));
@@ -954,15 +954,6 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, 
bool *tx_again)
total += done[i];
}
 
-   /* read hw index again make sure no new tx packet */
-   if (cpu != dma || cpu != mtk_r32(eth, MTK_QTX_DRX_PTR))
-   *tx_again = true;
-   else
-   mtk_w32(eth, MTK_TX_DONE_INT, MTK_QMTK_INT_STATUS);
-
-   if (!total)
-   return 0;
-
if (mtk_queue_stopped(eth) &&
(atomic_read(>free_count) > ring->thresh))
mtk_wake_queue(eth);
@@ -970,47 +961,75 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, 
bool *tx_again)
return total;
 }
 
-static int mtk_poll(struct napi_struct *napi, int budget)
+static void mtk_handle_status_irq(struct mtk_eth *eth)
 {
-   struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi);
-   u32 status, status2, mask;
-   int tx_done, rx_done;
-   bool tx_again = false;
-
-   status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
-   status2 = mtk_r32(eth, MTK_INT_STATUS2);
-   tx_done = 0;
-   rx_done = 0;
-   tx_again = 0;
-
-   if (status & MTK_TX_DONE_INT)
-   tx_done = mtk_poll_tx(eth, budget, _again);
-
-   if (status & MTK_RX_DONE_INT)
-   rx_done = mtk_poll_rx(napi, budget, eth);
+   u32 status2 = mtk_r32(eth, MTK_INT_STATUS2);
 
if (unlikely(status2 & (MTK_GDM1_AF | MTK_GDM2_AF))) {
mtk_stats_update(eth);
mtk_w32(eth, (MTK_GDM1_AF | MTK_GDM2_AF),
MTK_INT_STATUS2);
}
+}
+
+static int mtk_napi_tx(struct napi_struct *napi, int budget)
+{
+   struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi);
+   u32 status, mask;
+   int tx_done = 0;
+
+   mtk_handle_status_irq(eth);
+   mtk_w32(eth, MTK_TX_DONE_INT, MTK_QMTK_INT_STATUS);
+   tx_done = mtk_poll_tx(eth, budget);
+
+   if (unlikely(netif_msg_intr(eth))) {
+   status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
+   mask = mtk_r32(eth, MTK_QDMA_INT_MASK);
+   dev_info(eth->dev,
+"done tx %d, intr 0x%08x/0x%x\n",
+tx_done, status, mask);
+   }
+
+   if (tx_done == budget)
+   return budget;
+
+   status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
+   if (status & MTK_TX_DONE_INT)
+   return budget;
+
+   napi_complete(napi);
+   mtk_irq_enable(eth, MTK_TX_DONE_INT);
+
+   return tx_done;
+}
+
+static int mtk_napi_rx(struct napi_struct *napi, int budget)
+{
+   struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi);
+   u32 status, mask;
+   int rx_done = 0;
+
+   mtk_handle_status_irq(eth);
+   mtk_w32(eth, MTK_RX_DONE_INT, MTK_QMTK_INT_STATUS);
+   rx_done = mtk_poll_rx(napi, budget, eth);
 
if (unlikely(netif_msg_intr(eth))) {
+   status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
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,
+"done rx %d, intr 0x%08x/0x%x\n",
+rx_done, status, mask);
}
 
-   if (tx_again || rx_done == budget)
+   if (rx_done == budget)
return budget;
 
status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
-   if (status & (tx_intr |