Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp850116rdg; Wed, 11 Oct 2023 07:17:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7hXu3t2uDF/6tGuJEbgmCdxVHC94vbSzftCp6+d7+p9XD8DtAsKo+VfL4/kJAwEY8b0SH X-Received: by 2002:a05:6358:591c:b0:143:7d73:6e66 with SMTP id g28-20020a056358591c00b001437d736e66mr23853674rwf.1.1697033862650; Wed, 11 Oct 2023 07:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697033862; cv=none; d=google.com; s=arc-20160816; b=SS0TLYABa1ztOFTkOlgYvlgTQ1iH+Zc3+UWW7bl8eHPt9dglBTPHjHDF9TmSg+w+GG 4OxbZQujSvfH9P2f0GtUaZmtiIOgv74hgwIjJKWApkWmH4yMpHAQFKzxSqJYbpJakifP rG2/Rx4RJdOk0W/WlROxLc8k3DadQwb8W43xn+9gpPTHLco7/6QllzuxdRoK541G9bsi TEW1QYKAKaYaSbFhF/UCItsCddjwPhpDzzeMW2efuUzIdF3GLUBlcdlGc1x4ZLrK0gwu gWDSdLeSppQXzqsnanyUBJhBweQ6dd4IsJkNDQ5q5pbp4Ylts/QroMv40HrqalysrlSL wXAg== 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=3Qhez83D04lqPrphmv+D5bpPc2p/1oEARmA8MsTrJgs=; fh=6XphIdWxfa6Vpt4el4ltSz/1eFeqJAQ3KUirCeZaEUc=; b=Zis10VjIYJQv0a4ZMsMe52noLBQ8fNyr1NrD2U93AYV401DBtD7ybcywIRWkimgdGx 7ryNaUXfA1KH3EJ2pSgU1DyY/x1eqqNPpRovRdo3OkriOTa/cyuuWXr2eAGdVaFRnMhc d81YoTOJyosg+wbX6eHK3Emk2B6MQy+Rs9nDEnzkaeyUmAKfQ0rFxmQucETn0bj8mcy3 Vkq7kQvUWPPMVHfE4dx1domoQdJU/nERQzpgjmCMgAcpA9/XvNEaR4C8m2yb69e0vl0+ nMKDyarKBsJVTw6OwwVHiqurcbCJ3ywy95SMU1OJ2C1f2iSTZJ77zBXUiIwsRhVrkG8g bGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="TLSILp/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 206-20020a6302d7000000b00573ffd25b44si14499333pgc.182.2023.10.11.07.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:17:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="TLSILp/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 5883281B8032; Wed, 11 Oct 2023 07:17:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347006AbjJKORg (ORCPT + 99 others); Wed, 11 Oct 2023 10:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346995AbjJKOR2 (ORCPT ); Wed, 11 Oct 2023 10:17:28 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B4F90; Wed, 11 Oct 2023 07:17:25 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id A40D060003; Wed, 11 Oct 2023 14:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697033844; 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=3Qhez83D04lqPrphmv+D5bpPc2p/1oEARmA8MsTrJgs=; b=TLSILp/S+m49x09dkKN/DXLFhiGlb17OCnRUqqiliB+cuwF8NTK70vHgazrYAehPPvOXRs 0EzeYSJr10E+uTLR5CJKDeASLuvTlcKwK6JPWDrQDsMQL8wRvMFHchTV9QIxcbNk4tb+lw 8lAz97WK5UNTMOCTHEXLByP2DsYTirQU3wYfMr/jYYcaePzYQ9cQcuKVFmtDYMtxy/fnkV Pa27vTcy5GYGclOfQDRDW8AtAVd5EQSow0WrxATZLrYd0RuAHAT3H57BXzgpZCrjavOPGx cERGySqatkX730aLYOtlR2MQcXzNxIynJGcy6ZQ/9msY/8D2RxRnQoZC4RDWQg== From: Kory Maincent Date: Wed, 11 Oct 2023 16:17:01 +0200 Subject: [PATCH v4 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-v4-5-43d417b93138@bootlin.com> References: <20231011-b4-feature_hdma_mainline-v4-0-43d417b93138@bootlin.com> In-Reply-To: <20231011-b4-feature_hdma_mainline-v4-0-43d417b93138@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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 07:17:41 -0700 (PDT) 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 will occur. In remote setup we can only use a readl to the memory to assure the full write has occurred. Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") Reviewed-by: Serge Semin Signed-off-by: Kory Maincent --- Changes in v2: - Move the sync read in a function. - Add commments Changes in v4: - Update git commit message. --- 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