From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 382BAC7619A for ; Mon, 27 Mar 2023 13:03:37 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PlY0R5Kd9z3bg5 for ; Tue, 28 Mar 2023 00:03:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm1 header.b=Y61mr9XU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=S8t3E1mZ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arndb.de (client-ip=66.111.4.224; helo=new2-smtp.messagingengine.com; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm1 header.b=Y61mr9XU; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=S8t3E1mZ; dkim-atps=neutral Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PlXzG42JDz2xZp for ; Tue, 28 Mar 2023 00:02:33 +1100 (AEDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id 01DFD582160; Mon, 27 Mar 2023 09:02:29 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Mon, 27 Mar 2023 09:02:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1679922148; x=1679929348; bh=C0t+VBsIdNHlcZByrnG5NPOW3/HDBRin4l1 1iuQ2qiw=; b=Y61mr9XUfXVFhUlJdoF8OWNZ1qM6LGTHSqUwPXey+5SLhbXuszz IX4F35TzFt8tNJqu3TdHQy42BVXRNe3bcFUV8/zj9nSivnmtuzQXp6yIK2l3HJtv arNn0qdsSFaxnf2jpGCdO42ZY/Yo7maZ9JJxQnYT9zQ6fDNdG0CMXLPJSTiBiuYc DxowTYLJD3TZAMG+gAP8IaltLqnFWdByE0RMezkwvVUj8PXoa7+fgC1mMOdcybmk FOSp8xBGb8i1lrklfr+C8l8mm7z3rZwyVo/iOqMqn8kIsrxCMYlMByaiI+EkJOfO AksZxvdJBavSBPl8RAWIMzvbBRTXG6xIPuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1679922148; x=1679929348; bh=C0t+VBsIdNHlcZByrnG5NPOW3/HDBRin4l1 1iuQ2qiw=; b=S8t3E1mZSSbesGBfIrPg8iez5iynYZ434j4/P/C+PFUpzIj6OWt K13vVMOr45Pq/x54idE06yYJdGJHsAgbut8cysdL7NSE20F2ZB97nGf6sGl0XtnJ 9XT1e/v2R2VMawWFs9cAUtCqiZnEUzvQi5oNF6VrsD0uvg+IwkaMgefkI++oVxUX P6oUU+TSxGqMMY77icyCim+29Cz39zEK5CEbEi/5s9/A6kWKWjnkM9cNn+OZr9OG +PTT8iBaVt9Y7UzKaNo9juS2P9bsmSmnzuVEEp99tvwuhj8CNT8gHrMIM+y46L5g RgKT+E9GeicOtbPmieJjqHY7nt82g7IMpvg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehvddgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeegfeejhedvledvffeijeeijeeivddvhfeliedvleevheejleetgedukedt gfejveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 75C74B60086; Mon, 27 Mar 2023 09:02:24 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-236-g06c0f70e43-fm-20230313.001-g06c0f70e Mime-Version: 1.0 Message-Id: In-Reply-To: <52eef604-085e-acf9-f3ee-41ba9d8441d2@csgroup.eu> References: <20230327121317.4081816-1-arnd@kernel.org> <20230327121317.4081816-7-arnd@kernel.org> <52eef604-085e-acf9-f3ee-41ba9d8441d2@csgroup.eu> Date: Mon, 27 Mar 2023 15:02:04 +0200 From: "Arnd Bergmann" To: "Christophe Leroy" , "Arnd Bergmann" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 06/21] powerpc: dma-mapping: minimize for_cpu flushing Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rich Felker , "linux-sh@vger.kernel.org" , Catalin Marinas , Linus Walleij , John Paul Adrian Glaubitz , Max Filippov , "Conor.Dooley" , guoren , "sparclinux@vger.kernel.org" , "linux-riscv@lists.infradead.org" , Will Deacon , Christoph Hellwig , Helge Deller , Russell King , "linux-csky@vger.kernel.org" , Geert Uytterhoeven , Vineet Gupta , "linux-snps-arc@lists.infradead.org" , "linux-xtensa@linux-xtensa.org" , Brian Cain , "Lad, Prabhakar" , "linux-m68k@lists.linux-m68k.org" , Paul Walmsley , Stafford Horne , "linux-arm-kernel@lists.infradead.org" , Neil Armstrong , Michal Simek , Thomas Bogendoerfer , "linux-parisc@vger.kernel.org" , "linux-openrisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-mips@vger.kernel.org" , Dinh Nguyen , Palmer Dabbelt , "linux-hexagon@vger.kernel.org" , "linux-oxnas@groups.io" , Robin Murphy , "David S . Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Mar 27, 2023, at 14:56, Christophe Leroy wrote: > Le 27/03/2023 =C3=A0 14:13, Arnd Bergmann a =C3=A9crit=C2=A0: >> From: Arnd Bergmann >>=20 >> The powerpc dma_sync_*_for_cpu() variants do more flushes than on oth= er >> architectures. Reduce it to what everyone else does: >>=20 >> - No flush is needed after data has been sent to a device >>=20 >> - When data has been received from a device, the cache only needs to >> be invalidated to clear out cache lines that were speculatively >> prefetched. >>=20 >> In particular, the second flushing of partial cache lines of bidirect= ional >> buffers is actively harmful -- if a single cache line is written by b= oth >> the CPU and the device, flushing it again does not maintain coherency >> but instead overwrite the data that was just received from the device. > > Hum ..... Who is right ? > > That behaviour was introduced by commit 03d70617b8a7 ("powerpc: Preven= t=20 > memory corruption due to cache invalidation of unaligned DMA buffer") > > I think your commit log should explain why that commit was wrong, and=20 > maybe say that your patch is a revert of that commit ? Ok, I'll try to explain this better. To clarify here: the __dma_sync() function in commit 03d70617b8a7 is used both before and after a DMA, but my patch 05/21 splits this in two, and patch 06/21 only changes the part that gets called after the DMA-from-device but leaves the part before DMA-from-device unchanged, which Andrew's patch addressed. As I mentioned in the cover letter, it is still unclear whether we want to consider this the expected behavior as the documentation seems unclear, but my series does not attempt to answer that question. Arnd