Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp403807rdb; Fri, 17 Nov 2023 02:05:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHASBpwSaulERmuA4ibTbNqKCAmR7a8PWSsd3azWFKbONUY5bVBHAtN6BTE0Liq2X46aVJn X-Received: by 2002:a05:6e02:168c:b0:358:141:8584 with SMTP id f12-20020a056e02168c00b0035801418584mr26392010ila.17.1700215499896; Fri, 17 Nov 2023 02:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700215499; cv=none; d=google.com; s=arc-20160816; b=P6F9vFB3IvcMVUq67ralVN4IC9u0sCkVqgXrICVAa6yUP3oLGAZlg9Vz6cuuEPTi7Y kXoPRXtfdaDFteis0EdS+J0JTNiMPNj8D5wpKmbb9wcy6hwtISnU1nWbUIO1py5gY5jV VbHgJpB7pave0d5Z4j77cgJ8XnqBXoU7zSpTz3386FnP7vWwblmEXA50HqzFEEVHrbKt iH3EUlE8orB+qHtahESQ0xk56cRI9sC8fQTmLD1z9q71Gx02ULIY857cgdtjC22sHfke zdHInuk0+piRH+tNLu+37qgokx2RJVRbLbt5+UfPpHYFDK5/Ik0W8qUBiWd2hEBd2GZU 7oXg== 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=NmKeLzmrWDgqwybx3yFMvQV6TVy/TJmLs+gOb6jsjkI=; fh=Fko32OqwGgI5WpcqYpp5KigXgtelsKMiigtnZERCGL8=; b=Sqp2EMlXHnRO2NivuclCKupl02ooqgc2pJM1U7znwlTKagyGZRh7qNOLraE3VVIfx1 qEt6v/t9Z2laWKALLE4YAZ0LSHmPpCQanhMWkKAJw3n/Ctf+HZP9s2TJkViW8+y5X61a 6rNTq0AqC8G8GqHSqGbX2o5erJJgkIwyton2gkBH2dVvwZZ5glJByKWkYgNiKIsd+YTp ZDpH9AQ8P8UpE789KJ2LAvk9tvbvL6uzIE9PtujOsRnY3rr4pm3vQVl1elBWMXLCPBXM xyTTULNlCCfuSD+ougTY48ioCzSbzR6K4kKA8ZCfWdS15HZFSbZpfUW51PXXVAF3lY0s +mcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ifWxZU5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id k14-20020aa788ce000000b006c386ea46f0si1648615pff.1.2023.11.17.02.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:04:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ifWxZU5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 7DCF7820D5C9; Fri, 17 Nov 2023 02:04:51 -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 S1345851AbjKQKE0 (ORCPT + 99 others); Fri, 17 Nov 2023 05:04:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345810AbjKQKEO (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 ACFC7C5; Fri, 17 Nov 2023 02:04:10 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id F0408FF80E; 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=1700215449; 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=NmKeLzmrWDgqwybx3yFMvQV6TVy/TJmLs+gOb6jsjkI=; b=ifWxZU5MoSMJa1RExPWzueMckAhDz+/FP9AYay2y7oLb+Zalg5OPxS+uJSZ6G4PLL7tG27 7B6Ezqo8uZROfk4rgCJc6dbvYgIY0+mmsg5++iTo+2fcRvuDlLaiwaAPAf0dyV1+8PobEE skGRJZEe1YrNGNOeLk6h94G5RCnogZx93R8UT/syiH7T0M9ZLWcTVt+xB67YQ+n6/3r0tV IGok0iY52aiynYO0qUXH50zKQ3zI/Qe6E8pLLQT4iH9YOGT69DmSBzVZnc2wkvYBBxQHs/ 4/1BS0mmd0dfRSU8bMiJBmTHfAEEK2aqW2EIlzEH2dGTFVoTpf8JR8kZfqoNKg== From: Kory Maincent Date: Fri, 17 Nov 2023 11:03:54 +0100 Subject: [PATCH v6 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: <20231117-b4-feature_hdma_mainline-v6-6-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:04:51 -0800 (PST) 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Kory Maincent --- Changes in v2: - New patch Changes in v4: - Update git commit message. Changes in v6: - Fix comment typos. --- 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..b75fdaffad9a 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 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_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