Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp650354rdg; Wed, 11 Oct 2023 01:12:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe9filgaSMOm9tPUbZAfwtPIk5TbR+f3bQKyDY/xVKPq0FlGObSOjwnDz2C1W18Y6C1BDs X-Received: by 2002:a05:6358:278c:b0:143:8084:e625 with SMTP id l12-20020a056358278c00b001438084e625mr21751643rwb.11.1697011971439; Wed, 11 Oct 2023 01:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697011971; cv=none; d=google.com; s=arc-20160816; b=ENUzjwgEJJ8yMI07IS4XeUFjzJmjR8Rf2Iufx8YJR6jZhV4KP9rLMtwjWa5dQDe0Oe 293QqUp8VY1oXEQz6REB4fJumv2BSu1w4bpqCKMVMrqZfkLYpFiXdYVco1jyPgWLL+5h IWoEQePLI2xbqAoPQBauFwUe6NgWXRhue0/WIQXHbmrr95sUZBEltKDG2gjKKqhKSlIg WoQYLLywFXuIJq6UV2X3ycHxh3nxPsBZk2xwi9Fc+0fvSivmcpO8SCK7iRtxum/dGXIv 8AD+926wVzGEN/Ls4d0IWRh+mD0j1KRbPM4b7+XjlkfQ5+Yg6FBz5tABM3sBJabPxkoX ymrg== 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=EOZ53uDlJRud+RSY+ah8ZS/rh8udoyM60w7XsdTrQ3A=; fh=Fko32OqwGgI5WpcqYpp5KigXgtelsKMiigtnZERCGL8=; b=BlVEdgjR3SzODJ/L+5W89DYqvfZy7nB8wueYJREBiRdp/J76yfPcXM9W/0cNjXE/cN fMEUojocsCA2M80G/x7+gXwZE7mJQsCZJJfpSZ7BkWI35Vu54M1gnHdPmLWCKnptb4UE z1EFNnmZ97afks3WYeP+tW+jjMhvk0AO3eoBQV3K2RFLCnBHlklefxi8TA5CLZPfJ/+o tU7YsxW0cFOv+MUe+7bgjqaaRMCkPA7P/IIsek3xxfjzr+Vb2AEsqNppDsPnFroOmN9k enw8vN2N9a/woSY4wAiyVqFflN0amPU6gGtYN4S2plyXWS1qVbC/gF+a/CQCuXP5E4Lo xTaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ULdnuIEf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fb40-20020a056a002da800b0068fbb75adedsi11937003pfb.127.2023.10.11.01.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:12:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ULdnuIEf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 4A70F801B6C0; Wed, 11 Oct 2023 01:12:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbjJKIMe (ORCPT + 99 others); Wed, 11 Oct 2023 04:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjJKIMc (ORCPT ); Wed, 11 Oct 2023 04:12:32 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 190929B; Wed, 11 Oct 2023 01:12:29 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9D5081BF203; Wed, 11 Oct 2023 08:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011948; 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=EOZ53uDlJRud+RSY+ah8ZS/rh8udoyM60w7XsdTrQ3A=; b=ULdnuIEfUNsQOGmFVLOpN1K0Mu863utSDvP6VgnV2FwcjDgdsp8RQAT0O287xOj/he8DSX kvfyFcDoEOo4DUldDSq8T6KTBjQv68bYH2igSBePqPWZHIgY95v1Rp1m3njGnlr9O0dezP dwwHiSDY3Dl+uln3PRiAH50LrI1RO71ibZFoRU8I16MlINje9YHBYtyabqhZDkT89hc8y1 OdfL5LsoO4X0kI63RuVx+zf1b28xJAAbfyQZGpoN2qlIYEiT2+AuhSjC1F0jARcABhkdA3 JNG3jdS8ol13Vrfu6UBLg3fXW+uOH2Y0QRd72ugvuAv+9NPAWk5VuljAVG3Ulg== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:40 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-1-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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.3 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 01:12:46 -0700 (PDT) X-Spam-Level: ** 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") Signed-off-by: Kory Maincent Acked-by: Manivannan Sadhasivam --- 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