Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp403908rdb; Fri, 17 Nov 2023 02:05:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3zw0L8iFQvMy5hjBaEI0wTCMc0Uw9oeS4xdql8OWF/iS4XItpw0pyZ232NJkrkyHTSa1j X-Received: by 2002:a05:6a00:22c2:b0:690:f877:aa1e with SMTP id f2-20020a056a0022c200b00690f877aa1emr7159146pfj.12.1700215512082; Fri, 17 Nov 2023 02:05:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700215512; cv=none; d=google.com; s=arc-20160816; b=xCLMnivngNHfA1dLVZPijw6bJhTCyc6ORdBeYW3QMwUJv3hgeGWWHtqBnTKUgBkDjd pUl1andjodgaRF2wtP4JKgeBotoMCFhdhDJpVpRjt8vlrHZhnzFEcZXMgyReqCb2L8Ee Uz10KIU9gwG+ZHdtLdsS2QEiBnozpo9VwqGiIr2JgHaISjQA82pYilWv7dGnJftyty9n Xt9xmpI3OAfZZoItXI4XCEfQlmJvVHbjc3AFwmEo9EY8EyUgWcyjYdFPyUjdCP37XeMO /qOIWyKr/tBnC2e6RPSDvqjjFhkGKSHsSeKLSVVStAfuyDztfSvEvWXpE70fwaeYTZUF f9kA== 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=ppALPMc1pFTIFQzwRMW+tmzwmtQj10e6/dO7SG+F1wI=; fh=Fko32OqwGgI5WpcqYpp5KigXgtelsKMiigtnZERCGL8=; b=c/+wXk9l45ZK7WQm7NrSMHbgYqbTo8mqXwbRR926Wl7DqpK8NNKbotnisBGM9r8gbu VNUUJgTf+ihaPLc5/ApkqVmdROGLq+6RGpaMtcZhvquP/yzNreBqjfO163YhnhmBWPsp NMnw4rEvb6mXfz5LkaHKtXBdQDGTyaKAPmKLAGFxd16fEAKkwmRFpen8Awak2sJISWtz 2fnH8uHPuQJkIxvHiH8cr2Chp5OygIZCo/DrVMsCFIX7Sb6nM1L0CNzgo3Ik/0uhWKtz C8fcyZ0GLk9gpK0NkBPKu3sj6fwP3JvYs9u9a/IXev/80FaS6N150d8SkXaaLeJv/DTd Vdcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Nk9QOBXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z14-20020aa7888e000000b006c69c3a5d7bsi1661299pfe.79.2023.11.17.02.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:05:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Nk9QOBXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 1F53C809E210; Fri, 17 Nov 2023 02:05:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345900AbjKQKEa (ORCPT + 99 others); Fri, 17 Nov 2023 05:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345812AbjKQKEO (ORCPT ); Fri, 17 Nov 2023 05:04:14 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 345C6C4; Fri, 17 Nov 2023 02:04:10 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 61BA3FF81F; Fri, 17 Nov 2023 10:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700215448; 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=ppALPMc1pFTIFQzwRMW+tmzwmtQj10e6/dO7SG+F1wI=; b=Nk9QOBXXkZe4llaGhdKMLdybPq2Ys+qCWgZHo0Pqu1T/I1N0M3dRksIcsoMHP7nr5dtfxf 6i/sa+juuDTM+sP6A8BzmOF5UvDxgis/3p0tNggqxlk6nvDiHiVJ66i3UxsbEGn8rNw8le 5QSFaLRjEDZpgXIBZRUlVjICboIiEyp7IA+8UjD841jsPLL6MpoTpOuoNIH34uBqZTRmFj l4xEwiaZ74ODB4KZez8YoSvsWpSBRdhOTYNxbFcYgl3vLOL+cLUrswuB+sEgOOBqptNK/y +R6DIe+sLhbC82Qkx6wZGL9NojMmTkyB1B8buzuZ85auJPJIEQsMJS//3YxCsA== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:53 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-5-ebf7aa0e40d7@bootlin.com> References: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@bootlin.com> In-Reply-To: <20231117-b4-feature_hdma_mainline-v6-0-ebf7aa0e40d7@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 , Manivannan Sadhasivam X-Mailer: b4 0.12.4 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 02:05:09 -0800 (PST) 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v2: - Move the sync read in a function. - Add commments Changes in v4: - Update git commit message. Changes in v6: - Fix comment typos. --- 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..10e8f0715114 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 internal + * 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 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