All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Ludovic Desroches <ludovic.desroches@microchip.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Vinod Koul <vkoul@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, Michael Walle <michael@walle.cc>
Subject: [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly
Date: Thu, 26 May 2022 15:51:11 +0200	[thread overview]
Message-ID: <20220526135111.1470926-1-michael@walle.cc> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: Michael Walle <michael@walle.cc>
To: Ludovic Desroches <ludovic.desroches@microchip.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Vinod Koul <vkoul@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, Michael Walle <michael@walle.cc>
Subject: [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly
Date: Thu, 26 May 2022 15:51:11 +0200	[thread overview]
Message-ID: <20220526135111.1470926-1-michael@walle.cc> (raw)

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

             reply	other threads:[~2022-05-26 13:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 13:51 Michael Walle [this message]
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-04 15:09   ` Michael Walle
2022-07-05 12:48 ` Vinod Koul
2022-07-05 12:48   ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220526135111.1470926-1-michael@walle.cc \
    --to=michael@walle.cc \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=tudor.ambarus@microchip.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.