Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp719305rdg; Wed, 11 Oct 2023 03:48:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7qVx44u+a6ZRS7qT/aVzwIrgPzyg62bcGLmW1ME1KKN7fF3uzgMBySMHzMvDlyMFUJVCH X-Received: by 2002:a17:902:c946:b0:1c8:7bb8:321a with SMTP id i6-20020a170902c94600b001c87bb8321amr23866773pla.27.1697021282735; Wed, 11 Oct 2023 03:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697021282; cv=none; d=google.com; s=arc-20160816; b=H3/jflvjbtzKZY4tVx16PAPN7bHq6ZsoPT1uIWd5/nf6XwP32BKoF/j56O1cwDIIb8 2w6Tc1D41xyOZtP++s3h/kktPVwQwF0a21GvB3aoslyxFpF/Unr3fvxcX+u2ElP6vb5H e9ZFPwETqzldDqgNib+8BbM/uWYn4DHo3l+7jLU91k7tHtDGjKdZe2pntepzMF0SwIyq xi7p/ZvpLsw/bLcyHVNnAKa5MEePV4eYCagz/IbdCOdj9CuYX1ZOALmOFaWcdUFtmgsT D0BDRlBXJuVkcT+hcZ6k/ENqyVjj8HWBKY+YuFdIxa0ppPDl+ZAY/hrY+hBUh1wN6hPu b90w== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AVKb52P/acdOegXUvVk4ObTPK15ZJRlslOWZhhK70RY=; fh=LfuZ+iraf6fOqV6t2blpWsE8065jwlqlxENUi2SKrgM=; b=jqkyznb5RYQ9xPZSPwGald+c/d3zTGizNdhnfvLdqpjLDCVrU9Q9Wj5vysGK2LaCv4 FwpreHb/QoQa0aUsgWLRsZCpMJpvav6+xBBVCDSjfok3Lj1uNF9t7x2hy8KYRGPAoNpA tDjEEE6raJAp614BA3bejrFzE1BuMIQF+PdrjxJw06IxZ9Up4JXSDPLm5bWXgJS+tAPt vX9whDAbddJw+5z9LJZ5hAeE0jauzMS3soFctoyoEgTyJd3cgkYausl5fidGw+7Zcwkj dfTuqurNa5D17aou8Uubu2LGL/AzMPtI6uB/+xV6OLhrAHzDZbHtCsuw4DtusV1Xi0nR IdKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GQZjJDQS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cr12-20020a056a000f0c00b00690f0a78ecesi11471638pfb.315.2023.10.11.03.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:48:02 -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=@gmail.com header.s=20230601 header.b=GQZjJDQS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B15D8809E736; Wed, 11 Oct 2023 03:48:01 -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 S1346529AbjJKKrz (ORCPT + 99 others); Wed, 11 Oct 2023 06:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjJKKrx (ORCPT ); Wed, 11 Oct 2023 06:47:53 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A40B692; Wed, 11 Oct 2023 03:47:51 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5041bb9ce51so8480320e87.1; Wed, 11 Oct 2023 03:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697021270; x=1697626070; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AVKb52P/acdOegXUvVk4ObTPK15ZJRlslOWZhhK70RY=; b=GQZjJDQS0JFzerIRtunPw55XYZY1CBhImfgV/L2OpcHl95V9Qmgs057M4cVl0SZVkr cSeT00TYwJsplEm8hRDTTh/sioxt7O4eD0Vvqg832B3bTT6Pv7ujuPF32HxZwtRnsXwY tWBYWD+9xBvaXZhRRgKnydapxpg+2fNTw2Kztfn9aEfTFebBrdTgRLE3z0U8b2BZqd3L ZqNsHFwTgrnQkqP+MiZ0I1qOUxzuO1ci2Yc9WCYTT4RVXvK1vaaYQiP/AnceymBgYQsk Z1fuij7iMI/saIMFwdWeJ/ntp5qAqU1uCPRrP4sQUDkmBJ+Ryl5hCA888U0DnbEGy03r 2hrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697021270; x=1697626070; h=in-reply-to: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=AVKb52P/acdOegXUvVk4ObTPK15ZJRlslOWZhhK70RY=; b=VDljj6wepBnf8Hhj9nj+n4OSX1kF1FS1sEzybAMluyz+JUN8x7fsfGqId+q5RVoYD4 qcsvBe3qjdaXrbF6qIRbpvtplczwqffqcSEigElmPFJYK49o1MhroOELLJQvcNvNNb25 /BZvrokRKiqYxC5fvuz1f5UVsP7M7/D1qBh9uk9faoE3VHVayzawsoWsrdR3JBXonHW/ 1R8S3uLqkiuzKAMYjo1zm+Pph+rAxPngqZavUKWbe+zlpXyXJxZCAcWc4p3NiK87Lym6 bIWvWF7gxhT60x/Pf8YWB5X/lwMZ6OVAz45wjVaG/4a09MybFHFiqZxslzOL+9Y9UNNA xMug== X-Gm-Message-State: AOJu0YyCDk/W8qIDwmE3c5m9fUMl7SVoGYd+2l+9lPBo5RoMG900R1GE HwqsLaj0hvvCDVKvANEpIEo= X-Received: by 2002:ac2:5b4b:0:b0:503:c45:a6e1 with SMTP id i11-20020ac25b4b000000b005030c45a6e1mr14760902lfp.46.1697021269672; Wed, 11 Oct 2023 03:47:49 -0700 (PDT) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id b7-20020ac24107000000b004ff96c09b47sm2214345lfi.260.2023.10.11.03.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:47:49 -0700 (PDT) Date: Wed, 11 Oct 2023 13:47:46 +0300 From: Serge Semin To: Kory Maincent Cc: Manivannan Sadhasivam , Gustavo Pimentel , Vinod Koul , Cai Huoqing , Thomas Petazzoni , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Herve Codina Subject: Re: [PATCH v3 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Message-ID: <6adlujxc4cnrxbl5fbqpg5fishq7jvk6w6chgjyktbwcxd2dvi@w4ayo5ooh7fq> References: <20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com> <20231011-b4-feature_hdma_mainline-v3-5-24ee0c979c6f@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231011-b4-feature_hdma_mainline-v3-5-24ee0c979c6f@bootlin.com> X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 03:48:01 -0700 (PDT) On Wed, Oct 11, 2023 at 10:11:44AM +0200, Kory Maincent wrote: > 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. s/can appears/may occur > In remote setup we can only use a readl to the memory to assured the full > write has occurred. s/assured/assure > > Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") > Signed-off-by: Kory Maincent Reviewed-by: Serge Semin -Serge(y) > --- > > Changes in v2: > - Move the sync read in a function. > - Add commments > --- > 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..13b6aec6a6de 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 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_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 >