Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1530900rdb; Mon, 2 Oct 2023 12:26:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeViNGpqrjMNjaTayZJ9cG+mh/W8F3FrQYqwIa30BFiLiaNgy0KYCxYSKUIBKD0qbsWf6+ X-Received: by 2002:a05:6870:b526:b0:1dd:5857:e28b with SMTP id v38-20020a056870b52600b001dd5857e28bmr12800028oap.23.1696274772564; Mon, 02 Oct 2023 12:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696274772; cv=none; d=google.com; s=arc-20160816; b=ceggQDUyN5udUe4FSDxwdiEwOeLaVA54JVGs1ua9R8vthE1uwcB7i9/PtVVyAtpbaU 3H06kFk27t7hEa92hvZKCYe6YpeMf0uQYhVWdlRc7vJfq9kbxrPI6JqHHloU8rAO9w/K xgHvLk8du5CSC/KOcl75peD1cV5/V3SAhvc+q9ryClD7nUsFc7xp9GodPlEh61dG5FbI HyQPS1tRilHk8ZkgZoZeMmUK0aIzbDsRleEFfB9H+5dhin+NhxaszQaXhnmBQOpCW8pI xeEW7yLW/IngPJ/YCx4uHEhKaZc+/J6Uqu8jP1KJlG8py7Qu6H79gKKbs469J0ornyXT 4REA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i7v32YcvbtKkSJ6srCUo4fO3a6wW8xsgEHf4MdRd9fI=; fh=3Wij1Nyq0kk9iFJBGjsMqOGfirL0oXoeYA+XKMkEeWg=; b=bqPLLzpH7jLlrdZ+FNjfP0dFhlHDFVQuffYMtny2JNu9YME8QmPcRki4Fv0y/MEIML YAbVdNMlKD003BbPEtghAgchse13Tn2KGExrbN3J9ERfQB6QV63Qkp/Ud/DV5TgrqpGb vkHHMobPvAULNRB71cQBEF9i1FVcvMceCBSZqTRRHS8lNXmmvARmGlpXRpBp7Z19s0ME R4DVX5LpgXQ6DhZZDl1TrQq1L3d8SdNh8q+kw1UACU3BkDtBUEOxAenUdQOoxA4UhjJI l+yCsdGWrwY2xB1lCQab6fAIqNDQg69gbFEvZX72431pR/aBqFIACR9ZEmXqkbD4d6y7 Mgow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Jv8P35xM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i65-20020a636d44000000b00578bacd7fc7si28908332pgc.713.2023.10.02.12.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 12:26:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Jv8P35xM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 52DDA8036E9D; Mon, 2 Oct 2023 06:18:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237334AbjJBNSE (ORCPT + 99 others); Mon, 2 Oct 2023 09:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237359AbjJBNR6 (ORCPT ); Mon, 2 Oct 2023 09:17:58 -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 92DF6D9; Mon, 2 Oct 2023 06:17:54 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 78A041BF211; Mon, 2 Oct 2023 13:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696252672; 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: in-reply-to:in-reply-to:references:references; bh=i7v32YcvbtKkSJ6srCUo4fO3a6wW8xsgEHf4MdRd9fI=; b=Jv8P35xM3G4fXx7JgcG2Da0TXIVsgzHvLMfuRfHn/jbHcHUi4gQrgW+ety+Vpty+xxh1MF BdT9SzwYIQG/IS1beObVyXa3lSu7QvWDXJtzvfOQh6vWXzIQ5h7jYwPp+kKAdU++uXs690 LiCYnrvnYfOA8v5a7ig+jyUjnJP2xNRAuqkiTgqGxtN3aVLyO4tKcTeCyJ7upUc61a6SNx aFzHd6M2Ejd481iPcyCDwbesZLMfk7uZJF6IkgVZXsqM6cilX7dk9iwAQlGXaYyJz6Busk MNixVt1qBTx4Y9GmEwU2fgQmf6E6nLhV18WPg32126x1k0Yu4ig78JN2L4mF/Q== From: =?UTF-8?q?K=C3=B6ry=20Maincent?= To: Cai Huoqing , Manivannan Sadhasivam , Serge Semin , Vinod Koul , Gustavo Pimentel , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Petazzoni , Gustavo Pimentel , Herve Codina , Kory Maincent Subject: [PATCH v2 1/5] dmaengine: dw-edma: Fix the ch_count hdma callback Date: Mon, 2 Oct 2023 15:17:45 +0200 Message-Id: <20231002131749.2977952-2-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231002131749.2977952-1-kory.maincent@bootlin.com> References: <20231002131749.2977952-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,SPF_HELO_PASS, SPF_PASS 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 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 06:18:14 -0700 (PDT) From: Kory Maincent 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 --- 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 --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++------------ 1 file changed, 5 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..3e78d4fd3955 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -65,18 +65,11 @@ 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