Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp650446rdg; Wed, 11 Oct 2023 01:13:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQb0dr84YGj8dKkc/Ztb9S0iSfrKFPTUqQ8suDOUTklS+9fXdFFswdmVfJZKvPTors3BJJ X-Received: by 2002:a05:6a20:2445:b0:14e:3ba7:2933 with SMTP id t5-20020a056a20244500b0014e3ba72933mr20856920pzc.54.1697011985460; Wed, 11 Oct 2023 01:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697011985; cv=none; d=google.com; s=arc-20160816; b=L3rT2VSQG49sue88BkAu5U/4sjBFYCieu8TKY1r+o0seJfFquU7bpk1V/ZFrCmWbAs YrfVoBUpgqipUbvR4IItolHQyrbxyA9EiuA0yQBdwrhDuNcwYmejUNpG3JYOcN8TKdjA nCXluRreB8vAOXHZQ5Uz7phatbZcH2ql3DlDoojpUzkBjrrGCiksab6ZXSUIT9MR53AR iJnRzjJ1FI0gKn2awfrkXjg2s/zLq+vRicNQx1eEhfu8WZm1X4QW2JFwaQfL9TNTCK8+ 1F36z84XSZwq9p/C5Jey3jwhN57Lqeq7tYz9bNWPq4UU4YxRzSHyV4bEylYB/xEOkBKU 2PJA== 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=czWpdkchpjIcmkN5wE2Ao4sOST4MTB7arrN4NTSp2AY=; fh=6XphIdWxfa6Vpt4el4ltSz/1eFeqJAQ3KUirCeZaEUc=; b=RZNJCC4r6VV1auGJhE69SosjGxlFeuMKr4fBUh1YVKCfvtSuQLHwngxK/+AYAZ49Eq ZyZ0kTvb8ANDOeRbpbBSyUeJFj71s0VMHJ4/xumhWZ6vhs53An4uiyiHXYu5ibQgw1S8 PapMH/dIai8uvp0Otc1g6kgo7T/0IJCbOxVggJcia3fqgp28Pq184EgwF00Q6G6gXe1e z6ZldNgIE9cdBFHbvQsWcsdVPpQXBaLAWS+1O2nXVEetOQS8M5izo6byJPy45eqSNZYo N6czNLXhr8UiRXHbOLiEIliTG/GkdLZnwEjW0oYhexIjyfJ9MT1WQ099K0p8yDfVzkQ7 TkEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZAMMWcZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h12-20020a170902680c00b001c9c8c4c6d0si1695569plk.26.2023.10.11.01.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZAMMWcZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id E0E7D808727A; Wed, 11 Oct 2023 01:13:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjJKIMz (ORCPT + 99 others); Wed, 11 Oct 2023 04:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjJKIMn (ORCPT ); Wed, 11 Oct 2023 04:12:43 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 610BCC4; Wed, 11 Oct 2023 01:12:37 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 477A91BF20B; Wed, 11 Oct 2023 08:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697011956; 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=czWpdkchpjIcmkN5wE2Ao4sOST4MTB7arrN4NTSp2AY=; b=ZAMMWcZIv3fUK0YhnOY6IGV91gV13RwXR1jadOMLxKqrh96UtzvCyUR1Qr9RUKkdm84Ekj ogmgBZpcsht4rXjfbkjOVzWBmGYsBed15hgAOlzoXo9OvLDS+9hEOYWTVpdeDmK7UFn6Uz 4jMShL7Whh9qY04DzrIjj2wPqZS+DYjCGJ+PkIXcaotTpiWoNdQ38wSoFwlTlGnRv93aQ0 C12YRSDgaqsUo9u24oi/1Rv37dhG2BDsvIV/GaU9jbz0aGqlOMnwRqcqJnP+61d8NyTglv jeYDppQ7/rnxsnc4MWkteZwtRYVWOpJ3PraMrbgbbiG9U1BTGwDvJ8SzSWuJEQ== From: Kory Maincent Date: Wed, 11 Oct 2023 10:11:44 +0200 Subject: [PATCH v3 5/6] dmaengine: dw-edma: HDMA: 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-5-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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 01:13:03 -0700 (PDT) X-Spam-Level: ** 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 04b0bcb6ded9..13b6aec6a6de 100644 --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c @@ -222,6 +222,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; @@ -252,6 +266,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