public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly
@ 2022-05-26 13:51 Michael Walle
  2022-07-04 15:09 ` Michael Walle
  2022-07-05 12:48 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Walle @ 2022-05-26 13:51 UTC (permalink / raw)
  To: Ludovic Desroches, Tudor Ambarus, Vinod Koul, Nicolas Ferre
  Cc: linux-arm-kernel, dmaengine, linux-kernel, Michael Walle

It seems that it is valid to have less than the requested number of
descriptors. But what is not valid and leads to subsequent errors is to
have zero descriptors. In that case, abort the probing.

Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
Signed-off-by: Michael Walle <michael@walle.cc>
---
This was noticed with the atmel i2c driver:

[    2.488878] cma: cma_alloc: reserved: alloc failed, req-size: 1 pages, ret: -16
[    2.488934] dma dma0chan0: only 0 descriptors have been allocated
[    2.558378] cma: cma_alloc: reserved: alloc failed, req-size: 1 pages, ret: -16
[    2.558428] dma dma0chan1: only 0 descriptors have been allocated
[    2.558509] at91_i2c e0070600.i2c: using dma0chan0 (tx) and dma0chan1 (rx) for DMA transfers
[    2.558906] at91_i2c e0070600.i2c: AT91 i2c bus driver (hw version: 0x820).
..
[    7.393971] ------------[ cut here ]------------
[    7.393998] WARNING: CPU: 0 PID: 48 at arch/arm/mm/dma-mapping.c:492 pool_allocator_alloc+0xa0/0xa4
[    7.404940] coherent pool not initialised!
[    7.409018] Modules linked in:
[    7.412060] CPU: 0 PID: 48 Comm: kworker/0:6 Not tainted 5.18.0-next-20220526+ #639
[    7.419694] Hardware name: Generic DT based system
[    7.424472] Workqueue: events_power_efficient sfp_timeout
..
[    7.755103] dma dma0chan1: can't get descriptor
[    7.755239] at91_i2c e0070600.i2c: dma prep slave sg failed
[    8.133324] at91_i2c e0070600.i2c: controller timed out

Please note that this doesn't fix the underlying problem. It will just
handle that one gracefully.

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

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 3e9d726504e2..7b3e6030f7b4 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1900,6 +1900,11 @@ static int at_xdmac_alloc_chan_resources(struct dma_chan *chan)
 	for (i = 0; i < init_nr_desc_per_channel; i++) {
 		desc = at_xdmac_alloc_desc(chan, GFP_KERNEL);
 		if (!desc) {
+			if (i == 0) {
+				dev_warn(chan2dev(chan),
+					 "can't allocate any descriptors\n");
+				return -EIO;
+			}
 			dev_warn(chan2dev(chan),
 				"only %d descriptors have been allocated\n", i);
 			break;
-- 
2.30.2


_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2022-07-05 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-26 13:51 [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Michael Walle
2022-07-04 15:09 ` Michael Walle
2022-07-05 12:48 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox