linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet
@ 2019-04-03 10:09 Nicolas Ferre
  2019-04-03 10:09 ` [PATCH v2 2/3] dmaengine: at_xdmac: enhance channel errors handling " Nicolas Ferre
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolas Ferre @ 2019-04-03 10:09 UTC (permalink / raw)
  To: dmaengine, Vinod Koul
  Cc: Ludovic Desroches, Alexandre Belloni, linux-arm-kernel,
	linux-kernel

Even if this case shouldn't happen when controller is properly programmed,
it's still better to avoid dumping a kernel Oops for this.
As the sequence may happen only for debugging purposes, log the error and
just finish the tasklet call.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: added Ludovic's tag

 drivers/dma/at_xdmac.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index fe69dccfa0c0..37a269420435 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1606,7 +1606,11 @@ static void at_xdmac_tasklet(unsigned long data)
 					struct at_xdmac_desc,
 					xfer_node);
 		dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
-		BUG_ON(!desc->active_xfer);
+		if (!desc->active_xfer) {
+			dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
+			spin_unlock_bh(&atchan->lock);
+			return;
+		}
 
 		txd = &desc->tx_dma_desc;
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] dmaengine: at_xdmac: enhance channel errors handling in tasklet
  2019-04-03 10:09 [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas Ferre
@ 2019-04-03 10:09 ` Nicolas Ferre
  2019-04-03 10:09 ` [PATCH v2 3/3] dmaengine: at_xdmac: only monitor overflow errors for peripheral xfer Nicolas Ferre
  2019-04-03 10:22 ` [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas.Ferre
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Ferre @ 2019-04-03 10:09 UTC (permalink / raw)
  To: dmaengine, Vinod Koul
  Cc: Ludovic Desroches, Alexandre Belloni, linux-arm-kernel,
	linux-kernel

Complement the identification of errors with stoping 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>
---
v2: added Ludovic's tag
    address Vinod's comments (typo, comment, empty line before logical blocks)

 drivers/dma/at_xdmac.c | 48 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 37a269420435..b7117474a10d 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -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,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] dmaengine: at_xdmac: only monitor overflow errors for peripheral xfer
  2019-04-03 10:09 [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas Ferre
  2019-04-03 10:09 ` [PATCH v2 2/3] dmaengine: at_xdmac: enhance channel errors handling " Nicolas Ferre
@ 2019-04-03 10:09 ` Nicolas Ferre
  2019-04-03 10:22 ` [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas.Ferre
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Ferre @ 2019-04-03 10:09 UTC (permalink / raw)
  To: dmaengine, Vinod Koul
  Cc: Ludovic Desroches, Alexandre Belloni, linux-arm-kernel,
	linux-kernel

The overflow error flag (ROI: Request Overflow Error) is only relevant
for the case when the channel handles a peripheral synchronized transfer.
Not in the case of memory to memory transfer where there is no hardware
request signal.

Remove the use of this interrupt source in such a case. It's based on
the first descriptor which holds the configuration for the whole
linked list transfer.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: added Ludovic's tag

 drivers/dma/at_xdmac.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index b7117474a10d..cbe545ae4dfc 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -308,6 +308,11 @@ static inline int at_xdmac_csize(u32 maxburst)
 	return csize;
 };
 
+static inline bool at_xdmac_chan_is_peripheral_xfer(u32 cfg)
+{
+	return cfg & AT_XDMAC_CC_TYPE_PER_TRAN;
+}
+
 static inline u8 at_xdmac_get_dwidth(u32 cfg)
 {
 	return (cfg & AT_XDMAC_CC_DWIDTH_MASK) >> AT_XDMAC_CC_DWIDTH_OFFSET;
@@ -389,7 +394,13 @@ static void at_xdmac_start_xfer(struct at_xdmac_chan *atchan,
 		 at_xdmac_chan_read(atchan, AT_XDMAC_CUBC));
 
 	at_xdmac_chan_write(atchan, AT_XDMAC_CID, 0xffffffff);
-	reg = AT_XDMAC_CIE_RBEIE | AT_XDMAC_CIE_WBEIE | AT_XDMAC_CIE_ROIE;
+	reg = AT_XDMAC_CIE_RBEIE | AT_XDMAC_CIE_WBEIE;
+	/*
+	 * Request Overflow Error is only for peripheral synchronized transfers
+	 */
+	if (at_xdmac_chan_is_peripheral_xfer(first->lld.mbr_cfg))
+		reg |= AT_XDMAC_CIE_ROIE;
+
 	/*
 	 * There is no end of list when doing cyclic dma, we need to get
 	 * an interrupt after each periods.
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet
  2019-04-03 10:09 [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas Ferre
  2019-04-03 10:09 ` [PATCH v2 2/3] dmaengine: at_xdmac: enhance channel errors handling " Nicolas Ferre
  2019-04-03 10:09 ` [PATCH v2 3/3] dmaengine: at_xdmac: only monitor overflow errors for peripheral xfer Nicolas Ferre
@ 2019-04-03 10:22 ` Nicolas.Ferre
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas.Ferre @ 2019-04-03 10:22 UTC (permalink / raw)
  To: dmaengine, vkoul
  Cc: Ludovic.Desroches, alexandre.belloni, linux-arm-kernel,
	linux-kernel

Vinod,

Please disregard this series: I'm sending a v3 right now. Sorry for the 
noise.

Best regards,
   Nicolas

On 03/04/2019 at 12:09, Nicolas Ferre wrote:
> Even if this case shouldn't happen when controller is properly programmed,
> it's still better to avoid dumping a kernel Oops for this.
> As the sequence may happen only for debugging purposes, log the error and
> just finish the tasklet call.
> 
> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
> ---
> v2: added Ludovic's tag
> 
>   drivers/dma/at_xdmac.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index fe69dccfa0c0..37a269420435 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1606,7 +1606,11 @@ static void at_xdmac_tasklet(unsigned long data)
>   					struct at_xdmac_desc,
>   					xfer_node);
>   		dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
> -		BUG_ON(!desc->active_xfer);
> +		if (!desc->active_xfer) {
> +			dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
> +			spin_unlock_bh(&atchan->lock);
> +			return;
> +		}
>   
>   		txd = &desc->tx_dma_desc;
>   
> 


-- 
Nicolas Ferre
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-03 10:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-03 10:09 [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas Ferre
2019-04-03 10:09 ` [PATCH v2 2/3] dmaengine: at_xdmac: enhance channel errors handling " Nicolas Ferre
2019-04-03 10:09 ` [PATCH v2 3/3] dmaengine: at_xdmac: only monitor overflow errors for peripheral xfer Nicolas Ferre
2019-04-03 10:22 ` [PATCH v2 1/3] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Nicolas.Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).