From nobody Fri Jan 2 13:58:35 2026 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 02E21CD98FC for ; Wed, 11 Oct 2023 08:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbjJKIMf (ORCPT ); Wed, 11 Oct 2023 04:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjJKIMc (ORCPT ); Wed, 11 Oct 2023 04:12:32 -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 190929B; Wed, 11 Oct 2023 01:12:29 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9D5081BF203; Wed, 11 Oct 2023 08:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011948; 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=EOZ53uDlJRud+RSY+ah8ZS/rh8udoyM60w7XsdTrQ3A=; b=ULdnuIEfUNsQOGmFVLOpN1K0Mu863utSDvP6VgnV2FwcjDgdsp8RQAT0O287xOj/he8DSX kvfyFcDoEOo4DUldDSq8T6KTBjQv68bYH2igSBePqPWZHIgY95v1Rp1m3njGnlr9O0dezP dwwHiSDY3Dl+uln3PRiAH50LrI1RO71ibZFoRU8I16MlINje9YHBYtyabqhZDkT89hc8y1 OdfL5LsoO4X0kI63RuVx+zf1b28xJAAbfyQZGpoN2qlIYEiT2+AuhSjC1F0jARcABhkdA3 JNG3jdS8ol13Vrfu6UBLg3fXW+uOH2Y0QRd72ugvuAv+9NPAWk5VuljAVG3Ulg== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:40 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-1-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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 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") Signed-off-by: Kory Maincent Acked-by: Manivannan Sadhasivam Reviewed-by: Serge Semin --- 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 Fri Jan 2 13:58:35 2026 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 56134CD98FC for ; Wed, 11 Oct 2023 08:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjJKIMj (ORCPT ); Wed, 11 Oct 2023 04:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbjJKIMd (ORCPT ); Wed, 11 Oct 2023 04:12:33 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7CC98; Wed, 11 Oct 2023 01:12:31 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id DE3341BF206; Wed, 11 Oct 2023 08:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011950; 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=cwZtJjF55N4K1zCBuf7PfW7hNYydtD8p1nr7TpEtIiG+2S1jcgcesg0cUMQGTTeupwaQRD iM1rNe9SIQWe+rz4XDOEQJ3wtqaV3zbVWVw7TT/uuVNsUowGpFGegTvMjZpChSZdkDzaRG BvKPHYzmL7nETO6EnWPXmrF0jDyyBCqt+27QME7b836VzPKKq2+Vkf3XFfW3xIsCuPgG1o FFhIFcK0aqVR0SBuzistjylQtMtlgX4K6IoMIvFiB48CbK+SuOH4sjwd7JXszy+tbhCqx6 5W992I8Q3I2FkBGGltAyIK2KBFitdV2tyH63hIJEEvP4VMDVxRCB9K344ZNAsQ== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:41 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-2-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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.3 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 --- 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 Fri Jan 2 13:58:35 2026 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 309A1CD98FD for ; Wed, 11 Oct 2023 08:12:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjJKIMp (ORCPT ); Wed, 11 Oct 2023 04:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjJKIMe (ORCPT ); Wed, 11 Oct 2023 04:12:34 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8C469C; Wed, 11 Oct 2023 01:12:32 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4706E1BF213; Wed, 11 Oct 2023 08:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011951; 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=iDWq/Ocs6CBghGUbQvSHc/yBr2WaAenwVpAdxZ73beToAdp6c3U2QVkbd1b1SS1K99gJ+C LAHMOxkUaO9RVeTEGwq7pXq9scZNwboQZzS/nwrvAJ/6dtPxmvsiZVkBKgSx4RBetL7oH4 hpXJP4xWdWOxvilgy8ZCoevDRm4CsKghnoQKcqzRsfR/RmxWS4l5qzjn4E9j0lPEvYn+UF Rt1AN+YymB92x8wge/PfuUngSjgU+sSAaSdyNuVHeXd9Zl/MDwaoNoINOfFNZy84FIJwjx X7voyKEhGQ8KdAk9daLsfYkVvn0OCoglHoLS02flf5yfvHYs+Pni/HI2bTHoKA== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:42 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-3-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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.3 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 --- 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 Fri Jan 2 13:58:35 2026 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 740A8CD98FC for ; Wed, 11 Oct 2023 08:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230331AbjJKIMr (ORCPT ); Wed, 11 Oct 2023 04:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbjJKIMm (ORCPT ); Wed, 11 Oct 2023 04:12:42 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489DA9E; Wed, 11 Oct 2023 01:12:35 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id CB7801BF207; Wed, 11 Oct 2023 08:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011954; 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=Mh4FFs5qGnnta/KdhOFirxSlbpfwyU8rWS7+pkpEzJHs0IcWQ4Pc1Bd3A0ZhunxMo2zIfH HyjTs249F1qpcLVApKrrb7H1MZ8O3X5ojm3NQi0nde5Z74VcOUnspyXIPHjWzYF4uCgiwG 6tXRh3TiwjaHQidUuiJ5+5NpiwXCSn77BQ8WAWKu5r4pxzgZTgtrS5EKqFmx31GWNGGanO QEP4fXaB6CTcvzGAlAVx4Uy6BQjlndJodNLLxGZ6dEnSUrPRmMOX94lnTnwMEDDr2vPuF6 BY5mAeAfjpzbZLizS7IKzL3KdMsbaB+zZeO0+C4JQc+6XkqQOZW+FclSunsyGg== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:43 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-4-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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 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 Fri Jan 2 13:58:35 2026 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 8900ACD98FD for ; Wed, 11 Oct 2023 08:12:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbjJKIM4 (ORCPT ); Wed, 11 Oct 2023 04:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjJKIMn (ORCPT ); Wed, 11 Oct 2023 04:12:43 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 610BCC4; Wed, 11 Oct 2023 01:12:37 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 477A91BF20B; Wed, 11 Oct 2023 08:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011956; 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=czWpdkchpjIcmkN5wE2Ao4sOST4MTB7arrN4NTSp2AY=; b=ZAMMWcZIv3fUK0YhnOY6IGV91gV13RwXR1jadOMLxKqrh96UtzvCyUR1Qr9RUKkdm84Ekj ogmgBZpcsht4rXjfbkjOVzWBmGYsBed15hgAOlzoXo9OvLDS+9hEOYWTVpdeDmK7UFn6Uz 4jMShL7Whh9qY04DzrIjj2wPqZS+DYjCGJ+PkIXcaotTpiWoNdQ38wSoFwlTlGnRv93aQ0 C12YRSDgaqsUo9u24oi/1Rv37dhG2BDsvIV/GaU9jbz0aGqlOMnwRqcqJnP+61d8NyTglv jeYDppQ7/rnxsnc4MWkteZwtRYVWOpJ3PraMrbgbbiG9U1BTGwDvJ8SzSWuJEQ== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:44 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-5-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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.3 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 can appears. In remote setup we can only use a readl to the memory to assured the full write has occurred. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent Reviewed-by: Serge Semin --- Changes in v2: - Move the sync read in a function. - Add commments --- 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 Fri Jan 2 13:58:35 2026 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 3238DCD98FD for ; Wed, 11 Oct 2023 08:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbjJKIMy (ORCPT ); Wed, 11 Oct 2023 04:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbjJKIMn (ORCPT ); Wed, 11 Oct 2023 04:12:43 -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 5A131DA; Wed, 11 Oct 2023 01:12:39 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 475771BF20C; Wed, 11 Oct 2023 08:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011957; 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=raWpLxdnCsHiI6FQxGeq5/CW+Sjk7JXPZqqzsnU681g=; b=PdEzs+iwrBvoWBhPl97FjcpSGd90nBOEQ8xvaPJqFZ7EOnP3oVIei7hBWoOahPXkZiKoSx /eo7W0Bmiqth0V+eQESnoaYF7oZto0U9u57kkZUbon7wRGWnWbTk0pHou76+4tyfhmNHrj slmPP7CUxxKEsbcOPACjFRkqSdF4UPyK8sTNxvzqA9bz3z4olqOPb8rjmHMOj6vy5OE2WJ yRBPuUOe/3ahekYliDRdH3flj9EfuntbpXPyz+p2Prp4Mw/G3rf+BxjmZ8Zz+9GWcRjV+a RZBtCgCrdw7F14jdH3Eb9UmafuX+pLFOCM2lqm9xfacqRB7iwI0k/27CYO/ClA== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:45 +0200 Subject: [PATCH v3 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: <20231011-b4-feature_hdma_mainline-v3-6-24ee0c979c6f@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@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.3 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 can appears. In remote setup we can only use a readl to the memory to assured the full write has occurred. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Signed-off-by: Kory Maincent Reviewed-by: Serge Semin --- Changes in v2: - New patch --- 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