Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1915106rdb; Tue, 3 Oct 2023 05:16:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpq1Fvqoi9EscuxQjydHKp1t7azZe4lcqKO35m3egAF7Jye2lUSPyatZEM1DbrIskEHBgA X-Received: by 2002:a17:902:ab19:b0:1bf:7d3b:4405 with SMTP id ik25-20020a170902ab1900b001bf7d3b4405mr12050124plb.14.1696335383973; Tue, 03 Oct 2023 05:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696335383; cv=none; d=google.com; s=arc-20160816; b=hyIvxOO7z7XZSkzLK3mM5skEF6q3dG5MqLIU6jQxdXCKhAAkd06d/Yolfn+7LqGSNJ BHqkyXgLmDf+kvz1sb06MwpxVNUcENYKIs87r7fLasKVreF3cbmuSiRShxJ4kPXAuMXP ClDWa25PLzBtbSJyC0siYaGKHTvfOt1kyfRM0/yZYwO/KmNZh8RpybDM9fYYJ+cQrUr9 K+wkn3QWvh2k8+rLE1an8H5MbOaQRSyRVvCtT2wHTbjzwCL0qNro1NzMX8aUFgDPQw8X rh2T2It7SM+GHZ0Lv7VynFVW4bMoc0dIiniU16klUS/drMqsHK5SIWqDoTeii3QjXMpA yQqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zXx1lSnltg4BwldcbEtIyXvJaPMruxJjemPAO9ciyhc=; fh=3Wij1Nyq0kk9iFJBGjsMqOGfirL0oXoeYA+XKMkEeWg=; b=utxILXu4Joz8JRWqcsKj7qARTylfBH1AKNIcMtQtdDTDhIGx/ViZOXzF+Um1kkTxeh tRNeKriM3FGYqdXw/cYDNz6n3vTtiE+Jj7IkjJMCHduod/siLnXEEosqqQa/zoZk2QmG UG7eeNTjN/XPKNEGQ3912XSgfww7lVWxzbVnYnrCQ3dnvjGAYE3cgS5tgNayBiPGQU5q vMQOIXVrqB/Y0ZU8sd84N91ql0NJMpx/xEzQkv7r3yoE0/6tFkV0X3/IOEl8mnGxp1u6 foq3xwabIjGJ3MqRxpSE1blUIVqEPGb0w2CQUe6rg191KJTpU7QgGW+2gWrefOqVeye/ UguQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D4riTb3T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id kh6-20020a170903064600b001c342073f76si1221249plb.323.2023.10.03.05.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 05:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D4riTb3T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 65CF980B7C2A; Tue, 3 Oct 2023 05:16:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232243AbjJCMPy (ORCPT + 99 others); Tue, 3 Oct 2023 08:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbjJCMPt (ORCPT ); Tue, 3 Oct 2023 08:15:49 -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 8A0F8A6; Tue, 3 Oct 2023 05:15:45 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id BFC7EC0012; Tue, 3 Oct 2023 12:15:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696335344; 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=zXx1lSnltg4BwldcbEtIyXvJaPMruxJjemPAO9ciyhc=; b=D4riTb3TgcKOjBZ5xBZ5t/yW5UPe3YkUar2Zn5NfTDl5jS0a6fERzysQAUPQMCz/TlcK7Q hq/jClnQiOHiYSuFdos79H+zvM/Wg93ZiIicRustgoecIVbep7Wz/0nIASJYQxaqb4av9+ Z6I/z751xoQwihkjPTBPt7rkQ/rjhK3uXOC5gqvr4X/mngQMqxyghfYnUn2FbPhrZnwqNh dcFSFjw6HN0v2nM8dDcqPvX1BcU+z34q6jxGZ65KEZ2+CYjJtLI4yC2W7QOtL4Qzd9oLu4 prqL1ECZ5+fX08zNkwoR2Q5rN4iZuDW3eStPni5EBELA4OiRclivbg7kFtcb+g== 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 v2 4/5] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Date: Tue, 3 Oct 2023 14:15:42 +0200 Message-Id: <20231003121542.3139696-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 05:16:20 -0700 (PDT) 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 --- 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 0cce1880cfdc..9109dd6c2e76 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -221,6 +221,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); } +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 = chunk->chan; @@ -251,6 +265,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); } -- 2.25.1