Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1915881rdb; Tue, 3 Oct 2023 05:17:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEfq0SQGgwmMOH4PvU6727X+cqtrvwfyNjooo3HEoj3lRuhYAY1KoNU4I3SxuDajEPadK+ X-Received: by 2002:a05:6a00:39a6:b0:68f:c8b4:1a2b with SMTP id fi38-20020a056a0039a600b0068fc8b41a2bmr3953349pfb.17.1696335460875; Tue, 03 Oct 2023 05:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696335460; cv=none; d=google.com; s=arc-20160816; b=aLe1WBUrbMlw0JALPl0TIT7J5nO3UQg2O5S/sVw6uHW1h3DEezWSvM1WSDuYmiOQxw NBVaiW8S7U0nKbP52h6WrAF6ymvdlD1nHCdIesBXcI2E+ISZ/Xz44/oCWRJyl4E3a9aT /5CGdYciX0ZQeynP2CdCbvbFaFjU610Jf2okS+4CDBeVisQqdA1RW/n6LDJgx8iumcuM UY7+jwiDBA5nNFmYOpv4pg0q6R5nNfdWne4icHmt7FBnWqF1+MLCZlEic7ZbfajEEr+V fcAUg4H9KAeLk2ZiHg2GE/edU52hJW7khD0Q1STeD3h1ai1H/GNlBss81q7voEeVAdSk vDGQ== 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=JYIM3tNiFFR0zjfEW7Gk3VtShpUUYLCyTmhvYTMgjlU=; fh=3Wij1Nyq0kk9iFJBGjsMqOGfirL0oXoeYA+XKMkEeWg=; b=Yl6/GK2LBlUGDNRNqVORqfnVmdrZsDSeZTKDlkVkFb6NN5CWHhLw+nVT0c/E3kfnwO Zg1XixF3YaeC6+US+nswZYAu56lDcbPcwB0b3AkdJgF2mG+AMLI8WlePlRHJrs0vHQWD K4oSk6rPmvpepiA28cqsHNIhXiCdqq8jKoZF6Abx/lAtz2dbtOxS93DO6KHS5GaSx2/Y O9mA4VHCqqcLqItZvDIsBt97rJioo0x7KbTgykIhVc6VRWBoLVnmKPiLBLWZN65tOEos IvgKNNJ4fA1IMneujrRRa/vENBEXmUokp1BVA5KkQBYnCd7L9mW4wUwy+EYizsrwFl3F GLdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PYs49n2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id c5-20020a6566c5000000b00565322ef4f1si1311924pgw.348.2023.10.03.05.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 05:17:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PYs49n2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 156398022EB4; Tue, 3 Oct 2023 05:17:37 -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 S232317AbjJCMR2 (ORCPT + 99 others); Tue, 3 Oct 2023 08:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbjJCMR1 (ORCPT ); Tue, 3 Oct 2023 08:17:27 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45B72B0; Tue, 3 Oct 2023 05:17:23 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 954B840011; Tue, 3 Oct 2023 12:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696335441; 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=JYIM3tNiFFR0zjfEW7Gk3VtShpUUYLCyTmhvYTMgjlU=; b=PYs49n2cNSQGH/Fph/PEE6lvszszbpznmyJAdTd0UewNnXpfR5egwA4cuKmqGHLk4du30x 4YaxvYFvT1HojElO3pweMTx71ndfyZX09vy13NQhY5xoSvkkOI6jdEEYlqeED9zroKpopt TqvwCydlCKR7dVLx9i5X9TxKdAATrDpWfd+T52oBsOiywMGflO3CeVcsKaD8sicGG5SNAp +wAQZi4mh0IWNOHCo/g0YNdzf/2AALNaadanGb3FOasiv8zvB63sHKLWLMjMicsGZWnr0C +naThHHWSW9E7cZ53Sf4p8EP/4GUkEYUY8HgqkgzE05xTmYWzMA/5+sHLce59A== 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 5/5] dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup Date: Tue, 3 Oct 2023 14:17:20 +0200 Message-Id: <20231003121720.3139967-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 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]); Tue, 03 Oct 2023 05:17:37 -0700 (PDT) From: Kory Maincent 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 --- 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