Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp559341qtg; Fri, 31 Mar 2023 10:14:34 -0700 (PDT) X-Google-Smtp-Source: AKy350Yr3HqNYiemWNepEm05FMVXITSnNxxLyVQ4T5zBwQe7+14WIa0dvdXPH6fpz+XYKi26YlHy X-Received: by 2002:a17:902:7c0d:b0:1a0:7663:731b with SMTP id x13-20020a1709027c0d00b001a07663731bmr24216111pll.5.1680282874382; Fri, 31 Mar 2023 10:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680282874; cv=none; d=google.com; s=arc-20160816; b=eK2NdiFqT4QCUb8ZU0Ii2CUIgD3UJJwVR8lw4fhYSoWUudalcedC5aL2Cc5vm90c8A KyuaN/zwuI9URUBhiAORV1mJnud9WJ+DsEwWxueyEOlEdOL0mM2m7epwcOQCHDQEPPLo 3ejaObtmYJjMQEzBGih4/uDqueh9B4R/vvmP+BobTSztodZeYCBKTpB1ogvQJ1Zh0718 xBD2dWXtIgXmnv/iyLEfmyKO1vFsiC9W1HzpVTGBz1ewbZ0jOgBhIgpbyt3xqowWJ5s7 6mhYwcusLh/On76+hIjDLGREQEt4VRO774MJJiQIWW8jn7okHvYuPxK8NnATHiZpIWEZ XZMA== 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; bh=p8oZlDmf8vrBDZkp981SSmw2fjcW/U497MwRkJceKZQ=; b=HfAFdDUZR6lrVwapKX9ylAoaTJIzKrFGjybTDl9df0hdz8ekb4oblRfMjoDUM8Fojj SYuF8CUvrp6CQ2O7ynXkyj+gPf0HBWMK/IFyrbdHDlc8LjNf/EOkGATiREra48VuuvRe xMClh12AEGB/9ehxLnXI3jE4wba56DNpm3JZzh2RVN3OznTlb17Brk7lqZBMrQ6Maxj9 xYxa6d8+sOmHOJvzKSUvEyL+qoBQKHJc/zlBliUHR5Bqy16wTyS0B/NBV0YF7x8EaS4N rMscLls21afSRqUzVQpTDD7YFHkq1fet3opsjEV92qxh9slVUZQ01VN+YjgrZDbBsdZH RE6Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ke5-20020a170903340500b0019a826d304dsi2225578plb.633.2023.03.31.10.14.23; Fri, 31 Mar 2023 10:14:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232897AbjCaQyg (ORCPT + 99 others); Fri, 31 Mar 2023 12:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbjCaQyJ (ORCPT ); Fri, 31 Mar 2023 12:54:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8CE6EA9; Fri, 31 Mar 2023 09:53:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4BD1EB8310E; Fri, 31 Mar 2023 16:53:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 457CDC433D2; Fri, 31 Mar 2023 16:53:48 +0000 (UTC) Date: Fri, 31 Mar 2023 17:53:45 +0100 From: Catalin Marinas To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Vineet Gupta , Russell King , Neil Armstrong , Linus Walleij , Will Deacon , Guo Ren , Brian Cain , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , Dinh Nguyen , Stafford Horne , Helge Deller , Michael Ellerman , Christophe Leroy , 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 00/21] dma-mapping: unify support for cache flushes Message-ID: References: <20230327121317.4081816-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230327121317.4081816-1-arnd@kernel.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 27, 2023 at 02:12:56PM +0200, Arnd Bergmann wrote: > Another difference that I do not address here is what cache invalidation > does for partical cache lines. On arm32, arm64 and powerpc, a partial > cache line always gets written back before invalidation in order to > ensure that data before or after the buffer is not discarded. On all > other architectures, the assumption is cache lines are never shared > between DMA buffer and data that is accessed by the CPU. I don't think sharing the DMA buffer with other data is safe even with this clean+invalidate on the unaligned cache. Mapping the DMA buffer as FROM_DEVICE or BIDIRECTIONAL can cause the shared cache line to be evicted and override the device written data. This sharing only works if the CPU guarantees not to dirty the corresponding cache line. I'm fine with removing this partial cache line hack from arm64 as it's not safe anyway. We'll see if any driver stops working. If there's some benign sharing (I wouldn't trust it), the cache cleaning prior to mapping and invalidate on unmap would not lose any data. -- Catalin