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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25EE9C38142 for ; Mon, 23 Jan 2023 14:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbjAWOqs (ORCPT ); Mon, 23 Jan 2023 09:46:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbjAWOqq (ORCPT ); Mon, 23 Jan 2023 09:46:46 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3089029; Mon, 23 Jan 2023 06:46:45 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 37A2D68BEB; Mon, 23 Jan 2023 15:46:39 +0100 (CET) Date: Mon, 23 Jan 2023 15:46:38 +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: <20230123144638.GB31126@lst.de> References: <45d6eb0c-cbe3-4a83-aa12-3483638473ae@app.fastmail.com> <20230110070144.GG10289@lst.de> <02988e70-b099-46fd-b260-2d537c50543a@app.fastmail.com> <20230113054807.GA23179@lst.de> <20230121143733.GA7415@lst.de> <6a64b0b5-0ebc-43a5-a3d8-483a845a0b5e@app.fastmail.com> <20230122072759.GA3703@lst.de> <7ad668ba-d6f3-4ef9-9335-e42bfe8d4cce@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ad668ba-d6f3-4ef9-9335-e42bfe8d4cce@app.fastmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 22, 2023 at 12:04:35PM +0100, Arnd Bergmann wrote: > > And I'm not really sure I'd like to go beyond that - making it too > > easy pluggable will make people feel more comfortable doing stupid > > things here. > > I fear the bigger risk is still making the functions callable > from device driver code than it is to make the functions > globally settable. > > You introduced the mips version in f8c55dc6e828 ("MIPS: use generic > dma noncoherent ops for simple noncoherent platforms"), which > was clearly meant as an implementation detail, yet we already > have a driver that slipped in with 3bdffa8ffb45 ("Input: Add > N64 controller driver") that just calls this directly rather > than using the dma-mapping interface. MIPS actually has a bit of a history of these odd bypasses that it seems like this driver copied. rmk has been very worried by this bypassing, and in general I agree. But there's only so much we can do except for auditing drivers. Especially as none of these helpers is exported and built-in only drivers are quite rare. > > And yes, maybe that's personal because I've warned > > the RISC-V people years ago that they'll need architectural > > cache management instructions yesterday and the answer was that > > no one is going to use them on modern CPUs. *sigh* > > To be fair, from the ISA point of view, it really shouldn't > be necessary as long as you have a sane SoC design. > In practice there are always chips that are cutting corners, > or use the new CPU core as a drop-in for an existing > design. Arm SBSA tried to enforce the same thing and also > failed for pretty much the same reason. Not wiring up IP blocks for cache coherency is cheap. So it totally makes sense for dirt cheap SOCs, or even for low performance periphals in general. The GPU folks also believe they can make some things faster by deliberately turning coherency off on SOCs that support coherency. In addition to that cache maintainance is absolutely needed for NVDIMM support.