Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp2001644lfo; Sat, 28 May 2022 13:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTxiFsaf4wNQw9/ao5k0oRMftM2UvhMTpnZEUFxbRSyqLxH+qTQYwD+qlIMtnpamNOyqG6 X-Received: by 2002:a17:903:209:b0:161:7f66:b9e0 with SMTP id r9-20020a170903020900b001617f66b9e0mr32775754plh.73.1653769475176; Sat, 28 May 2022 13:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769475; cv=none; d=google.com; s=arc-20160816; b=fYilC97KEoGWy6FjfJD8RHTucq9w95t0TKdPXECTK1ynOcgOSb+0e/PXpSIVN0hA2g dr1JHnCljafdGPoy1gVEx0IiPNzbR3SNylFE9ZguyhUIhZIqIRYq6n16CPq6JvNT2Hbj I559s1iB1NzuHShztavGZUcARY+8x8rnPfJuP+ArhvZYlmN1686JEf+zjV4YeZPT1u+Q W7MYWzAByU4o+SjkFGiPFiWw9fAskzhvlhT1hvLf7yogQamkRJgCsb3lPc/Pw3ZX8Nc/ vlx5qISvMyLeDIGf/gS4fpaGZ2hOoKBKrVZt+bwjaVuVa2dvKXNmUsi9hB/oJQe6m8MR u/SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hDfeXGLxT1ATlD4gcVOQndFKZO4YnK6PdKkSbYlL/Og=; b=V0iEOprUUAJTaportU5nLmT+in6bMU1zEkno308UOTRGRmnL9ydLqF3A3vwL+cfbTT tKqBoana5JC6FGK9C4CyOsFTiGaIHKMus+atQ3BBxkZQjqOWvxuQD9WI+s3EuqjmBLTl U9XbVp3SQqwuf+WZBtbEimybcTN5nO/TZiqIMu4EVWaQ8TLSYLcQXTAfoHk4P65B1tMJ cy1cGmmgiohpnMLlVHGefIZzVRrrf8caoPlVAfYW5NSMolOpiqMRjFdA6UO1ZvFc5l4i XwIZYV55yd+0gVrkk4ahg9D3iMCtWBdoLGV6hdG3RY3mQX2vCdDp1Oz2iMfSDi4KkmKX zqDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=CCpFv7RW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j9-20020a17090276c900b00161d28c3907si9138840plt.8.2022.05.28.13.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:24:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=CCpFv7RW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9FFD516F939; Sat, 28 May 2022 12:31:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345411AbiEZNvd (ORCPT + 99 others); Thu, 26 May 2022 09:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233900AbiEZNva (ORCPT ); Thu, 26 May 2022 09:51:30 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC8B1D0F1; Thu, 26 May 2022 06:51:26 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.30.2