Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp493291rdb; Mon, 29 Jan 2024 08:26:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IE78alUMIWx5/ys4/V+3GpqxTTJ9tpMe2lvJkG6rrv1UJ8AaAJa03TzxWdzQFQYA42ADecO X-Received: by 2002:a05:6a20:8b9c:b0:19c:a2bc:d1d9 with SMTP id m28-20020a056a208b9c00b0019ca2bcd1d9mr1672870pzh.55.1706545577148; Mon, 29 Jan 2024 08:26:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706545577; cv=pass; d=google.com; s=arc-20160816; b=YsWJQNEa9I6sRseKX6fAZXqMydRQao9fucXY1OFSd3X8vyE5YU22HBgid++x9XcqyP XaeudFtjdqZdndmJtuwmQHtREF/hNBQkfSEdWVjhrKH6AkUjZF4cFNpDfc0jiFMvrBoD wYnrciT13x76XABFkgsyPQ1shS4KTvZKrV/NIGMg/Ync5r58xLB0m5RDPhEA5gqoMwek xYjO/YncPZMafbYa9TaV2jkGalIsKd0sOIdCGnzqOeZ1xso2HNdq5NbWWRO1GUoDb9Zg Gq2UpcsHCu+Pzx0xRZ8nRYg88H31xj8fJnwC3yhaHB6PV+FdrKvX3fyrR7D0rXlT0e6b yAkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=MG/EpR8bVcQceln2f1UmgAvAjO7ip8LLXAJEWchyMuQ=; fh=oC1+pIJR2tZdBb9Uzp3yLjqrVYle+8srf2TBxoXLW2Q=; b=XbYgqLNJdkzvaERhY7Sp1/9nxbRm2ymZFp4CvKLV3a8oRy6djZ/fI845HncbKvlkXP gj8v72YDFsczZvwbwuouQaeD2C8WT+gMmXV7Z+z2Md/KHA2PoEAwg/VoC29waPMTzJwo TS2v1zHPP4+0YBQXSyyzUitPIr44dMe9tV2DPEn+z7C4f2GejDC+GM+H2+etGx4rtGB9 PYQcmMHq4J/jjYjAkHNQSlWKrSMAJt0IGke1T9oevhIwQe9+nwcCaxiTckxoAjpnVZYo 35/89k0SguneG3AGEudPxBiEvmrjn5QZv7rf/DJ1a5qzZ5sw/r7pg1nnKnJNg5oeAO2g Vdag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=eaCrbU3p; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y6-20020a17090a474600b002908a478c0bsi7963740pjg.145.2024.01.29.08.26.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=eaCrbU3p; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC31F281CD6 for ; Mon, 29 Jan 2024 16:26:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF1FD156965; Mon, 29 Jan 2024 16:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eaCrbU3p" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 038EB155A5D; Mon, 29 Jan 2024 16:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545570; cv=none; b=LkUkhrYn0sl6iOfCs2syUkove7ZBLCQutOOmmT7l/kcMZjSJXRg4GiBgk2kSB9sYpTWIfVW2rufmuaDDq4naB8Q1ZzM7f/7+kFH0Mvy8POQeE/nABT4qYuNt/WcA9TnOV8N5vqHV7PNQuMFZOrFFqP2lMrAmq/BHdObIM3y+Y8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545570; c=relaxed/simple; bh=C4sO6yQ/bq+76ak3Oo81L+OU1zOyCbXoSaUNduyzz0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UujnTPFLlWYYoaQagXbymBN33+nU7O7QmEQRfm5qIR5lVh+L4AiydmM79qcmSjp4EwJi+bBNv5PbOpShI8V9CVgKZB3SR8L7Uy0hF0T/2+Lbq5OBUdSk2InNI8J9/N5g9KYg91lLqNEYZ8WiyPYlze/5VJRmah5d1egjx2VAqvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eaCrbU3p; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id CE5D6E000B; Mon, 29 Jan 2024 16:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706545566; 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=eaCrbU3p0Ll8pLp5KtMk2BFOFJrF8vRmqnxFUveVuzaMIo98Vc8yFYPvXEP45wVKgDA5t0 GMJpqeW+mAXtNOjM0kB5EgoMyKt25qIgy/iEVcZOubQT+xYj+ncWFTea7HVNNLsODqe4fQ ucA8h6kEvzxQXb5VP7SqmxaTAWO5qJCl3PecS/FQknYgIN7PZ/0irfiWYjhkYOBWMj/JDW hX3CF8BSjYDoWPGjyYNH7DU3nlx4kQl3rJF0GUArrJs/yVRXz+NJtlwBP+eTLbPrIS5Rys rwhH72vGdvY09mhERXcs3Z3b3y6wZ5ZoFeY49QkP9SlEvw1EfXVNiacg0VbhHQ== From: Kory Maincent Date: Mon, 29 Jan 2024 17:25:57 +0100 Subject: [PATCH v7 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240129-b4-feature_hdma_mainline-v7-1-8e8c1acb7a46@bootlin.com> References: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@bootlin.com> In-Reply-To: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@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 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