Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4180405rwb; Sat, 21 Jan 2023 07:09:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLV2kTzFiIjTUmYoj1WwN5MXxa1/mHzKeKEdx93IhG6jJqqSFp+baZu+axWnGXNiwXzNYb X-Received: by 2002:a05:6a20:7b1b:b0:b8:7c95:de84 with SMTP id s27-20020a056a207b1b00b000b87c95de84mr15943890pzh.33.1674313788924; Sat, 21 Jan 2023 07:09:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674313788; cv=none; d=google.com; s=arc-20160816; b=P2ctZVjXXV/uTs9glLIazm0akJxdz+K85o4US2VfLPn1Lw7afq+gXix/Jl+TpACG87 JL/3i1DluQl3LMRgaQKiFvOtvpRlkbR9eiBivdly0x3ruFrGtH2TJQzWCiTHK43GElhS u8UgfwnryBSW0hXAFNnWSnfqaRIV8Eoht1A4D6kU5Ow12ZWTCXqXV2kRxD8Zrjy0HUBw kenggzEJO56VlrnqZbDJ+YEsxRDPeE/LDvJ0HSJdohiVKvoRkQLHtxixKjOIE8BFsbF9 mE72JqjUnktRzfNUUCb/weISwg3GQ97ZePmdEAA5Ct/a5yef1ESVPTL25klRIYORc0og pW4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mvRXkdOvA6LzmSEnYuUMaqSZFqGIPl0Kd3ZyZC315l0=; b=cxjbKWNWQc9nJg2mnm34QxGMalSkq69tBtmGRYZVwSebgZ+9qLXpSEYVBh4NEmdWAX YPfs6ctHyjWo5uhkNX9JTonyM9KgXDcXmbN5jt2yC2gaZQEmxckHTfpNycQWmBbqo+tY DZosMtBSYjGJlWxPWIp+/kGRTuIH+PxXc5vzaUF4Out2Lp5bnRpm/2tgyM0USmyaVNk/ LuTQRIxFO6bK0FBddsM7k73l5OeBz9/MEhJCtETHBb/pXNjxLYnrDmfossVIDR7/Aa9t HchegVtRYsE4gBfUEsbiAK8ne0aJLxoIfOixnSURiUdiFgCkCHvP8sveba0hdFsPvipk 6d4Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a63f508000000b00479503041c4si52130685pgh.368.2023.01.21.07.09.40; Sat, 21 Jan 2023 07:09:48 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjAUOhl (ORCPT + 52 others); Sat, 21 Jan 2023 09:37:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjAUOhk (ORCPT ); Sat, 21 Jan 2023 09:37:40 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236441B0; Sat, 21 Jan 2023 06:37:38 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 33DEE68CFE; Sat, 21 Jan 2023 15:37:33 +0100 (CET) Date: Sat, 21 Jan 2023 15:37:33 +0100 From: Christoph Hellwig To: Arnd Bergmann Cc: Christoph Hellwig , Prabhakar , "Conor.Dooley" , Geert Uytterhoeven , Heiko =?iso-8859-1?Q?St=FCbner?= , guoren , Andrew Jones , Paul Walmsley , Palmer Dabbelt , Albert Ou , "open list:RISC-V ARCHITECTURE" , open list , devicetree@vger.kernel.org, Linux-Renesas , "Lad, Prabhakar" , Philipp Tomsich , Nathan Chancellor , Atish Patra , Anup Patel , Tsukasa OI , Jisheng Zhang , Mayuresh Chitale , Will Deacon Subject: Re: [RFC PATCH v6 1/6] riscv: mm: dma-noncoherent: Switch using function pointers for cache management Message-ID: <20230121143733.GA7415@lst.de> References: <20230106185526.260163-2-prabhakar.mahadev-lad.rj@bp.renesas.com> <6f7d06ef-d74d-4dfc-9b77-6ae83e0d7816@app.fastmail.com> <9017adf0-acd4-4c43-8aea-3579b214b477@app.fastmail.com> <45d6eb0c-cbe3-4a83-aa12-3483638473ae@app.fastmail.com> <20230110070144.GG10289@lst.de> <02988e70-b099-46fd-b260-2d537c50543a@app.fastmail.com> <20230113054807.GA23179@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 Fri, Jan 20, 2023 at 06:04:37PM +0100, Arnd Bergmann wrote: > Having looked at this some more, I see that the powerpc > version is a bit problematic here as well: this one > flushes the partial cache lines before and after the > DMA transfer, while only invalidating the full > cache lines. That feels really odd, and might be worth a bug report to the PPC maintainers. > Obviously there is no winning either way if the same > cache line gets written by both CPU and device, I'm > just trying to figure out what behavior we actually > want here. There isn't, and that's why we require DMAed regions to be cache line aligned. > Aside from the question for how to handle flush vs invalidate > on DMA_FROM_DEVICE, I'm still trying to figure out how to > best handle highmem with architecture specific cache management > operations. The easy approach would be to leave that up > to the architecture, passing only a physical address to > the flush function. I suspect that is a good enough first step. Especially as I remember that some architectures have physical address based cache management anyway (unless we removed them in the meantime). > A nicer interface might be to move the > loop over highmem pages out into common code, flush > lowmem pages by virtual addresss, and have a separate > callback for highmem pages that takes a page pointer, > like I'd rather avoid multiple callbacks if we can. But maybe solve the simple problem first and just pass the paddr and then iterate from there. > > struct dma_cache_ops { > void (*dma_cache_wback_inv)(void *start, unsigned long sz); > void (*dma_cache_inv)(void *start, unsigned long sz); > void (*dma_cache_wback)(void *start, unsigned long sz); > #ifdef CONFIG_HIGHMEM > void (*dma_cache_wback_inv_high_page)(struct page *, size_t start, unsigned long sz); > void (*dma_cache_inv_high_page)(struct page *, size_t start, unsigned long sz); > void (*dma_cache_wback_high_page)(struct page *, size_t start, unsigned long sz); Btw, I really don't think these should be indirect calls. For sane architectures there should be exactly one way to call them, and the onces that have different implementations really should be using alternatives instead of expensive indirect calls.