Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2845971rwl; Mon, 27 Mar 2023 06:10:48 -0700 (PDT) X-Google-Smtp-Source: AK7set9+2h9WD6YPQjrjZNygWpIjKBSL+IJnP1tdK3xSlORjDdrHug3Pnd1XKsjkwkQdOFFlyE5m X-Received: by 2002:a05:6a20:4c17:b0:dd:f73d:17b with SMTP id fm23-20020a056a204c1700b000ddf73d017bmr10828401pzb.12.1679922648441; Mon, 27 Mar 2023 06:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679922648; cv=none; d=google.com; s=arc-20160816; b=EMMBSZei+ka39/Snxq10Faw96MhWnConh5Ig2TNlcal3d1ViYMubvKE2Bee/CBVa1E KZxboihXR5yEuucvQhs0+y6uCBLdS9mK0/Erk4S05W6CfJxpf/84aZApGSBbgY2MT/M6 nV56fpoI96C5oyO0Bk4t+V3lFb3kaBMWwPIvFL+v7zPgyRDkoG/JfiA7EW6rKFi+HKuO Yz501lB4v4DS6bTGXLDDkPylrqzUBYW0Pz+kbD+N+vkI7h+6MfSfQedEMkn77g75gyBy /2y4YLpyQSm2CAhwng32QJzxWlLCD/soxIl4RXGXmATqqs/KyxntrmaqP+mJqf8urKoc f4FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=C0t+VBsIdNHlcZByrnG5NPOW3/HDBRin4l11iuQ2qiw=; b=KE2XpMf5Jm0Z0ou7tvmzmAv4BAm7EJoUYhyfXz/0SKh4Qj9jOdMq+y2ktISBDyMhKo ePqFuqKmNznECqpO7LURfxekyXAE1RyDl99q67REDgrwZkKPVzbnJ3qTecBGYSPh9p8w d6TtDua6/9EGOA7Ghp5aKMh65M/gp3okUX8l4mMp47DAFhdP58Gh2JTTxIblblLRsV2W FDcp7AShHkqm5zOJdAJAJRE9GqKf7q+kOCwrjccEemOkx99ziDAF8lZib9Hqnv5bOu30 gA3XT7RBym3vDCXELa8U0XjAkzTtKWlyKslA+Ktc62kXUTf12qT+i3Bih66RGhS6c05l kArg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=Y61mr9XU; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=S8t3E1mZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s73-20020a632c4c000000b0050bd4b86169si11334240pgs.414.2023.03.27.06.10.33; Mon, 27 Mar 2023 06:10:48 -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=@arndb.de header.s=fm1 header.b=Y61mr9XU; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=S8t3E1mZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232556AbjC0NCz (ORCPT + 99 others); Mon, 27 Mar 2023 09:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232542AbjC0NCw (ORCPT ); Mon, 27 Mar 2023 09:02:52 -0400 Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AED2CD; Mon, 27 Mar 2023 06:02:32 -0700 (PDT) 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" Cc: "Vineet Gupta" , "Russell King" , "Neil Armstrong" , "Linus Walleij" , "Catalin Marinas" , "Will Deacon" , guoren , "Brian Cain" , "Geert Uytterhoeven" , "Michal Simek" , "Thomas Bogendoerfer" , "Dinh Nguyen" , "Stafford Horne" , "Helge Deller" , "Michael Ellerman" , "Paul Walmsley" , "Palmer Dabbelt" , "Rich Felker" , "John Paul Adrian Glaubitz" , "David S . Miller" , "Max Filippov" , "Christoph Hellwig" , "Robin Murphy" , "Lad, Prabhakar" , "Conor.Dooley" , "linux-snps-arc@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "linux-oxnas@groups.io" , "linux-csky@vger.kernel.org" , "linux-hexagon@vger.kernel.org" , "linux-m68k@lists.linux-m68k.org" , "linux-mips@vger.kernel.org" , "linux-openrisc@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-riscv@lists.infradead.org" , "linux-sh@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linux-xtensa@linux-xtensa.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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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, 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