Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6756076rwd; Mon, 19 Jun 2023 11:50:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VvBwNZOEO9/LStjWqykNuWAZiQ/2WtICIbl6N6a0JMVj8I8pMrbyjCc2DWhA4NLi03/4K X-Received: by 2002:a05:6a20:94c9:b0:10f:9317:153a with SMTP id ht9-20020a056a2094c900b0010f9317153amr6759827pzb.62.1687200610791; Mon, 19 Jun 2023 11:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687200610; cv=none; d=google.com; s=arc-20160816; b=qIdB4isMVXsv3COhNEgIXmV6ifb7bip3e4THEKxEtIxba5UoMvGOZ9c0i3STHTLKCB GrUJHcvrYqnqrqibySoI+iAYIUzqpQAUXvc8gkg3ISHSvMYvpczE9hAJMqNyZEw6g30z Kx+Cw7IryBBLLDliPqKHY4ZmEmHa4ziWkYHE3+5ydZa5cNNnX/dWFiAEk2iZWSs/0nbI hL6NC/Dk1CSXf+u6s2+SZTPFAz7bSAOQbFtZkxYEk5hLUHXh2K2xsnztT0ReUjkKepJ0 xO7Nk2mrD4q0BtPcVzABbV7n2KwuQ82AHOBRqmeEP2NQMeBnO1mjoH4kmjInLggVSnC9 3k6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=bdfkvwi5YASMPpEuIoUnF7CVkCeJJHGf2/I6JPyJWQU=; b=Kvr2JnQfq19EKOGEn6GbzaTa+O3HSIyYsnWtOxkxqFmicbyX63uf57uFRP4b3qkAW7 pUg3cSxaSV6D6lX2zP2koGIOGuB4FwsjgY94Tbrfw+4oBWp/0S2p3Vv3QQs5BzkkMWSM W4G7sFZY+Ov+gSF1LFs4on7CUqTsw7cLrrJ8J8yHaSMf2x9Ef9TEpN2RUuhDvVTuzeAL wRbRtdCx0CE6rLxxHNPXrbTaqRyZgG8+f/o/kzuTfC5gzK7YQP6NnUd8G/UXQ/e/+PzS sHU5e6ImWbLxu4w5A1WWRRLg2CMPqP3QsXYxuINiRXT5Oe9Jz0xtocLb48DTzpogIny5 EHOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cOrV+fPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a63be02000000b0055390839e3dsi74273pgf.528.2023.06.19.11.49.58; Mon, 19 Jun 2023 11:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cOrV+fPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbjFSSlP (ORCPT + 99 others); Mon, 19 Jun 2023 14:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbjFSSlN (ORCPT ); Mon, 19 Jun 2023 14:41:13 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893CFE6E; Mon, 19 Jun 2023 11:41:09 -0700 (PDT) X-GND-Sasl: kory.maincent@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1687200068; 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=bdfkvwi5YASMPpEuIoUnF7CVkCeJJHGf2/I6JPyJWQU=; b=cOrV+fPZMJsmIOrJxWCq30GEPUpalF7Ug4i14220zLMGZOsWLxF/XsoIG2qn5zmhVjdkVN jF3+0bjWITwlFZYaJejasJZeUWPTsA2Q3sKScPC97Y2Noxt9l2CM+LkorzNkixXcorxWAd 9cv3emDLNcNtK68YleAjJ/8RdEpMdrU3oPVV7x6RAmLpyBO8BlHKkB99rpQeeinn4WJjnP I+5J2W5NTaSuplTCeCoNrF1S9KM5QhlH/Cc4X6HNGo/V7+rgHOHDZpeOyKx7qKShn4w55M OuFT/cb3STiJBLyfM+RgMJ40bNKgi2THotxhyanA6gkpOMJ3Wo87FfD2VWEXsQ== X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com X-GND-Sasl: kory.maincent@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E17CD20002; Mon, 19 Jun 2023 18:41:06 +0000 (UTC) Date: Mon, 19 Jun 2023 20:41:05 +0200 From: =?UTF-8?B?S8O2cnk=?= Maincent To: Serge Semin 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 5/9] dmaengine: dw-edma: HDMA: Fix possible race condition in remote setup Message-ID: <20230619204105.620f87e6@kmaincent-XPS-13-7390> In-Reply-To: <20230619171550.3iyujmbre3dpe5oq@mobilestation.baikal.int> References: <20230609081654.330857-1-kory.maincent@bootlin.com> <20230609081654.330857-6-kory.maincent@bootlin.com> <20230619171550.3iyujmbre3dpe5oq@mobilestation.baikal.int> Organization: bootlin X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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 On Mon, 19 Jun 2023 20:15:50 +0300 Serge Semin wrote: > On Fri, Jun 09, 2023 at 10:16:50AM +0200, K=C3=B6ry Maincent wrote: > > From: Kory Maincent > >=20 > > When writing the linked list elements and pointer the control need to be > > written at the end. If the control is written and the SAR and DAR not > > stored we could face a race condition. > >=20 > > Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA") > > Signed-off-by: Kory Maincent =20 >=20 > Once again. Is this a hypothetical bug or have you actually > experienced the denoted problem? If you do please describe the > circumstances, give more details. Otherwise it sounds weird. Here is > why. >=20 > DW eDMA HW manual states that the control LL DWORD is indeed supposed > to be written after the rest of the descriptor DWORDs are written. But > AFAICS it's only relevant for the LL tree entries recycling. Current > DW eDMA driver design doesn't truly implement that pattern. Instead > the DMA transfer is halted at the end of the chunk. Then the engine is > recharged with the next chunk and execution is started over. So the > runtime recycling isn't implemented (alas) for which the CB flag of > the control DWORD needs to be updated only after the rest of the LLI > fields. This one is only hypothetical. It appears to me that writing the control after the configuration of sar and dar is more relevant to prevent race iss= ues and should be the usual coding choice. Also you are right saying that it wi= ll be relevant only for the LL tree entries recycling. Simple question from non DMA expert: isn't cyclic DMA mode recycle the LL t= ree entries?=20 >=20 > If you described a hypothetical problem then it would be ok to accept > the change for the sake of consistency but I would have dropped the > Fixes tag and updated the patch description with more details of the > race condition you are talking about. Alright, I will do that. K=C3=B6ry