From nobody Sun Feb 8 01:21:25 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 121C6C7EE2E for ; Fri, 9 Jun 2023 08:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240259AbjFIIRq (ORCPT ); Fri, 9 Jun 2023 04:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240165AbjFIIRf (ORCPT ); Fri, 9 Jun 2023 04:17:35 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF1A35B6; Fri, 9 Jun 2023 01:16:59 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298617; 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=x8snxb+3C9fmkNIycrjOe2QGKhT9VxzlCpHRN3AtV6g=; b=YsfuWmYOXUDE83S/ScUKeT2bzH5eUfjurjL4aQoAj+pw1QQxrMPRhokkwln9xq6A2pFEY9 jzf9iXpyC/h1v/1Ny5ztGQ0Ma1RGWf9NBog3HQr3jckqC8IRKtyjs6S6zwZ1yLakYBwxyK v38XC6DPmcIkHw2e3fRmoYkHa3aKYpC86wI/Ka+FZAQEHXPyxFG5YLwAUoX1sbujXrSKZx BhogV3aG2InKR/F4mO1ZE4HGU4rDrTbGxAaaoTABRRfh6qJPS4Ze/DV14/utD+p3iFC2XA hUIP9Z9X08H9aMshuwbcgvzeAhLKuNa+q5C42FCau+uoNWE+Da1Hk2peEaT9iw== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0E0B3C0003; Fri, 9 Jun 2023 08:16:56 +0000 (UTC) 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 1/9] dmaengine: dw-edma: Fix the ch_count hdma callback Date: Fri, 9 Jun 2023 10:16:46 +0200 Message-Id: <20230609081654.330857-2-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/ This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 13 +------------ 1 file changed, 1 insertion(+), 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..de87ce6b8585 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -65,18 +65,7 @@ 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; + 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 Sun Feb 8 01:21:25 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 5C23EC7EE2E for ; Fri, 9 Jun 2023 08:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240284AbjFIIRu (ORCPT ); Fri, 9 Jun 2023 04:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240168AbjFIIRg (ORCPT ); Fri, 9 Jun 2023 04:17:36 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D1B35BD; Fri, 9 Jun 2023 01:17:01 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298618; 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=xTZthyABqfsJIp2/g/QBAbmCaWyEr1NmIxCo1bqkf3w=; b=lNmNHKx3hN3/of+rh7ppTvpGt+1KLaFbiH/zTDC0UEaCIYiIqC6vZOhIh+7rCw+Y3xpi6e dEWqHmiIg9vc9l0ZpAeGnNsxVfghdk/AwFpAsUJ0tdI2uTTr7cLLCjXTpki4xS8n0DyK4S ir8aWOOYlkGjD/iJNiZwPwO2u0ejZ9QpFoLVaXp227O30waeICI/ox/pFkBme1Tq0jh3Gf tEokEAi+cqqIe0MEDcxq8YeEWb2js/xpepKgcSsz2zAoNCegdCgLZIqOtBy50nyVtS7TcR 5EtN2CNtcG4qn3N67y89kHjM7W9SCineFBy+xHBDpd9wTDEPRe13HRvFuMUziw== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0EACBC0009; Fri, 9 Jun 2023 08:16:57 +0000 (UTC) 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 2/9] dmaengine: dw-edma: Typos fixes Date: Fri, 9 Jun 2023 10:16:47 +0200 Message-Id: <20230609081654.330857-3-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error. 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. Signed-off-by: Kory Maincent Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin --- This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 +- drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index de87ce6b8585..da8663f45fdb 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -231,7 +231,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); 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 Sun Feb 8 01:21:25 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 845F4C7EE2E for ; Fri, 9 Jun 2023 08:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240367AbjFIISF (ORCPT ); Fri, 9 Jun 2023 04:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240196AbjFIIRh (ORCPT ); Fri, 9 Jun 2023 04:17:37 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C212635BE; Fri, 9 Jun 2023 01:17:03 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298619; 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=8SNOyQIGrae4VS8d9/zrsPOL4K+WbpBEtOXUfe9PyKQ=; b=B4qv8kRPDn7Ovadfs8sRaW/pXvhXWRW/TvZEx5jieXw1js19IeVyqqJ0mbPmwUNP5iucaS InPb45H4uAfjLOirgCwC6ZQodiQPxZb9QmW6gegp3IYsopMaf3kJYUoiAXc85DVQhkaYct hT8mlRDu8CaiAAYOlQZVvZy8o5H6gKmqi7vcA7x80VANNnjvWDT/EDBoj5xpCdP9mQ0izG ZhPCd4exN6dNsNIy7cN9hbG25u9U6aT3ea1Q/vY5tikRMb0fP+xHD/ZpEEYrgol6QoN0pC 5HCtPrJHOtJlnVJriqcyGoDFjl0Oy1QM/fGT8+UPg65oi6hr3AA9rh3loNxwdw== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0033FC000C; Fri, 9 Jun 2023 08:16:58 +0000 (UTC) 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 3/9] dmaengine: dw-edma: Add HDMA remote interrupt configuration Date: Fri, 9 Jun 2023 10:16:48 +0200 Message-Id: <20230609081654.330857-4-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent 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. Signed-off-by: Kory Maincent Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin --- This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- 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 da8663f45fdb..7bd1a0f742be 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -232,6 +232,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 Sun Feb 8 01:21:25 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 A997BC87FDC for ; Fri, 9 Jun 2023 08:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240345AbjFIIRy (ORCPT ); Fri, 9 Jun 2023 04:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240187AbjFIIRg (ORCPT ); Fri, 9 Jun 2023 04:17:36 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B6C91FEC; Fri, 9 Jun 2023 01:17:02 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298620; 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=iaIwrR05LfNW5SSLQAneAaJEWILGvAsISfahHxT0j/M=; b=Ex3mdL6eGB+jsiAganw8NeFfEveOKMnoTHHsGmGraYohL+oKAE+F/B9Hqq07myNS2d86D0 m58xWjJxig8A3VFHxrQ6gkPNMk1q/PzKvcoUXN7tGHfoMYq/pth5TtFJdINUI+7+kufST0 /exwSmDFjkMouCOk7+jlHMiTZ7UrgVwkjDSDmI7SpOu/Gaf37NubjLYP604h5G0foA9Ljn bHh/ASjJMWOwBaxbD+ABTbyqHE4IDoe4Lx5quchR/xFb2SFou/ZI8V2SFRf641EqHgIyyQ 8uQccGgDyXVtM4KiAfqWnEwi6PzcUW/Vo47DmKm04LaQ45bZusVyp/I6ESAUgw== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id ED319C0006; Fri, 9 Jun 2023 08:16:59 +0000 (UTC) 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 4/9] dmaengine: dw-edma: HDMA: Add memory barrier before starting the DMA transfer in remote setup Date: Fri, 9 Jun 2023 10:16:49 +0200 Message-Id: <20230609081654.330857-5-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent 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 --- This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index 7bd1a0f742be..0b77ddbe91b5 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -247,6 +247,15 @@ 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); + + if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + /* Make sure Linked List has been written. + * Linux memory barriers don't cater for what's required here. + * What's required is what's here - a read of the linked + * list region. + */ + readl(chunk->ll_region.vaddr.io); + /* Doorbell */ SET_CH_32(dw, chan->dir, chan->id, doorbell, HDMA_V0_DOORBELL_START); } --=20 2.25.1 From nobody Sun Feb 8 01:21:25 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 1BC61C7EE2F for ; Fri, 9 Jun 2023 08:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240358AbjFIISC (ORCPT ); Fri, 9 Jun 2023 04:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240209AbjFIIRj (ORCPT ); Fri, 9 Jun 2023 04:17:39 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1062D7E; Fri, 9 Jun 2023 01:17:04 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298622; 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=cbdGpWw3wXdv/9CgkohTPhBO6pQU5IR9oYOzbdI3a4k=; b=bzrgUYylr8ZtCiQyYtetbY2fhyi9ysaaQcJRlN3RwRAYJ5Y0c14hgXD4wDSnUbYWsdAb1M DScTGRCZRAssYgubd3SDvABJZqioqEnT/hLLZfiOYIb9fVNTOcbiCzPiAgKfFsJhx7Ph55 18SJjNJ1W4PcIG2731dJdADTR+xkVvEQuF92TgVSbBtCWsERQmtYaClaBM0Au6Br4f0pzL 4giHBAWZM1mENfq9U9FrKJJDk03a01NuXzbaPC9WJstpBXL/dizlu5Qv9CKIu5XJqmuLZ0 sXXM22WKm49dGOzvw5jpNvxu/8QOpvrwMIBFqwxuZ4DCVGV34EYWevylajlPXA== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0F319C000A; Fri, 9 Jun 2023 08:17:00 +0000 (UTC) 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 5/9] dmaengine: dw-edma: HDMA: Fix possible race condition in remote setup Date: Fri, 9 Jun 2023 10:16:50 +0200 Message-Id: <20230609081654.330857-6-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent When writing the linked list elements and pointer the control need to be written at the end. If the control is written and the SAR and DAR not stored we could face a race condition. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent --- This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index 0b77ddbe91b5..f28e1671a753 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -162,10 +162,10 @@ static void dw_hdma_v0_write_ll_data(struct dw_edma_c= hunk *chunk, int i, } else { struct dw_hdma_v0_lli __iomem *lli =3D chunk->ll_region.vaddr.io + ofs; =20 - writel(control, &lli->control); writel(size, &lli->transfer_size); writeq(sar, &lli->sar.reg); writeq(dar, &lli->dar.reg); + writel(control, &lli->control); } } =20 @@ -182,8 +182,8 @@ static void dw_hdma_v0_write_ll_link(struct dw_edma_chu= nk *chunk, } else { struct dw_hdma_v0_llp __iomem *llp =3D chunk->ll_region.vaddr.io + ofs; =20 - writel(control, &llp->control); writeq(pointer, &llp->llp.reg); + writel(control, &llp->control); } } =20 --=20 2.25.1 From nobody Sun Feb 8 01:21:25 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 3B7CAC7EE25 for ; Fri, 9 Jun 2023 08:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240396AbjFIISJ (ORCPT ); Fri, 9 Jun 2023 04:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240207AbjFIIRk (ORCPT ); Fri, 9 Jun 2023 04:17:40 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10EDD2D7B; Fri, 9 Jun 2023 01:17:06 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298623; 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=oCPB9Nf3YZqvG1rzu67yQSLPi8ZPt/80c1MDnzGqrYE=; b=d+AW7TcbsOXUczeTbAj0+f1hTV3cgIhoVMCMFoZUmd4pq1hiPoV7nM3TWzrjrDqXxJGIBH WCZWVzTHH9uIxpnW0agbTU70MjQKdEYkKJ7vevRIvaRfuuQTAlh3+AjAuDTXNqoRf/Ziza eN7Wrz+IPBv6JEfNn2zGCeCXpUmJ2U/Gz1N8NZRZLCTIlfidyUzxTmRk6N/v4VZSBzDLVV YQ4nYhGhNZ/Bcis2Jav4orHvVEQbrbBBMLhx3HI39x/F0zCUpGZ99YnFbF/PquYBo7Zmvl c476gy+A60kmmPotp6HPPLqNwdZkIBglcWZEx62DbPGosO0elJnd8DGVeg1lSw== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 47970C0010; Fri, 9 Jun 2023 08:17:02 +0000 (UTC) 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 6/9] dmaengine: dw-edma: HDMA: Fix possible race condition in local setup Date: Fri, 9 Jun 2023 10:16:51 +0200 Message-Id: <20230609081654.330857-7-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent When writing the linked list elements and pointer the control need to be written at the end. If the control is written and the SAR and DAR not stored we could face a race condition. Added a memory barrier to make sure the memory has been written. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Signed-off-by: Kory Maincent --- This patch has not been tested since I don't have board with HDMA in local setup. This patch is fixing a commit which is only in dmaengine tree and not merged mainline. --- drivers/dma/dw-edma/dw-hdma-v0-core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw= -hdma-v0-core.c index f28e1671a753..d3c70500496c 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -155,10 +155,13 @@ static void dw_hdma_v0_write_ll_data(struct dw_edma_c= hunk *chunk, int i, if (chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { struct dw_hdma_v0_lli *lli =3D chunk->ll_region.vaddr.mem + ofs; =20 - lli->control =3D control; lli->transfer_size =3D size; lli->sar.reg =3D sar; lli->dar.reg =3D dar; + + /* Make sure sar and dar is written before writing control */ + dma_wmb(); + lli->control =3D control; } else { struct dw_hdma_v0_lli __iomem *lli =3D chunk->ll_region.vaddr.io + ofs; =20 @@ -177,8 +180,11 @@ static void dw_hdma_v0_write_ll_link(struct dw_edma_ch= unk *chunk, if (chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { struct dw_hdma_v0_llp *llp =3D chunk->ll_region.vaddr.mem + ofs; =20 - llp->control =3D control; llp->llp.reg =3D pointer; + + /* Make sure sar and dar is written before writing control */ + dma_wmb(); + llp->control =3D control; } else { struct dw_hdma_v0_llp __iomem *llp =3D chunk->ll_region.vaddr.io + ofs; =20 --=20 2.25.1 From nobody Sun Feb 8 01:21:25 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 4509CC7EE2E for ; Fri, 9 Jun 2023 08:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240438AbjFIISU (ORCPT ); Fri, 9 Jun 2023 04:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240237AbjFIIRl (ORCPT ); Fri, 9 Jun 2023 04:17:41 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB3F30DB; Fri, 9 Jun 2023 01:17:10 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298624; 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=ZN4vSrdEzZbjDfKQW2lKALJhEegIaV8kRdvhAJHOihQ=; b=hcG/OaQGWsEJoSXYV3ZcJgpjt9j3R7FGTjZ/ONxgw9+gogqpNSHbZ9uOlMzNMebGLDA1nP rfuD1999pBUuLpUk8aiWioqyBn4Tzo5BunhzuOIL/36dfyT0j7HNSshdLfEWgCU1GnnG9i 6s+mCK+dVhvHUZNWcrGe7WHMVULdAa1t185/6r02IERNw+DRJTmpUEDFffUkEKlxg+PEoa 3DWAE1JtmiRqfz3evHdONfh5Z9Nt5jDeEHBxQLsDqXhLK1h5AuxM0BqB266FtdmKNeub9y CTTJR1IUFMjjQqbuoTqJEQTlGGenWtY5WMiTcmY37PcM17+1AXQV839sNXW1YA== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 80D28C000E; Fri, 9 Jun 2023 08:17:03 +0000 (UTC) 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 7/9] dmaengine: dw-edma: eDMA: Add memory barrier before starting the DMA transfer in remote setup Date: Fri, 9 Jun 2023 10:16:52 +0200 Message-Id: <20230609081654.330857-8-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent 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 --- drivers/dma/dw-edma/dw-edma-v0-core.c | 9 +++++++++ 1 file changed, 9 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..2e872d6f2c04 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -412,6 +412,15 @@ 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)); } + + if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + /* Make sure Linked List has been written. + * Linux memory barriers don't cater for what's required here. + * What's required is what's here - a read of the linked + * list region. + */ + readl(chunk->ll_region.vaddr.io); + /* Doorbell */ SET_RW_32(dw, chan->dir, doorbell, FIELD_PREP(EDMA_V0_DOORBELL_CH_MASK, chan->id)); --=20 2.25.1 From nobody Sun Feb 8 01:21:25 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 1538AC7EE25 for ; Fri, 9 Jun 2023 08:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240494AbjFIIS0 (ORCPT ); Fri, 9 Jun 2023 04:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240274AbjFIIRs (ORCPT ); Fri, 9 Jun 2023 04:17:48 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7865130EC; Fri, 9 Jun 2023 01:17:14 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298625; 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=ZA+S0v6iLr2wkmRPyH+qWvvhx/TnOH2owT01i8MhK3U=; b=PKfIeo5Idiacxg521v7LF2oTJXigoQW/18p/KEPAo44SGR0/PPVw4kJXW2qpLQVKbogDLb vfMcoIAPliXK3BtdMbpT4k2pm4qWpTynj31/tKkh4pHzW/diVPNd5uT4xgFcQnO2L2/eNY OXuA3OvJCygSS4qXY0HhCxz4q9/7ILy4VE7ly9t69G6pPGE5hJrv4HbDwrKKKgi1De1Z70 PX6QfN+tjxKJiNNh7HAVQ1Hr5ngnVzLUJRO2g9ITc+v2zIrU20Marb1oqPe78DkzMg5LT4 rbDH6gFhURB3Oyn5Mrrh0FEVSmaS1P8n9JauFqKVVomSKBq1s3Utg1N1PQzceg== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id AE98AC0012; Fri, 9 Jun 2023 08:17:04 +0000 (UTC) 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 8/9] dmaengine: dw-edma: eDMA: Fix possible race condition in remote setup Date: Fri, 9 Jun 2023 10:16:53 +0200 Message-Id: <20230609081654.330857-9-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent When writing the linked list elements and pointer the control need to be written at the end. If the control is written and the SAR and DAR not stored we could face a race condition. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Signed-off-by: Kory Maincent --- drivers/dma/dw-edma/dw-edma-v0-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw= -edma-v0-core.c index 2e872d6f2c04..a5d921ef54ec 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -291,10 +291,10 @@ static void dw_edma_v0_write_ll_data(struct dw_edma_c= hunk *chunk, int i, } else { struct dw_edma_v0_lli __iomem *lli =3D chunk->ll_region.vaddr.io + ofs; =20 - writel(control, &lli->control); writel(size, &lli->transfer_size); writeq(sar, &lli->sar.reg); writeq(dar, &lli->dar.reg); + writel(control, &lli->control); } } =20 @@ -311,8 +311,8 @@ static void dw_edma_v0_write_ll_link(struct dw_edma_chu= nk *chunk, } else { struct dw_edma_v0_llp __iomem *llp =3D chunk->ll_region.vaddr.io + ofs; =20 - writel(control, &llp->control); writeq(pointer, &llp->llp.reg); + writel(control, &llp->control); } } =20 --=20 2.25.1 From nobody Sun Feb 8 01:21:25 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 1793FC7EE2E for ; Fri, 9 Jun 2023 08:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240404AbjFIISM (ORCPT ); Fri, 9 Jun 2023 04:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240248AbjFIIRm (ORCPT ); Fri, 9 Jun 2023 04:17:42 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E052D30ED; Fri, 9 Jun 2023 01:17:10 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686298626; 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=GiInZFwv5UYo7clt/bdC/mTWPa4mwyqkZum6ygvm/Fw=; b=AyqcItkyGQ0Nf2EBvxSv7WugPbRmP9c+lYLP5DnylOOr8hMKkR04j+iZovz+F6Wp8BgN4K ET+m7VZ0WgduGkgYOcPMuMqDxIVP+PNQrSlLNi4t0J1I+/AytTqLR2bQFKNO209gvp0Htg 9WMvMBFy4d8MOHdOxVGKE6vXYLXDZcmazPW/t9fcwyhtvw8FuhVmImdrZIM40u8dC6Ucdp CZGdkSsHQRfsfGUbqqUqYjvyTDiG14dPadFX4RcVyQKcKhWwoqYZigiB/5mKNXQ9ecNTyY Dy67EsthO1953HjstPMYiuPVjHBQR7CDYyvMiHlnDfEpdnxQQVLZQLoxUrY7lg== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id BD163C0014; Fri, 9 Jun 2023 08:17:05 +0000 (UTC) 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 9/9] dmaengine: dw-edma: eDMA: Fix possible race condition in local setup Date: Fri, 9 Jun 2023 10:16:54 +0200 Message-Id: <20230609081654.330857-10-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609081654.330857-1-kory.maincent@bootlin.com> References: <20230609081654.330857-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Spam-Score: 300 X-GND-Status: SPAM Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kory Maincent When writing the linked list elements and pointer the control need to be written at the end. If the control is written and the SAR and DAR not stored we could face a race condition. Added a memory barrier to make sure the memory has been written. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Signed-off-by: Kory Maincent --- This patch has not been tested since I don't have board with eDMA in local setup. --- drivers/dma/dw-edma/dw-edma-v0-core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw= -edma-v0-core.c index a5d921ef54ec..612c8c49668f 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -284,10 +284,13 @@ static void dw_edma_v0_write_ll_data(struct dw_edma_c= hunk *chunk, int i, if (chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { struct dw_edma_v0_lli *lli =3D chunk->ll_region.vaddr.mem + ofs; =20 - lli->control =3D control; lli->transfer_size =3D size; lli->sar.reg =3D sar; lli->dar.reg =3D dar; + + /* Make sure sar and dar is written before writing control */ + dma_wmb(); + lli->control =3D control; } else { struct dw_edma_v0_lli __iomem *lli =3D chunk->ll_region.vaddr.io + ofs; =20 @@ -306,8 +309,11 @@ static void dw_edma_v0_write_ll_link(struct dw_edma_ch= unk *chunk, if (chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { struct dw_edma_v0_llp *llp =3D chunk->ll_region.vaddr.mem + ofs; =20 - llp->control =3D control; llp->llp.reg =3D pointer; + + /* Make sure sar and dar is written before writing control */ + dma_wmb(); + llp->control =3D control; } else { struct dw_edma_v0_llp __iomem *llp =3D chunk->ll_region.vaddr.io + ofs; =20 --=20 2.25.1