From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9728EC4332F for ; Tue, 14 Nov 2023 14:52:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbjKNOwP (ORCPT ); Tue, 14 Nov 2023 09:52:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233462AbjKNOwK (ORCPT ); Tue, 14 Nov 2023 09:52:10 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 072B6122; Tue, 14 Nov 2023 06:52:05 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3735E240016; Tue, 14 Nov 2023 14:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973524; 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=l5h/4CDAZVV5CoIlDpdVV6jLbP0J4DWNgbBA/qnRgpSxqda1WfnLl89euNEhdfwBUDOMG3 aPgSR8ubD1TvbGfsz39HZSrz9yfmAsikpDgdfuKdhHl+VNQIQ0aXJzaRWVqSiaO6+ZdGGp O9kQkY47IV3NUClmmX5kT5yKEnGhDL86YksknaXDT6DwQJcRjd+WjSa8PKhv9ph3NvkPlB CkSqSnRn7VzmxYL50NNdmLY6doiLojnqor7609PKi9yK2k8iK1IkZGEkQsXTOOiYKdcULO AN4AvYud2IaxP2Kj0O8uIG5oJhOF7RVgMfOMby5TPp/dGHZcf9qfHNVUZKj1nw== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:54 +0100 Subject: [PATCH v5 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: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-1-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) =20 static u16 dw_hdma_v0_core_ch_count(struct dw_edma *dw, enum dw_edma_dir d= ir) { - u32 num_ch =3D 0; - int id; - - for (id =3D 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 =3D 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; } =20 static enum dma_status dw_hdma_v0_core_ch_status(struct dw_edma_chan *chan) --=20 2.25.1 From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3C48C4167B for ; Tue, 14 Nov 2023 14:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233512AbjKNOwM (ORCPT ); Tue, 14 Nov 2023 09:52:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbjKNOwJ (ORCPT ); Tue, 14 Nov 2023 09:52:09 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52189126; Tue, 14 Nov 2023 06:52:06 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A3D59240003; Tue, 14 Nov 2023 14:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973525; 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=9zfuTvre0UzAi4GpamYmN3E9uemUolgHrcnYVxe0/6o=; b=WYk2bi0RayS5KdrXFqbBs1ZUT9c5Dp0Ig/yyDAl+rGqTB0JGPqachk9W2nn3szazQliexh bJu4e+X7001Ndf3IAj2ulsFJoD+/h2Mr3OzLL8CNMtSVk8kx1VanZDTwjyPgIcoTKiQ46Q zddanlA29ytFqh6mN/fXTdq/iI1lfq2HfgLyDtO8MwREiWpc3C52OupHDWcrfrRqRySEk8 HJzevquDlmD3osMZ2ChzrpwPLbIRlR7YObCAFt8aOF3O55P1+sKkaHcNu4ANYei6B/jldt mzu6Q2h93Q3YOj6sAHbNj6hRRqHW9qrbqhyR8xXGFZcQuam3c3iudq7sQYKSmg== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:55 +0100 Subject: [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-2-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix "HDMA_V0_LOCAL_STOP_INT_EN" to "HDMA_V0_LOCAL_ABORT_INT_EN" as the STOP bit is already set in the same line. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- Changes in v3: - Split the patch in two to differ bug fix and simple harmless typo. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index 1f4cb7db5475..108f9127aaaa 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -236,7 +236,7 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk = *chunk, bool first) /* Interrupt enable&unmask - done, abort */ tmp =3D GET_CH_32(dw, chan->dir, chan->id, int_setup) | HDMA_V0_STOP_INT_MASK | HDMA_V0_ABORT_INT_MASK | - HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_STOP_INT_EN; + HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_ABORT_INT_EN; SET_CH_32(dw, chan->dir, chan->id, int_setup, tmp); /* Channel control */ SET_CH_32(dw, chan->dir, chan->id, control1, HDMA_V0_LINKLIST_EN); --=20 2.25.1 From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A245DC4332F for ; Tue, 14 Nov 2023 14:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233546AbjKNOwS (ORCPT ); Tue, 14 Nov 2023 09:52:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233473AbjKNOwK (ORCPT ); Tue, 14 Nov 2023 09:52:10 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D527912A; Tue, 14 Nov 2023 06:52:06 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2A164240013; Tue, 14 Nov 2023 14:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973525; 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=iPCuxXS6fiLAq+ZD6dKRSHgB+AgJYpeJ58Nq57Fi1fk=; b=LTi65E4Tlircxae7M6pf96+eWA6ie+/jpuEiLF891xQxSMoGf7b2b2dRtvl9+ET3M6ro82 m11cQHytfNvz6x+v6P+Rrn10m2FWjqm8oVRtWwQdOHopBNp2hTMw7cA39S7Drpije9NeYD UpMx4MYp+wbAxCN7K0ELXHXT+fBOWTEsjPqzdifAnBxUXzwq66/9n1fazUep9MOueXN4LV kq0lDF7Diwc9r9nfLYjhOSIr2qpRBV+yYNFG75ntcZBSul27yjQBhxv1B2anuDbsEezJC3 4Caz1BnFpW/QXYlx/cbcUf1/rbgpcUQihIXWHLFYlGHR3RB1G81//ORU+83Enw== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:56 +0100 Subject: [PATCH v5 3/6] dmaengine: dw-edma: Typo fix MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-3-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- Changes in v3: - Split the patch in two to differ bug fix and simple harmless typo. --- drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-regs.h b/drivers/dma/dw-edma/dw= -hdma-v0-regs.h index a974abdf8aaf..eab5fd7177e5 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-regs.h +++ b/drivers/dma/dw-edma/dw-hdma-v0-regs.h @@ -15,7 +15,7 @@ #define HDMA_V0_LOCAL_ABORT_INT_EN BIT(6) #define HDMA_V0_REMOTE_ABORT_INT_EN BIT(5) #define HDMA_V0_LOCAL_STOP_INT_EN BIT(4) -#define HDMA_V0_REMOTEL_STOP_INT_EN BIT(3) +#define HDMA_V0_REMOTE_STOP_INT_EN BIT(3) #define HDMA_V0_ABORT_INT_MASK BIT(2) #define HDMA_V0_STOP_INT_MASK BIT(0) #define HDMA_V0_LINKLIST_EN BIT(0) --=20 2.25.1 From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 921AFC4332F for ; Tue, 14 Nov 2023 14:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233535AbjKNOwV (ORCPT ); Tue, 14 Nov 2023 09:52:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233490AbjKNOwK (ORCPT ); Tue, 14 Nov 2023 09:52:10 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F603CA; Tue, 14 Nov 2023 06:52:07 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9D8CC24001A; Tue, 14 Nov 2023 14:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973526; 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=svngh7gavoOsAoTd14KvI+aVm1JHod9n5Mvh72UXNZY=; b=l093DY4tY3uYI0h8I8HZT0q/eiUFB7NuJDDOQ8GuICv7vwFR5tDyIfaJCHrndUqkgXHBTW /Vra+Ug2i9GUHE/tyxWKJVHao/NfRCnQNu3L9Nm6YmFiDGKHZuImP3+zFB82qDaThoiRX3 2zdp4Gcf8OMYREUS6RQwITSrPrcL9aQJkCnEKwKPgmQ3xzZbU3x2XIzS26emBQ6xXWsNc3 IRkC9VUTojkXiifW+1RtQipJd1CkZpYLuMkS7kzZrTNoJRJv+wX6gu6tkPDl8FZ7Ynskzf Bx53oQxWb1PxzhVFMGPA6XGqLmmtUEUO4ncriX2cV7oTYxNc7VuPZhJyd1TQKg== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:57 +0100 Subject: [PATCH v5 4/6] dmaengine: dw-edma: Add HDMA remote interrupt configuration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-4-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only the local interruption was configured, remote interrupt was left behind. This patch fix it by setting stop and abort remote interrupts when the DW_EDMA_CHIP_LOCAL flag is not set. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent Reviewed-by: Serge Semin Acked-by: Manivannan Sadhasivam --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index 108f9127aaaa..04b0bcb6ded9 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -237,6 +237,8 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk = *chunk, bool first) tmp =3D GET_CH_32(dw, chan->dir, chan->id, int_setup) | HDMA_V0_STOP_INT_MASK | HDMA_V0_ABORT_INT_MASK | HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_ABORT_INT_EN; + if (!(dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + tmp |=3D HDMA_V0_REMOTE_STOP_INT_EN | HDMA_V0_REMOTE_ABORT_INT_EN; SET_CH_32(dw, chan->dir, chan->id, int_setup, tmp); /* Channel control */ SET_CH_32(dw, chan->dir, chan->id, control1, HDMA_V0_LINKLIST_EN); --=20 2.25.1 From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E998AC4167B for ; Tue, 14 Nov 2023 14:52:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233575AbjKNOwX (ORCPT ); Tue, 14 Nov 2023 09:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbjKNOwL (ORCPT ); Tue, 14 Nov 2023 09:52:11 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB7C9114; Tue, 14 Nov 2023 06:52:07 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 27E2B240002; Tue, 14 Nov 2023 14:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973526; 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=3Qhez83D04lqPrphmv+D5bpPc2p/1oEARmA8MsTrJgs=; b=CcEo/VcSTQOJAj9E1r+SviFWQrmQe/uQ1bUTGRXUw9tnNqVDTVS/+/DJglKUGWhyKMw+yp A6pR4z9sY41YQaqS6CRNz9TL8RmR0ydk2/totJWn2buXEm02HrTmF1ltG4TaLijMqJRcgk eYG/nLbq80vgWTi3lbps/oNhtfkoniL99qQswCdpcazDV5aRMDJj+TljqxNYdLssssT6bk idFVJVO8ZfiAxG+M94gnFBGqW/rt8VoGvM2vt1F2YDXs/YV+A71VPDk8ROLnuw+DYXX9RK sMMRLfPNEVtbbElolJlk0Ae9jHR19PlTmpZncJzfStYDpC6LZ2P3WWn1Jz4AGA== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:58 +0100 Subject: [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-5-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Linked list element and pointer are not stored in the same memory as the HDMA controller register. If the doorbell register is toggled before the full write of the linked list a race condition error will occur. In remote setup we can only use a readl to the memory to assure the full write has occurred. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin Signed-off-by: Kory Maincent Reviewed-by: Manivannan Sadhasivam --- Changes in v2: - Move the sync read in a function. - Add commments Changes in v4: - Update git commit message. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index 04b0bcb6ded9..13b6aec6a6de 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -222,6 +222,20 @@ static void dw_hdma_v0_core_write_chunk(struct dw_edma= _chunk *chunk) dw_hdma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr); } =20 +static void dw_hdma_v0_sync_ll_data(struct dw_edma_chunk *chunk) +{ + /* + * In case of remote HDMA engine setup, the DW PCIe RP/EP internals + * configuration registers and Application memory are normally accessed + * over different buses. Ensure LL-data reaches the memory before the + * doorbell register is toggled by issuing the dummy-read from the remote + * LL memory in a hope that the posted MRd TLP will return only after the + * last MWr TLP is completed + */ + if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + readl(chunk->ll_region.vaddr.io); +} + static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first) { struct dw_edma_chan *chan =3D chunk->chan; @@ -252,6 +266,9 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk = *chunk, bool first) /* Set consumer cycle */ SET_CH_32(dw, chan->dir, chan->id, cycle_sync, HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT); + + dw_hdma_v0_sync_ll_data(chunk); + /* Doorbell */ SET_CH_32(dw, chan->dir, chan->id, doorbell, HDMA_V0_DOORBELL_START); } --=20 2.25.1 From nobody Tue Dec 30 15:03:22 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85E85C4332F for ; Tue, 14 Nov 2023 14:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233598AbjKNOw1 (ORCPT ); Tue, 14 Nov 2023 09:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233497AbjKNOwL (ORCPT ); Tue, 14 Nov 2023 09:52:11 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAE1181; Tue, 14 Nov 2023 06:52:08 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 919E5240014; Tue, 14 Nov 2023 14:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699973527; 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=Njx3NaGKWu808jS2rM/MlNFciYIn5u1xCeEnktSSeyc=; b=o1u43gWsw//1Ii7k+NR1KGDSUTt45keYRcjX7yDasFcLfK3YLnvA4/JcEFfwjFKugypt3Y DHXBZo/jRAvoB2wHpDYYIkGkfH/sStZm3ChEUzHn4u30dt693atc/k8OBPUNBAcPpk5xXS l/NhE9sHEnS9fEvDKUUc2IsLI+WoYgh432PSGfLTHGIg+LU7Tuaf5xiD5ArJu2yEZ3xYJE lIfrMG7nuqyLyXcG8Qi0U7M2eJY/OUwRGEBbnscU68RJ5tojRSTAPLf7jntB0S+6W0Hhgc xXd1/YhidQ2FKLfiFJx4mLVPErCkU7dH/gRpLIy2OH8cs9L8eh81YrA/lgGuQQ== From: Kory Maincent Date: Tue, 14 Nov 2023 15:51:59 +0100 Subject: [PATCH v5 6/6] dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231114-b4-feature_hdma_mainline-v5-6-7bc86d83c6f7@bootlin.com> References: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@bootlin.com> In-Reply-To: <20231114-b4-feature_hdma_mainline-v5-0-7bc86d83c6f7@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 X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Linked list element and pointer are not stored in the same memory as the eDMA controller register. If the doorbell register is toggled before the full write of the linked list a race condition error will occur. In remote setup we can only use a readl to the memory to assure the full write has occurred. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Reviewed-by: Serge Semin Signed-off-by: Kory Maincent --- Changes in v2: - New patch Changes in v4: - Update git commit message. --- drivers/dma/dw-edma/dw-edma-v0-core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw= -edma-v0-core.c index b38786f0ad79..6245b720fbfe 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -346,6 +346,20 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma= _chunk *chunk) dw_edma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr); } =20 +static void dw_edma_v0_sync_ll_data(struct dw_edma_chunk *chunk) +{ + /* + * In case of remote eDMA engine setup, the DW PCIe RP/EP internals + * configuration registers and Application memory are normally accessed + * over different buses. Ensure LL-data reaches the memory before the + * doorbell register is toggled by issuing the dummy-read from the remote + * LL memory in a hope that the posted MRd TLP will return only after the + * last MWr TLP is completed + */ + if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + readl(chunk->ll_region.vaddr.io); +} + static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) { struct dw_edma_chan *chan =3D chunk->chan; @@ -412,6 +426,9 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk = *chunk, bool first) SET_CH_32(dw, chan->dir, chan->id, llp.msb, upper_32_bits(chunk->ll_region.paddr)); } + + dw_edma_v0_sync_ll_data(chunk); + /* Doorbell */ SET_RW_32(dw, chan->dir, doorbell, FIELD_PREP(EDMA_V0_DOORBELL_CH_MASK, chan->id)); --=20 2.25.1