Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp849944rdg; Wed, 11 Oct 2023 07:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmRr1ZGDiO29pmhz4EBCDDUKlVFk2jhDU6mRejDfzsS34WiAERpXGziaSrEk2zImaWKpyR X-Received: by 2002:a05:6a20:9185:b0:163:9f1d:b464 with SMTP id v5-20020a056a20918500b001639f1db464mr21708957pzd.5.1697033851171; Wed, 11 Oct 2023 07:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697033851; cv=none; d=google.com; s=arc-20160816; b=wWfYDyJgG7QDFLdj8UpqTNX++JKM2aPn7RiELhVURSmoJpWsDX8q24SdcmCSXvCTXU 9vBvdsv8MX1oiHbboFehJ1d8XBDH4zG4AsJmq3Sy0Al+8NVKtL7wFdAfUKWFXoCMPJB5 /3oCue4QB844s0M8nslufXr6ZMosZISRD+XI4yPuzzn8WuBA4o+Z6KAk1idX42dsSMx2 rtK8h3RJ6X0vAqQMVrSedWXTC/whZ0GaXHbiiHb20ElaCmBpfNHr0sE1cLBQqkxZ2iVk xocg4C/47ezhyBi7WR8AtibKbRKNCzpT+jguAoUBgQEpeU34YhMp1gQhyZ0NsRJwAS91 0Sfg== 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=aMwAca7ZnAnSD8CU1CO5CoeUBYV5Kn1hwp1G3dnAI9TvlSdpWSKPUUd/FCgKbedvZE sxT9XSusz8HXUJrcTgZdOlMi3NzNOdTluZi4v4I0E+JjE941hiPoRsdKk28EOBrAIWYF ieXSsgdQI4wVmZay+8Te2RG2Qp7YZtY73EmxRJIWVWdLOKdN+oTqYq3N7Er8P/hG0QH1 891Ek/xNHpc5a/xzGdDEBLfddDK1xrk3dV9HHAhKHjUAFD63qtZqDtAtEuMEsSACYv22 +ZWT/CNl4ikZpeT2Sk70I36Au4RY0A5tfjv+YhBZbkzctG7Yt+dh5lh9Rf+CjbCG7yen KhtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=omBzhJGi; 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 s15-20020a63af4f000000b005a1d8816535si324045pgo.5.2023.10.11.07.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:17:31 -0700 (PDT) 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=omBzhJGi; 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 8D1F98029471; Wed, 11 Oct 2023 07:17:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346866AbjJKORY (ORCPT + 99 others); Wed, 11 Oct 2023 10:17:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235057AbjJKORV (ORCPT ); Wed, 11 Oct 2023 10:17:21 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25004B6; Wed, 11 Oct 2023 07:17:18 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7ED2B60009; Wed, 11 Oct 2023 14:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697033837; 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=omBzhJGiXMkoyMhghh9lOAaUVjCKnPJko9Xe2tYr5QUQn9gEm89glW5nCgV4M4Kf+fjdAj 2MNQ+dVZPr1bBF+EEFw6qK0tW0Zq+S/WgvqpQlwYQ6qZb3IQA9q8GWLe8LELreHjG2Xvs8 LAimgtDlpvBLQz5/RR71tue0F+t+GvuHWQsrklIzBFIKBmK8XP8MCLNCik8+1hRpK6otYR nQrgmYusvkf596qSU9q0Y/lojUUpvcnKjYY7tVABab2KE/ris8OvlHhOjbyI3UHhJtyywT ZAyHI2N5oDVxBacZ+Rscc2nk/Occo0q7lq4lRFK7TXJ/+VmLmG68ZYyG/rCJbA== From: Kory Maincent Date: Wed, 11 Oct 2023 16:16:57 +0200 Subject: [PATCH v4 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-v4-1-43d417b93138@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v4-0-43d417b93138@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v4-0-43d417b93138@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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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]); Wed, 11 Oct 2023 07:17:28 -0700 (PDT) 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