Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp650525rdg; Wed, 11 Oct 2023 01:13:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERlwc6R+iZExVgOM7oKHbuKq8O8T/bPg/PBwoFeE6IM5GkQlEe4tZYJ5WYVuJ8ynHaAdj+ X-Received: by 2002:a05:6e02:2189:b0:34f:e4e1:b4aa with SMTP id j9-20020a056e02218900b0034fe4e1b4aamr24284266ila.14.1697011998435; Wed, 11 Oct 2023 01:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697011998; cv=none; d=google.com; s=arc-20160816; b=DTL5fMo2mETS3wZCoJiybx+BPWV3wy5eI8JX2aFw5Z4OoeeFSfGvrLvRQhgvUa+EnI zKos5Mn8wkTJRGPc9zwCZaMZwJRpctGWfzyGHpPRqiIpD6IeImdWoIGV31UGCaieAg/L E/vS0qBionUxjRDukceCxrKKD/Fcdj0mNDFYDX/OGLJ8csc8/7kK2yGpACK7pvEzmGpy DrvQJYUeN+0kjKH9AANMaYwt4EBk6O0hmbwB0IvVwUBLF3pqBDKCmE9D7fwclPWah2wx SNJf7SG4r/yksG8GaQxRvTXRp89HIvMxbDuXV1hF+UUqEpu443F5PkXgjGeYSLnmih4v AOsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=raWpLxdnCsHiI6FQxGeq5/CW+Sjk7JXPZqqzsnU681g=; fh=6XphIdWxfa6Vpt4el4ltSz/1eFeqJAQ3KUirCeZaEUc=; b=ejKe1WQFqqcThSX4CBtbVGyuCRoZbG0aZsEr6FajeDgwpeMUssmTtdi5F0fFZZppsq FZWuxJg4S+6KaNWdCQRu1A2nV82zH1QLGMH672L6Tq01M+8sOGCSR84K4FbJASZ3rRhv fYokrgwpnyvp16wAS5sGtP4xr7R+IIeBbdPBLSSJwSF0E69mD/yazqrt9zyMDOWc85IE WWYRCw4aFjUx0jl7vFGA/39Quq2w5LLQbMHmJjjb0tQd1uhIshf51y3GKYQH45RmUqu8 iW4mf0xdtwNao4rhmAfZQ7AVT3s5Vk4APYHpcimdVZnQi0pJT+GP9e2aHDemsA5b+bkM HwNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PdEzs+iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m125-20020a633f83000000b005895b62fe76si14083765pga.462.2023.10.11.01.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PdEzs+iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 2305D809ACA4; Wed, 11 Oct 2023 01:13:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbjJKIMv (ORCPT + 99 others); Wed, 11 Oct 2023 04:12:51 -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: 7bit 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 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 01:13:15 -0700 (PDT) X-Spam-Level: ** 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 --- 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); } +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 = 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