From patchwork Mon Jan 29 16:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 193589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp688328dyb; Mon, 29 Jan 2024 08:41:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk6TaKWoVd4fPLO95jkFiKbK3/LuoyicOxB14c1agxwiVLAp1VK3QBb8h+JeLEZVQJZtbR X-Received: by 2002:a17:90a:a88e:b0:28d:f5db:70b8 with SMTP id h14-20020a17090aa88e00b0028df5db70b8mr3685993pjq.37.1706546488735; Mon, 29 Jan 2024 08:41:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706546488; cv=pass; d=google.com; s=arc-20160816; b=jsC7Ki+Xmv0hWdI4LVPn0PC+IBfqAX8Dw6KB0EmAXJk6vqHiWOm8XAGL0XorVzMZ3Y TlrMnNNo0VhMr/NIY3rImPM2CEQHu01iYG347bp5GAZTKrFUaZ8M8wcdlcMDTSKEAk7u RGCQ+SqDg1SypsWYPZayZ+blu0I4UMGYSo48eO8XaiH97KKtNvK8mWt1xpfyq3VNYmp2 Vgq0U920NR3UQZzRyb7b45UMQpPkEUCQ24iYdUJxOenT47hPpyWiTnfFXahaQYHOf269 h2PI6H31wzD/DO6zIiIP44UQsAxaM9a8GaEyse/ZO4Bd8G/m4aNg/JaOuTySYzCHcvTj iCtg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s61-20020a17090a69c300b0029028f583fbsi5915462pjj.104.2024.01.29.08.41.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:41:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43078-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43078-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D8C7AB23007 for ; Mon, 29 Jan 2024 16:27:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1947D1586D6; Mon, 29 Jan 2024 16:26:17 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789443690690608299 X-GMAIL-MSGID: 1789443690690608299 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));