Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp493903rdb; Mon, 29 Jan 2024 08:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFK9yL95cNDlxdCFhCyH7KKRwzBGfahEpGT+JL1Z8RP7VGe9Km0J8NwgVz3CHuXW6ar1kij X-Received: by 2002:aa7:d60e:0:b0:55e:f8bd:6246 with SMTP id c14-20020aa7d60e000000b0055ef8bd6246mr2053882edr.18.1706545653624; Mon, 29 Jan 2024 08:27:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706545653; cv=pass; d=google.com; s=arc-20160816; b=G4aT+EbNf+0AQHsxcEDbcERmvdQSJwWETxi9teHRlqxPpVjA+Y2uswZtQZ5PcUUFbQ jXxfXmVC3CrfYgAYf0wHTB49vtoyFJG5gPPKQc5zNRcULMU291f7dW2cFctcpxDaPRdp tnT8HhOZoMec7CkEFtXXrVo8zwdng6HVYoyboeDwg0J71jD79on5vANcO82fgFEYcfym iymX5u+QiXX1O0voO8cmII2GnNcuINRXMNu1C5Ti1vv8ycHpgCMyZpmJ95TRbLkfrmBo 2TjpKMse5xWwW6dKL1HcISPOGCOJFv59xO1LpHXfxyLhfJPE+VeoEvoQf1P8jzldEt5l dZ0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=NmKeLzmrWDgqwybx3yFMvQV6TVy/TJmLs+gOb6jsjkI=; fh=oC1+pIJR2tZdBb9Uzp3yLjqrVYle+8srf2TBxoXLW2Q=; b=taoMv7peuqr0cSN+TPdFTG3xWTm1E8UHyBwxCwKY22q9kU2UVGv593Zb+jUgHKrt/i hF9XTKFU2C5DK4A0128CtZwOIY8GsouVr84slOyxNNareJirs3PK1XaUFd6FFgZYrkOm Zlv8PgdscECUd26RNaudHNenOQkDDqy8DBoXs8UQy/lhKseVFQWQZXDdKENT6Aktk+/N BmazyaAmg4abQECiAy55RR1AbR4F0+Y/OZa0WXNZ56UUvnX69PnEDoI3sTE6VQWLeWX3 VBqAwBHT45lxGhrvAN6mE3zsFE+WQjoSsJSqdTTgy75+8TQ1UHIxX9+52khTUXagqq6C Eoig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=d6v5f7h5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dg18-20020a0564021d1200b0055efaddbf18si1216650edb.132.2024.01.29.08.27.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:27:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=d6v5f7h5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 607DD1F23153 for ; Mon, 29 Jan 2024 16:27:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 397B0155A5F; Mon, 29 Jan 2024 16:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="d6v5f7h5" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D1F15702C; Mon, 29 Jan 2024 16:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545574; cv=none; b=jQToONlPCz273HwQ+395nqzQdbtvxp8uvpntNxy4AkbTRyMIaPpgQ6m7WvWZBMUYWB5V33eP5Zw1aMXKfMcmx3WwHw7Ll3Zyaj2yg8JktyLnDaCdWR04cVUrhFA78WQ3X5gn1zms0KiRvPaAVGBFDD12YvRvYdDuksKdRoYygm0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545574; c=relaxed/simple; bh=uJflaUj/o6qIVrmoj3XRFhafmb5pPKWQ886Uc8xGT/g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P0tiAsxMxQWAoF3il1+t4ptc0/PYi2RAewK/UzI18NAbn8ecBgYgfax5T5yP4Pg0DML1k1qKkQ8zGL1Totr15wwXMIDD6/R9UhCPtrWUJZXbjwAbXbixk4r2OWNrl7N8aXiGn8bF3iDKAcOr2HNQKtanC7krNcEWSBO8Id29Q9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=d6v5f7h5; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E01A1E000F; Mon, 29 Jan 2024 16:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706545569; 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=d6v5f7h5LqrKNI+2B+Idq2KxCE2DWyBdxziPUtJ+3XWOJi4Kkpm/yLPYvDmcwczfiSvADu 8fUj6ZXw0IpUYd1JMOtlZPj2F+B09QO7CQNGSg2wXPU24BIACn9/1RZPGxQT+NqPhbwxnH /8iqGXyICsE18lE322T2CJ62VRRbMWLQjs3GJc3SkI19dMjzYWLwrG5GTYMLowEUwWEZLc PaBC3m9P3XiElUN1uRdZsmWBoFlkEgSqJyJ8apk8DeW4KoqWfL6uJCJdqkZL7rAzZlQK4E ZCQzdn9zsf/sKluwVrNnFw1TeBniXZnrdY1Rr/YSXivv8KO5Hzyxq8z2KkdhHQ== From: Kory Maincent Date: Mon, 29 Jan 2024 17:26:02 +0100 Subject: [PATCH v7 6/6] dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240129-b4-feature_hdma_mainline-v7-6-8e8c1acb7a46@bootlin.com> References: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@bootlin.com> In-Reply-To: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@bootlin.com> To: Manivannan Sadhasivam , Gustavo Pimentel , Serge Semin , Vinod Koul , Cai Huoqing Cc: Thomas Petazzoni , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Herve Codina , Kory Maincent , Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com The 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); } +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 = 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)); -- 2.25.1