Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1899080rdb; Tue, 3 Oct 2023 04:49:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6VcCSMQfx3CHGqx26ISkGZrIpRtJiOVDhedbjt38EWhBiL1ZcmZFJCSoZc+mehnV6rfv+ X-Received: by 2002:a17:903:1104:b0:1bb:d59d:8c57 with SMTP id n4-20020a170903110400b001bbd59d8c57mr14126584plh.18.1696333753505; Tue, 03 Oct 2023 04:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696333753; cv=none; d=google.com; s=arc-20160816; b=OWyH6XgUqJHBT1Kpm2r7l7VC+0JcmKDmkNv9iwKUeiNn8JVnTSpeJsfkRWHvB0VXqy Q1iT+GZ4wghS3OYKPyky6ps50Krk/h7NN/8Ij0x1cQci/aD2VM63kIPAarqIM3oxrZqu M9X5jR63paopEMOfLRQtdY9FsbOByXTLxPHUi65Dwq7Z4RKfEwz+fNplhlTMzoIQ5bRo 38FEY6/QfN/Zhc7Aeq6Z1+b1u+/SFB+s19vUNHZdCja20Wrczq7fQhgFuJj8MreWw3ZX ZZ+fl6mxYUBtkac/k6EZkBwewIaNqraBiMp/GTUzBTY1K+NhzGpNsMlwmDDav/1ZP48q j/mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=m6tHL69a/PWxjome3u44isF/AAc7d6tUD65N4GlVjME=; fh=Kgtip4zV1Z0hikPyXit1EknyYDvvf4K7CuIvHM/WMp8=; b=F7TOTgiLUjG+ko4sXZNzHZi3SzNKq8idp2o/XYRqsBN8GxrvBsSLggouHEWVUKijvz 4HOkpYM52Ic9a6EKo5eFP/eR49xWGbfmAdjHaRCRrStvV5c8cpqu4I61d8Ni3TC43ugZ XUzTXOMZsp7Jhib0luI2Ksyim9JdR2ZpP45wCF4ippD7L9QpZxL93+6iqecj5zPfNv8Q pDTrhakGDQrHA6Vq3hBSy9+97UmdshpNudYhB5BaQ33bVpPn7lluyPywN19xlZjoag0E p15teyO13AXZpFK1U2bnTJhIQyhnGZke/v1zBo/PdRxg9bVrGIt1U2I/iwP0/Qoob4up JpwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="XjNI/vs2"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i4-20020a170902e48400b001b886d36bf6si1181299ple.226.2023.10.03.04.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 04:49:13 -0700 (PDT) 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=@gmail.com header.s=20230601 header.b="XjNI/vs2"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id F0225801B395; Tue, 3 Oct 2023 04:49:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231916AbjJCLtA (ORCPT + 99 others); Tue, 3 Oct 2023 07:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbjJCLs6 (ORCPT ); Tue, 3 Oct 2023 07:48:58 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70100A6; Tue, 3 Oct 2023 04:48:55 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-503f39d3236so996973e87.0; Tue, 03 Oct 2023 04:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696333734; x=1696938534; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=m6tHL69a/PWxjome3u44isF/AAc7d6tUD65N4GlVjME=; b=XjNI/vs2w0juS/HSLsTNncKh/dxigZKM9dCWZFLBikXGr9ojIccSBgZC87tWyr9cEP s7R1hDbrBWlPXcRgEGg2XIAtD0NCSYLFDc0qrpNf9uGwIzXHNwG+YLKAhSPY0BsWZBGU wmbd6ArhiM+BxcK6W49BWT8glkUV0VsGI9ffxfdSPTmlU82rLFIvQrDES0+Hzf112aYL cwe2jPsEu4v1pzGjL3XMhp9LwnywCAWJE0rsmGFUWQlA3i5nNSDkLCyM+kCKHTz6fgYH kMvB2Gh/4zZ8kikNFJKUioOfheq3+NyCDVHprN0Ow0UC+PQff4OUIfkRgMSQ9uDIuEGd l6rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696333734; x=1696938534; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m6tHL69a/PWxjome3u44isF/AAc7d6tUD65N4GlVjME=; b=ZePo7979Qjn9o99iFR2r5Jmj80h4S13PxYsxSaoK81gsU6bkzMcwR+QMvvU1qT/D0R q+sxUWW76SSaUsph2lnq8H3Tedua0gjumEsvhvhuZiF/TDYkB6vtAjk5GIB9PEyB72dv cEi3CA1f48lah/2clcXycORZ0LkHzdwCZFdXTdn1Ak1g/cT/ph8pQdASJ0DyAIbacqYr 26ECTJXlnD0SH0uCCOEPvVGERUgkiltFnpFEGTuPeibiSygKcGoe0j/ggD7aJMV3u8pI bvM4BMyzH/h4cxT03H7BaGP/k7Hfs+H/GDTT5bwdUwqM2sMuZs+apw8egmyUWuQqLyEL ghgQ== X-Gm-Message-State: AOJu0YwKIyM6ob7CkejuKmylJFfhV0ucXZyuwKozGzyzlncGK8F8UdUE nHp1g0nunEWNSgwhgA/tD2M= X-Received: by 2002:a05:6512:2521:b0:4f8:6abe:5249 with SMTP id be33-20020a056512252100b004f86abe5249mr11772250lfb.3.1696333733469; Tue, 03 Oct 2023 04:48:53 -0700 (PDT) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id t18-20020ac243b2000000b00500829f7b2bsm162581lfl.250.2023.10.03.04.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 04:48:53 -0700 (PDT) Date: Tue, 3 Oct 2023 14:48:49 +0300 From: Serge Semin To: =?utf-8?B?S8O2cnk=?= Maincent Cc: Cai Huoqing , Manivannan Sadhasivam , Vinod Koul , Gustavo Pimentel , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina Subject: Re: [PATCH v2 4/5] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Message-ID: References: <20231002131749.2977952-1-kory.maincent@bootlin.com> <20231002131749.2977952-5-kory.maincent@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231002131749.2977952-5-kory.maincent@bootlin.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 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]); Tue, 03 Oct 2023 04:49:11 -0700 (PDT) On Mon, Oct 02, 2023 at 03:17:48PM +0200, K?ry Maincent wrote: > From: Kory Maincent > > 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 can appears. > In remote setup we can only use a readl to the memory to assured the full > write has occurred. > > Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") > Signed-off-by: Kory Maincent > --- > > Changes in v2: > - Move the sync read in a function. > - Add commments > --- > drivers/dma/dw-edma/dw-hdma-v0-core.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c > index 0cce1880cfdc..26b5020dcc2a 100644 > --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c > +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c > @@ -221,6 +221,25 @@ 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); > } > > +/** > + * dw_hdma_v0_sync_ll_data() - sync the ll data write > + * @chunk: dma chunk > + * > + * In case of remote HDMA engine setup, the DW PCIe RP/EP internals > + * configuration registers and Application memory are normally accesse accessed > + * over different buses. We need to insure ll data has been written before > + * toggling the doorbell register. 1. Please replace "We need to insure ..." with "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". 2. Please move this comment to being above the if-statement. The driver doesn't use kdoc at all. Having it for just a single function doesn't look well, especially seeing it's static and isn't take part of the kernel API. > + */ > +static void dw_hdma_v0_sync_ll_data(struct dw_edma_chunk *chunk) > +{ > + if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) > + /* Linux memory barriers don't cater for what's required here. > + * What's required is what's here - a read of the linked > + * list region. > + */ 1. The comment isn't that much informative. If it wasn't required then why would have this been needed in the first place? Anyway just drop it since you'll move the kdoc detailed comment to being above the if-statement. 2. Note the preferred style for the multi-line comments is: /* *... */ except for the networking subsystem. It's DMA so normal format should be utilized. I know there are several comments in this driver which are defined in the net-format. Just ignore them. These are legacy code which should be eventually fixed to comply with the preferred style. -Serge(y) > + 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; > @@ -251,6 +270,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 >