]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: macb: Handle HRESP error
authorHarini Katakam <harini.katakam@xilinx.com>
Mon, 18 Jul 2016 06:40:08 +0000 (12:10 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 27 Jul 2016 12:31:31 +0000 (14:31 +0200)
Handle HRESP error by doing a SW reset of RX and TX and
re-initializing the descriptors, RX and TX queue pointers.

Signed-off-by: Harini Katakam <harinik@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/cadence/macb.c
drivers/net/ethernet/cadence/macb.h

index 91b27ad634865e9ad92be491f135c4ceaa2c4e9b..e772ca4fae4b3afc1f820161e7ab2a2c13fa7c7a 100644 (file)
@@ -1111,6 +1111,53 @@ static int macb_poll(struct napi_struct *napi, int budget)
        return work_done;
 }
 
+static void macb_hresp_error_task(unsigned long data)
+{
+       struct macb *bp = (struct macb *)data;
+       struct net_device *dev = bp->dev;
+       struct macb_queue *queue = bp->queues;
+       unsigned int q;
+       u32 ctrl;
+
+       for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
+               queue_writel(queue, IDR, MACB_RX_INT_FLAGS |
+                                        MACB_TX_INT_FLAGS |
+                                        MACB_BIT(HRESP));
+       }
+       ctrl = macb_readl(bp, NCR);
+       ctrl &= ~(MACB_BIT(RE) | MACB_BIT(TE));
+       macb_writel(bp, NCR, ctrl);
+
+       netif_tx_stop_all_queues(dev);
+       netif_carrier_off(dev);
+
+       bp->macbgem_ops.mog_init_rings(bp);
+
+       macb_writel(bp, RBQP, bp->rx_ring_dma);
+       for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
+               queue_writel(queue, TBQP, queue->tx_ring_dma);
+               /* We only use the first queue at the moment. Remaining
+                * queues must be tied-off before we enable the receiver.
+                *
+                * See the documentation for receive_q1_ptr for more info.
+                */
+               if (q)
+                       queue_writel(queue, RBQP, bp->rx_ring_tieoff_dma);
+
+               /* Enable interrupts */
+               queue_writel(queue, IER,
+                            MACB_RX_INT_FLAGS |
+                            MACB_TX_INT_FLAGS |
+                            MACB_BIT(HRESP));
+       }
+
+       ctrl |= MACB_BIT(RE) | MACB_BIT(TE);
+       macb_writel(bp, NCR, ctrl);
+
+       netif_carrier_on(dev);
+       netif_tx_start_all_queues(dev);
+}
+
 static irqreturn_t macb_interrupt(int irq, void *dev_id)
 {
        struct macb_queue *queue = dev_id;
@@ -1201,11 +1248,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
                }
 
                if (status & MACB_BIT(HRESP)) {
-                       /*
-                        * TODO: Reset the hardware, and maybe move the
-                        * netdev_err to a lower-priority context as well
-                        * (work queue?)
-                        */
+                       tasklet_schedule(&bp->hresp_err_tasklet);
                        netdev_err(dev, "DMA bus error: HRESP not OK\n");
 
                        if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
@@ -3401,6 +3444,9 @@ static int macb_probe(struct platform_device *pdev)
 
        netif_carrier_off(dev);
 
+       tasklet_init(&bp->hresp_err_tasklet, macb_hresp_error_task,
+                    (unsigned long) bp);
+
        netdev_info(dev, "Cadence %s rev 0x%08x at 0x%08lx irq %d (%pM)\n",
                    macb_is_gem(bp) ? "GEM" : "MACB", macb_readl(bp, MID),
                    dev->base_addr, dev->irq, dev->dev_addr);
index 5dbcbe8d4731a6e1f8fa72219c998dab60635b04..977ffd8dabfcbb95390213c03df901238176383d 100644 (file)
@@ -925,6 +925,8 @@ struct macb {
        int                     phc_index;
        unsigned int            ns_incr;
        unsigned int            subns_incr;
+
+       struct tasklet_struct   hresp_err_tasklet;
 };
 
 static inline bool macb_is_gem(struct macb *bp)