From patchwork Mon Jan 29 16:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 193587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp688265dyb; Mon, 29 Jan 2024 08:41:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwhGpXGm4IUt6xFUcNA66wTsklVGmo7JFZS0Rd21BTb3e0C+t7hrUQH9UG2kCmXcAKf0nN X-Received: by 2002:a05:6358:8826:b0:178:6db3:27d9 with SMTP id hv38-20020a056358882600b001786db327d9mr1946167rwb.40.1706546479491; Mon, 29 Jan 2024 08:41:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706546479; cv=pass; d=google.com; s=arc-20160816; b=nPOjdvrQ1yk9jlHvM6wTl2kb45bmWQSDYuGp1vlrm4Msq0Yv0cOQdRIfXVPhDwQVPS 3GI+SR+ycFnahVvXPTGTqqZgRw7GF9FWCUrEJNV/lwd6NL8oL4cSzu4V4cCqYfsiIfLR 6HOwd5NyCct5xppTEWpoT/kEJNwBfaL1XFtWyHJMb7jzla3ZW5b2mX+sFx1gqavITbQo kTOOroIJFVQA93Q0huRWeJBK+5pxI8jSxTDWGpFtowhh+m0Gfzo4GuxmdsYNJbAE1BQb +OSGV3aUh4p0uhjb19/8uhG5ibXxxKLo8T+uyf98K0/51aZOysKg/yyes+Wz4p0MAeC5 uuPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ppALPMc1pFTIFQzwRMW+tmzwmtQj10e6/dO7SG+F1wI=; fh=oC1+pIJR2tZdBb9Uzp3yLjqrVYle+8srf2TBxoXLW2Q=; b=wIh0R+wCwKudyBW8tEr4biXW2GU/WZ88Biwh8u8sc5rF7oCeAGaTZrBmHiX9w1LZFP WD8fr2yusHoAkw6A/Lz20HgxoUO0i1sgVswoVGxoNgrLXmn31HCbuGHHuwkKj8N4VHF/ vANL7tIbLrP1wbM7AqXIgPZLcW6wYodGsnBuKThzPlYXaQzH7op4O77+TE8kkpw6afuD oAALTzlUBGBqW6YpFATpka1FJAsEwElPpBVfugD5JQKYGu3D9Mfhc0/hTSMlaqnn2URb vXIHFEIKtrATiZufXjTmWB83FFD1TKmbeiaZS9fDMLRsnnhqXDtIudOi9nknPKETPeVH Xymw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Z/PZCM9X"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43077-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y23-20020a63b517000000b005cfc01363cesi6100504pge.309.2024.01.29.08.41.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:41:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43077-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Z/PZCM9X"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-43077-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2935BB255EE for ; Mon, 29 Jan 2024 16:27:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 137F31586CB; Mon, 29 Jan 2024 16:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Z/PZCM9X" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6A4115696E; Mon, 29 Jan 2024 16:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545572; cv=none; b=JmprdtgxrHKNl+pN8eyCPADhrZQfjyaLC7Bkz4YAbLSZQ0br4jR2vGCgy2nTa8GgrwD9xM2oF8BssMsivdOEnrTIA8ph7KlE3FDTRYkd/1LGVHGJs9GhuvlEPQmVa3mIABmOEhWD7t3dmHZ6MEYjehCHG/wT2+QEbwvzyan8Upk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545572; c=relaxed/simple; bh=x47cesg/6O6mFEGId7nMSQjKtzbnwyjiAJgM1rfNKwU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vgupcv1aGY4EQEHJQIsYRfkUppTej8Mawib14bdRkixk9keeac10CDutaCMuePIqFgpXXcmS/JrqmYEwIEX5nxFsKqkNPaej98PvjnRBdeWkM6I6V3zk9frC9R1WFnlUBK3jjMN2SbpUSj3g3cXGlfb99jk8B2aytClKjleqGXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Z/PZCM9X; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 48A5FE0013; Mon, 29 Jan 2024 16:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706545568; 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=Z/PZCM9XZQ+0pHNBkgC7DcZmmNkE0NvU9jCHkgzF3yWHCmxDNzwo50FZTQx3XS4TiPgOWe bpieuxk7/MuoiNSEuY17Fu0fn8Mlaw/BDC7HvL8nHPUM7oIym0S1XeqsIipMIi1KU/3Iz6 zLsS3/chykKR6FJ1GduyBpiw5NSnbp5TaQ8S4do5O50RYxfM0qD3aqmwg1DHWRZMXSEliq 4S/VF6Zsi3wiSkBiEMsq1FIb19qQtldI/PmKWxoXD70n4nXTUDCZO58nRuoYTZzIy3UvyL Ucl/pm4GiwBcewYVcDeCOQrfaxH9G5lhQJBkKqE8msGclGxL/61lRZaW69wciw== From: Kory Maincent Date: Mon, 29 Jan 2024 17:26:01 +0100 Subject: [PATCH v7 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240129-b4-feature_hdma_mainline-v7-5-8e8c1acb7a46@bootlin.com> References: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@bootlin.com> In-Reply-To: <20240129-b4-feature_hdma_mainline-v7-0-8e8c1acb7a46@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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789443681376291003 X-GMAIL-MSGID: 1789443681376291003 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); }