Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp403464rdb; Fri, 17 Nov 2023 02:04:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPs4FdQBdQbQ5SsPQ5ZC47FnrTW0gkQjd9xDmsYkkLxAyJWkPrCksrpHXph8RCwml8yO++ X-Received: by 2002:a62:ab0c:0:b0:68e:3772:4e40 with SMTP id p12-20020a62ab0c000000b0068e37724e40mr15466952pff.3.1700215463723; Fri, 17 Nov 2023 02:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700215463; cv=none; d=google.com; s=arc-20160816; b=dkY5rk4Y4EnYkoKVTJIxpYg8YgaDjLSZYKxx/Twa1ngT0BwIf7peNP+g5uMoJejgRt XWALeZ53kGO0Ou7aQQe6WBuz3pgZFtCyJJvJXCu/DIk9DP3sPSS/U6TCICE/raMRWHYm LxyIIi8Fz/lGH9EZiXEa1Yx0qyRfkyts169WszBMoh7Q+E9WUJXICQ0Ww7xga6nJvsO6 i4aWumCPEKJ4owHLXWiljsBR2tEO0CoABEod0fPwctHGKfzKPLrvdDV+t4nwgW05e0vv oMPtr8pJb2s8XbsC3MSrERWYiAZy58WSMhoNjMgeVkbrn9USB8oQrG/EyzMaWFNDPFkH JHSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=MG/EpR8bVcQceln2f1UmgAvAjO7ip8LLXAJEWchyMuQ=; fh=Fko32OqwGgI5WpcqYpp5KigXgtelsKMiigtnZERCGL8=; b=0iBFxDrppTLNH3muAGodqMV/uwJYN8zilgaJHpx4Xe0vX5GlaCpTK/QKuKGEIsayJz pKMIIvBB5cO0LTJwD1+K1KKFtoVsiWVd4yQP4C5+i0qAsns6wBO1Kj4NIzzXV0mRJY9J kFGyim/reKODo7Zw07Ows7zp4nbTD6GZa/jJNeSQ1+wuCaPNzPGoj7mVQjL1ZGyJ43T/ G9rucor8yHz/FxjAymVF/hkR4EtRUxXS4skeKTrUqWT2aNke55Y8/gtJXYftFdIkcC+W qLUgONXL8HqNEDz4hx51hB3SBdQRy3q2XQHpXZzEK8y9dGLjUzA/kCw01aJ+oqvuxgrf rHoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=p3UZahcB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t13-20020a65608d000000b005be1ee5beb7si1442387pgu.534.2023.11.17.02.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:04:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=p3UZahcB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 65E49827006E; Fri, 17 Nov 2023 02:04:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345829AbjKQKER (ORCPT + 99 others); Fri, 17 Nov 2023 05:04:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjKQKEM (ORCPT ); Fri, 17 Nov 2023 05:04:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188ECA9; Fri, 17 Nov 2023 02:04:07 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2DD6EFF81D; Fri, 17 Nov 2023 10:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MG/EpR8bVcQceln2f1UmgAvAjO7ip8LLXAJEWchyMuQ=; b=p3UZahcB5fPC27GIKBJabXO5yGHhpl+kOie0qlM7j1CpkzJyrQcOTgUyIeLo+dxwDCc8LJ wcIFqOwpqlsYXCZyC3le3j3IOn3+s3fBImDVtTnQ41iadU/8lxdtZZg4CnP8Mlg/8xvzIV gm9Ay9vzq98L1n6juEMCyLaOuGAe6XrCsCJ+b3llcTKwoyvmoeFRxxSQOZ/MoT8f3dtPVR 3zv1QPyoW0I/ySSr1IdJsaah5IkVDd5upVx/KnT7jijLnsi5M917oLCG8nefH7qc/R+JBt eWxxxA2FMtg4ejttruB5ZA8bpXRBqe4TgSxsKmm9N6PCNLxgQsvBQ11F6j7Ekw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:49 +0100 Subject: [PATCH v6 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231117-b4-feature_hdma_mainline-v6-1-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> To: Manivannan Sadhasivam , Gustavo Pimentel , Serge Semin , Vinod Koul , Cai Huoqing Cc: Thomas Petazzoni , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Herve Codina , Kory Maincent , Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 02:04:22 -0800 (PST) The current check of ch_en enabled to know the maximum number of available hardware channels is wrong as it check the number of ch_en register set but all of them are unset at probe. This register is set at the dw_hdma_v0_core_start function which is run lately before a DMA transfer. The HDMA IP have no way to know the number of hardware channels available like the eDMA IP, then let set it to maximum channels and let the platform set the right number of channels. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Acked-by: Manivannan Sadhasivam Reviewed-by: Serge Semin Signed-off-by: Kory Maincent --- See the following thread mail that talk about this issue: https://lore.kernel.org/lkml/20230607095832.6d6b1a73@kmaincent-XPS-13-7390/ Changes in v2: - Add comment Changes in v3: - Fix comment style. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c index 00b735a0202a..1f4cb7db5475 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -65,18 +65,12 @@ static void dw_hdma_v0_core_off(struct dw_edma *dw) static u16 dw_hdma_v0_core_ch_count(struct dw_edma *dw, enum dw_edma_dir dir) { - u32 num_ch = 0; - int id; - - for (id = 0; id < HDMA_V0_MAX_NR_CH; id++) { - if (GET_CH_32(dw, id, dir, ch_en) & BIT(0)) - num_ch++; - } - - if (num_ch > HDMA_V0_MAX_NR_CH) - num_ch = HDMA_V0_MAX_NR_CH; - - return (u16)num_ch; + /* + * The HDMA IP have no way to know the number of hardware channels + * available, we set it to maximum channels and let the platform + * set the right number of channels. + */ + return HDMA_V0_MAX_NR_CH; } static enum dma_status dw_hdma_v0_core_ch_status(struct dw_edma_chan *chan) -- 2.25.1