dmaengine: at_xdmac: enhance channel errors handling in tasklet
authorNicolas Ferre <nicolas.ferre@microchip.com>
Wed, 3 Apr 2019 10:23:58 +0000 (12:23 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 23 Apr 2019 05:08:56 +0000 (10:38 +0530)
Complement the identification of errors with stopping the channel and
dumping the descriptor that led to the error case.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/at_xdmac.c

index 37a2694..1dd7eda 100644 (file)
@@ -1575,6 +1575,46 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan)
                dmaengine_desc_get_callback_invoke(txd, NULL);
 }
 
+static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)
+{
+       struct at_xdmac         *atxdmac = to_at_xdmac(atchan->chan.device);
+       struct at_xdmac_desc    *bad_desc;
+
+       /*
+        * The descriptor currently at the head of the active list is
+        * broken. Since we don't have any way to report errors, we'll
+        * just have to scream loudly and try to continue with other
+        * descriptors queued (if any).
+        */
+       if (atchan->irq_status & AT_XDMAC_CIS_RBEIS)
+               dev_err(chan2dev(&atchan->chan), "read bus error!!!");
+       if (atchan->irq_status & AT_XDMAC_CIS_WBEIS)
+               dev_err(chan2dev(&atchan->chan), "write bus error!!!");
+       if (atchan->irq_status & AT_XDMAC_CIS_ROIS)
+               dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
+
+       spin_lock_bh(&atchan->lock);
+
+       /* Channel must be disabled first as it's not done automatically */
+       at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask);
+       while (at_xdmac_read(atxdmac, AT_XDMAC_GS) & atchan->mask)
+               cpu_relax();
+
+       bad_desc = list_first_entry(&atchan->xfers_list,
+                                   struct at_xdmac_desc,
+                                   xfer_node);
+
+       spin_unlock_bh(&atchan->lock);
+
+       /* Print bad descriptor's details if needed */
+       dev_dbg(chan2dev(&atchan->chan),
+               "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n",
+               __func__, &bad_desc->lld.mbr_sa, &bad_desc->lld.mbr_da,
+               bad_desc->lld.mbr_ubc);
+
+       /* Then continue with usual descriptor management */
+}
+
 static void at_xdmac_tasklet(unsigned long data)
 {
        struct at_xdmac_chan    *atchan = (struct at_xdmac_chan *)data;
@@ -1594,12 +1634,8 @@ static void at_xdmac_tasklet(unsigned long data)
                   || (atchan->irq_status & error_mask)) {
                struct dma_async_tx_descriptor  *txd;
 
-               if (atchan->irq_status & AT_XDMAC_CIS_RBEIS)
-                       dev_err(chan2dev(&atchan->chan), "read bus error!!!");
-               if (atchan->irq_status & AT_XDMAC_CIS_WBEIS)
-                       dev_err(chan2dev(&atchan->chan), "write bus error!!!");
-               if (atchan->irq_status & AT_XDMAC_CIS_ROIS)
-                       dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
+               if (atchan->irq_status & error_mask)
+                       at_xdmac_handle_error(atchan);
 
                spin_lock(&atchan->lock);
                desc = list_first_entry(&atchan->xfers_list,