Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp850204rdg; Wed, 11 Oct 2023 07:17:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsfeVg/XMfLuhs4fmJz1h/Q8OBy1t6+u+rXchehLbLNOnYq+pWS2WKZGn7gRj9qQ5NWgYB X-Received: by 2002:a05:6e02:1bcc:b0:349:3756:b1ce with SMTP id x12-20020a056e021bcc00b003493756b1cemr26320454ilv.2.1697033870798; Wed, 11 Oct 2023 07:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697033870; cv=none; d=google.com; s=arc-20160816; b=jrlL1LbWunWERODqOPkjIzuKg9bMuu3vvNc6tlVD/Zq/cVRvp+/w4SOmWdRpcn18A2 cTiFbhzakIbtN7G66lTcv1xNryDS793v1/59lCY99lQ/nFLE/c+t6hu3048urWammV75 HkqUVWdDyxClNYs7zJpHj3Mm/ET/YUbDRZ3ChRLmnPrRMmhRNKMxLlEyCPK96QafEdd8 6vaGafNqR5SxiKNsj4qwjL6BqBftKJLCBMW3FdUcWPh/0TkAVnczf4UMtcFWIabTc2Im RO3DBkt+6yW//I7l6VuzWbDrmSSXGSzB2hC5WmkjRhiAGf2Cw8L2og3H8spx3dRi8SPl Epwg== 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=Njx3NaGKWu808jS2rM/MlNFciYIn5u1xCeEnktSSeyc=; fh=6XphIdWxfa6Vpt4el4ltSz/1eFeqJAQ3KUirCeZaEUc=; b=iFwBF0kXmdNu6CXUBiw470QsGdaHIH1srVJNu9v/G7ksMWtzuO6QJvLsn01nxJiBks 1R1Zch2pPEkVzpdUo5c0a3mhD46SPw6AvkUZkCnNkQ0zSVJ3VZLsw0kY+SGZlOfuj6f0 s6C5Sz9IkO0862qWFGoN6ETedsJt5MwV1Fky1VHiJ55Mfv4kaYKyKWNaCy5SH/3cvujQ 4FEZHMnibDW6vnPND/kHqvcvhrKg/MjjSbRUGjaqfrhnu86HDNyoEzXidu5GOjHO06ub 9wDBDjO9ulqYkYXMl9jIIhzdTtnc29fzJ/SpPNw4b5ePYnv0KhheivHcFXPk0BElSoL2 Cr4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="ipH6DD//"; 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 fh29-20020a056a00391d00b00690c1e51cdfsi11940084pfb.188.2023.10.11.07.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:17:50 -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="ipH6DD//"; 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 83FD481D8097; Wed, 11 Oct 2023 07:17:49 -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 S1347047AbjJKORk (ORCPT + 99 others); Wed, 11 Oct 2023 10:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347018AbjJKORb (ORCPT ); Wed, 11 Oct 2023 10:17:31 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E79A7; Wed, 11 Oct 2023 07:17:27 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id D720B60009; Wed, 11 Oct 2023 14:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697033845; 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=Njx3NaGKWu808jS2rM/MlNFciYIn5u1xCeEnktSSeyc=; b=ipH6DD//FVdp9q8zrCoQzSezgKpRCLRy3Cb1+M9S6l4iFonYWRLtNptp5rFbl8s6T3AbAC yzpZrWiPuqYtpjw2+hwYvD2SA9XHV7Iq+Hyep7HXwBsyKmQf5AO5DFPoAFf6xjKVL5RYe7 5NSKEjuAmTcKmyeMyERE5z9TPf/O1J2iz3h2rvoxMcUbGYoCEVBDZUTHQEVo8tbg43Qmhd NIX7ne2Qapu0OyjzMyydb0bmoZpMlP7ij2lRT+salf/xDKQM67nts8HPF2OdbZMx/ngq80 GcRedwOEAQGUf3V03eZ4QtXQGi8QfHjIWt16a/yMAC/IB6ywBXOJhOQnvvHT/A== From: Kory Maincent Date: Wed, 11 Oct 2023 16:17:02 +0200 Subject: [PATCH v4 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-v4-6-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, 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:49 -0700 (PDT) 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 will occur. In remote setup we can only use a readl to the memory to assure the full write has occurred. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Reviewed-by: Serge Semin Signed-off-by: Kory Maincent --- Changes in v2: - New patch Changes in v4: - Update git commit message. --- 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