From nobody Tue Dec 30 09:18:52 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 F3167C197A0 for ; Fri, 17 Nov 2023 10:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345832AbjKQKES (ORCPT ); Fri, 17 Nov 2023 05:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjKQKEM (ORCPT ); Fri, 17 Nov 2023 05:04:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188ECA9; Fri, 17 Nov 2023 02:04:07 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2DD6EFF81D; Fri, 17 Nov 2023 10:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215446; 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=p3UZahcB5fPC27GIKBJabXO5yGHhpl+kOie0qlM7j1CpkzJyrQcOTgUyIeLo+dxwDCc8LJ wcIFqOwpqlsYXCZyC3le3j3IOn3+s3fBImDVtTnQ41iadU/8lxdtZZg4CnP8Mlg/8xvzIV gm9Ay9vzq98L1n6juEMCyLaOuGAe6XrCsCJ+b3llcTKwoyvmoeFRxxSQOZ/MoT8f3dtPVR 3zv1QPyoW0I/ySSr1IdJsaah5IkVDd5upVx/KnT7jijLnsi5M917oLCG8nefH7qc/R+JBt eWxxxA2FMtg4ejttruB5ZA8bpXRBqe4TgSxsKmm9N6PCNLxgQsvBQ11F6j7Ekw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:49 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-1-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 09:18:52 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 1CF53C197A0 for ; Fri, 17 Nov 2023 10:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345826AbjKQKEQ (ORCPT ); Fri, 17 Nov 2023 05:04:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjKQKEM (ORCPT ); Fri, 17 Nov 2023 05:04:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3B6AD; Fri, 17 Nov 2023 02:04:08 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id B02BFFF80F; Fri, 17 Nov 2023 10:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215447; 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=FAldIdFOcM6TSQgoc+utZ58ITzn88qsDQysRSDWf7aE=; b=CWRbqMYkcicpcthfaTaZUOscd6Wt623MOsiQdZmUgWhnIc1T6SfQvhnfkr9w3z6sXRvzZg +jSHd2ucjSFwLUtWTWNGpsEnB4irS2FCwHUNlJP6teX085KkgGMNBUVjMvxFIR565ru+la /pdox0q4vBvNZsO9cPSteGHeJrfRWfEQEnVAhODfmwHcOo2ePeGqoeYYB7xoGCz4QHFiBK gCm8GgfaA4CSOPTPjURP8gquTjdy8KBee5gEgBO55CaMj5ckVon35OBdD8YGy4cgr0WlL5 7Smf8QWcZf/zm6gSKw07/HBe6OQ5Y0RoccMolikPqPVtcjPnnIgJbkIqnxK4bw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:50 +0100 Subject: [PATCH v6 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set for HDMA MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231117-b4-feature_hdma_mainline-v6-2-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 Instead of setting HDMA_V0_LOCAL_ABORT_INT_EN bit, HDMA_V0_LOCAL_STOP_INT_EN bit got set twice, due to which the abort interrupt is not getting generate= d for HDMA. Fix it by setting the correct interrupt enable bit. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v3: - Split the patch in two to differ bug fix and simple harmless typo. Changes in v6: - Update commit message --- 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 09:18:52 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 3FCF7C197A0 for ; Fri, 17 Nov 2023 10:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345834AbjKQKEW (ORCPT ); Fri, 17 Nov 2023 05:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345719AbjKQKEM (ORCPT ); Fri, 17 Nov 2023 05:04:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE977B0; Fri, 17 Nov 2023 02:04:08 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 38394FF803; Fri, 17 Nov 2023 10:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215447; 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=Cl2LjMo9y4kvfDVQJV3DM0tMK1TINYKcgigqy6Qohec=; b=RCp2V0P3x9CUu7RYAlP4bUyJuhoBpyrtZtFKsDlc+qoLE942p6cLWUPQpj0Chgvw/U84Rk N7BFXpYxvzqWwh8p/Q6B8sAAHG7VkO+hdA70ZLN+i6WUOijmQw//rFh7T1tA40OgU6c2yp n4PfRgReGy9U+lnkOtX0YvEXVQpgbVE4yXVSUQAgW/DEZsy67gcKNmNjqcUNpb0KKY7wCG LO2v+L22qVI1JLKTuG4sGiw1XEVIzYE4Xv8hubLcv2i72+7J+4Rw5agm+QKiN1PC7qajtw VSGllGb8VvGAThztu1xp1gUbCxsdRUe12HLKjszykKIxy8zoVweJDlcQfUprCg== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:51 +0100 Subject: [PATCH v6 3/6] dmaengine: dw-edma: HDMA_V0_REMOTEL_STOP_INT_EN typo fix MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231117-b4-feature_hdma_mainline-v6-3-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v3: - Split the patch in two to differ bug fix and simple harmless typo. Changes in v6: - Mention the typo in the subject. --- 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 09:18:52 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 0783DC197A0 for ; Fri, 17 Nov 2023 10:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345838AbjKQKEY (ORCPT ); Fri, 17 Nov 2023 05:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345796AbjKQKEN (ORCPT ); Fri, 17 Nov 2023 05:04:13 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB864C1; Fri, 17 Nov 2023 02:04:09 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BA377FF817; Fri, 17 Nov 2023 10:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215448; 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=QYHHyKIme7eUxzobIVI12NLStklWJelYUHOZJ8AvmXXYvVElzTGwhkFIEekpHOSAcW+K18 l2G2pjqbTC+vUGDQq4caHJnddWHbObwbnmuLFdXz6OHmI5UQdklpT+f5Tam2dLWOW8kYqZ aygZ3O+Dh2MQLgPPzYeM3II+RhgcZsTqTiW7Gd5RkguZymAmsnmbw88V2uQDy1Nsu+B+Yr M5sifRmoU3s/BGjR6O0bBukYE5UNkg63Dh/xrTT5HSqVhwIG5d/kk4MH6BX71psxXwLM8n AeT5maXpNpy6RDf8b46r8dFUQyUMjm/QOYl+KuSWQRvIph3e3tZsuZljL0ziWw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:52 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-4-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 09:18:52 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 4E84DC197A0 for ; Fri, 17 Nov 2023 10:04:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345904AbjKQKEc (ORCPT ); Fri, 17 Nov 2023 05:04:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345812AbjKQKEO (ORCPT ); Fri, 17 Nov 2023 05:04:14 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 345C6C4; Fri, 17 Nov 2023 02:04:10 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 61BA3FF81F; Fri, 17 Nov 2023 10:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215448; 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=ppALPMc1pFTIFQzwRMW+tmzwmtQj10e6/dO7SG+F1wI=; b=Nk9QOBXXkZe4llaGhdKMLdybPq2Ys+qCWgZHo0Pqu1T/I1N0M3dRksIcsoMHP7nr5dtfxf 6i/sa+juuDTM+sP6A8BzmOF5UvDxgis/3p0tNggqxlk6nvDiHiVJ66i3UxsbEGn8rNw8le 5QSFaLRjEDZpgXIBZRUlVjICboIiEyp7IA+8UjD841jsPLL6MpoTpOuoNIH34uBqZTRmFj l4xEwiaZ74ODB4KZez8YoSvsWpSBRdhOTYNxbFcYgl3vLOL+cLUrswuB+sEgOOBqptNK/y +R6DIe+sLhbC82Qkx6wZGL9NojMmTkyB1B8buzuZ85auJPJIEQsMJS//3YxCsA== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:53 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-5-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v2: - Move the sync read in a function. - Add commments Changes in v4: - Update git commit message. Changes in v6: - Fix comment typos. --- 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..10e8f0715114 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 internal + * 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 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 09:18:52 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 6E77DC072A2 for ; Fri, 17 Nov 2023 10:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345864AbjKQKE2 (ORCPT ); Fri, 17 Nov 2023 05:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345810AbjKQKEO (ORCPT ); Fri, 17 Nov 2023 05:04:14 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACFC7C5; Fri, 17 Nov 2023 02:04:10 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id F0408FF80E; Fri, 17 Nov 2023 10:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215449; 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=NmKeLzmrWDgqwybx3yFMvQV6TVy/TJmLs+gOb6jsjkI=; b=ifWxZU5MoSMJa1RExPWzueMckAhDz+/FP9AYay2y7oLb+Zalg5OPxS+uJSZ6G4PLL7tG27 7B6Ezqo8uZROfk4rgCJc6dbvYgIY0+mmsg5++iTo+2fcRvuDlLaiwaAPAf0dyV1+8PobEE skGRJZEe1YrNGNOeLk6h94G5RCnogZx93R8UT/syiH7T0M9ZLWcTVt+xB67YQ+n6/3r0tV IGok0iY52aiynYO0qUXH50zKQ3zI/Qe6E8pLLQT4iH9YOGT69DmSBzVZnc2wkvYBBxQHs/ 4/1BS0mmd0dfRSU8bMiJBmTHfAEEK2aqW2EIlzEH2dGTFVoTpf8JR8kZfqoNKg== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:54 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-6-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v2: - New patch Changes in v4: - Update git commit message. Changes in v6: - Fix comment typos. --- 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..b75fdaffad9a 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 internal + * 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 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