From patchwork Thu May 26 13:51:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12862442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 156F9C433F5 for ; Thu, 26 May 2022 13:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hjY7JWdcgsVdjAaop2oU7v7Aa9T1H60TTRCzF5AKabo=; b=2uP/6gAOz3bfW1 qQPivTprAo8JG+oUT3ueBDWQgY15A2vjEpqIHqACeZY6FhSYEwML70W1G94etfWTFTwBhgz9zQXN8 yzyBWmjROYlACdz6CZLohgErV+cuf5tZ1YihyVXvE2Vz+QNFgbTA+N2AQhwjme3jLv3s3C2H2hPUf mnaVFkZSdmMNqWvYBplG/ptWavUwcE9yMtTnuZKkF1J1VwtoSyTmGxrHeuHZipk6ZhtDnuWCsHySF Yb7ZfzqE7VLBQZEXGUcaiZ3NblwiHJi/e5oOnDPgYHLshi4mStkFnwON2SAZgFnXj/mj9dnKaqbA+ WRx6cTYweOToqBSlpW3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuDts-00F4Lj-Se; Thu, 26 May 2022 13:51:40 +0000 Received: from ssl.serverraum.org ([2a01:4f8:151:8464::1:2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuDto-00F4Jy-R7 for linux-arm-kernel@lists.infradead.org; Thu, 26 May 2022 13:51:38 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 242DA2223B; Thu, 26 May 2022 15:51:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1653573084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hDfeXGLxT1ATlD4gcVOQndFKZO4YnK6PdKkSbYlL/Og=; b=CCpFv7RWHTo3w7QRPFcEETAptNX4XXn7LP2Vu8rfu01uYdu+SbF2G44dTPWil5zt1+P0lM Upbf3ZQ3XdvLaAwwBIt60PDyyBv+SuauAv5aKWY1Guk2i5HM43gj+8PnMNtWmGTQcGKfHa axdBgMTsDObYND+xqaIMgYxfSX1Fpts= From: Michael Walle To: Ludovic Desroches , Tudor Ambarus , Vinod Koul , Nicolas Ferre Cc: linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Date: Thu, 26 May 2022 15:51:11 +0200 Message-Id: <20220526135111.1470926-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220526_065137_085607_80B0D42A X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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;