Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5109554rwb; Sun, 22 Jan 2023 03:30:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtdwq72YwnMPn3BPaoT1ZE2kX0hH7tVwARymC2FYfeb2gChkHIix4t8P1P9ik3HTBxK9MNP X-Received: by 2002:a05:6402:520a:b0:49e:a080:d55f with SMTP id s10-20020a056402520a00b0049ea080d55fmr14408815edd.18.1674387041638; Sun, 22 Jan 2023 03:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674387041; cv=none; d=google.com; s=arc-20160816; b=iMNgiQA0wsynsBY7hqQpgOmFHAYeXogA25QZ7VEXrSE6+R2yPcyE6HGWmXkj9Cv/uH HyrykaujcYTUx9ucKo5UKmrG7Jf7xw9gY4fTQDnyV0YhyMPxzGwFR3TZLL+jfwIncT// FQ0kI79VUq9sTVcvg6sYyL+ldn789IyHxK6DMpd4TG3s0lFh83c2lD4fv+Ux8lpQIYiH QF6IRIG4HAtVLQopfwObWRdQxAmUMv5UCetLabWRIKCh4/EEJlTJieSrLyYa5nYCKp1/ tIsJrrEUiI6nS+pDpLFhSHg4M+6iSdRT8ki+nr1UR2Be4dyrdgrYIpEHK5ptBoS8Cc8l fnjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=PIGBqayUKuArKaRHZD7sCBO6FDrvE59LUQTAu0TlFio=; b=qVy2jHTTFcGxO1i3gEStlbzAX5IXKH0yt9GkFbbyTiRZ/4U1a9DcTwt32beAAduUvK 3pn3tlpD6jUHQL2efhh5006t13rJ6l+BgHKGjh+9nAat5EZGMgYWwVZ9BMjAzlPboKLg s+0u0V0nj2R8HdMSUNmUZq4V5SvonevFs0UUPXUNt8YLtkx5ta88oRj0qcHEpLjjCTdS ZMok2xyTppF/Aqt7VtIzje1fwSavKNjLiNYzX10bUlnJ+cAZluViTaIvrvtS81HcNQcj wEBZerHdUWDtmYSKOPrUuJDDvOX1cUaEDCo4yQg1pX3/AD6ChV0rV/5vKr4aHabRnsM6 5mFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=Lxhnxo7u; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mqfFVKoA; 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 eb14-20020a0564020d0e00b0047ff112ee12si57162519edb.101.2023.01.22.03.30.28; Sun, 22 Jan 2023 03:30:41 -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; dkim=pass header.i=@arndb.de header.s=fm2 header.b=Lxhnxo7u; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mqfFVKoA; 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 S229709AbjAVLFE (ORCPT + 52 others); Sun, 22 Jan 2023 06:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjAVLFC (ORCPT ); Sun, 22 Jan 2023 06:05:02 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E311ABEB; Sun, 22 Jan 2023 03:05:00 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 208A45C003B; Sun, 22 Jan 2023 06:04:58 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Sun, 22 Jan 2023 06:04:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc: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=fm2; t=1674385498; x=1674471898; bh=PIGBqayUKu ArKaRHZD7sCBO6FDrvE59LUQTAu0TlFio=; b=Lxhnxo7ujOLMNwhq5OGDK6ZKiL ghNTbYaudfk7815ZYCsm9Y8XKiRED3XjCvkKaGoOhc6hStAzvEga0xZmdKmIdkQk eTdcUdlj6D/6Gip2mhSxlQgikIE4PVx5pW1Bxs6amsP6rVcfJNgtgZmCf1Ucczzk HGa6TsBVuoBKjs6gMcSEEd5TvizRU4rIgSwqAh5Z4U8krTZM55xHrLNqAFC1jFxx fIpuiCj7iPve1Jg5gonO+nkTZLrj9YhAYZVaTwqGMNwUDeiN6mY6XOBMWQB2xljw iDxX8SgFksBLKM5kPYQctaINyRdpsDNJ9Z3iwWu71rTdRFGKQj2oB/pK1Oog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= fm3; t=1674385498; x=1674471898; bh=PIGBqayUKuArKaRHZD7sCBO6FDrv E59LUQTAu0TlFio=; b=mqfFVKoA8Wv1ISopmIUdhhQQTWCzmhNjBh4V0QvcSI52 jVBJy4enEBRHiYs3E4RUFI4uSXG3Wvla1TWuNJyikr2oKpxkXKcZ8+O2y1VITn0t sSWihFf596BuYflkgy5PrJYKO+GSEVafTrwoyrwFR7JNMp9H2zvHIyBkfi8NXmzR jeTlPX4zf78x1nQy5dR1FzjdPSIEJCGqMmOW+n8rUDgTJHE5mW+gYd4yqVShrWTu taS3BwPSDyBwETYLTvxAy7CKQhrlGZGn1rXO+Y6wnu4v+bnv79UupEFpLFLsxP8D Hc+83GyL277N8Nv+HZyNn3wyU7TCjDUJx/anr66M5w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudduiedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id D166BB60089; Sun, 22 Jan 2023 06:04:55 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-85-gd6d859e0cf-fm-20230116.001-gd6d859e0 Mime-Version: 1.0 Message-Id: <7ad668ba-d6f3-4ef9-9335-e42bfe8d4cce@app.fastmail.com> In-Reply-To: <20230122072759.GA3703@lst.de> References: <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> <20230121143733.GA7415@lst.de> <6a64b0b5-0ebc-43a5-a3d8-483a845a0b5e@app.fastmail.com> <20230122072759.GA3703@lst.de> Date: Sun, 22 Jan 2023 12:04:35 +0100 From: "Arnd Bergmann" To: "Christoph Hellwig" Cc: Prabhakar , "Conor.Dooley" , "Geert Uytterhoeven" , =?UTF-8?Q?Heiko_St=C3=BCbner?= , 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 Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 Sun, Jan 22, 2023, at 08:27, Christoph Hellwig wrote: > On Sat, Jan 21, 2023 at 08:30:23PM +0100, Arnd Bergmann wrote: >> I was thinking of using STATIC_CALL() as an optimization here, which >> I find easier to read and understand than alternatives. One advantage >> here is that this allows the actual cache operations to be declared >> locally in the architecture without letting drivers call them, >> but still update the common code to work without indirect branches. >> >> The main downside is that this is currently only optimized on >> powerpc and x86, both of which don't actually need CPU specific >> callbacks. ARC, ARM, and MIPS on the other hand already >> have indirect function pointers, RISC-V would likely benefit the >> most from either alternatives or static_call, as it already >> uses alternatives and has one implementation that is clearly >> preferred over the others. > > For now I'd just keep doing direct calls into the arch code, just > for the lower level invalidate, writeback, invalidate+writeback > calls as that helps cementinc the logic of which of those to use > in well documented core code. Ok. > 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. On the other hand, the indirect function pointers for per-cpu cache operations are not easily translated anyway: with the three architectures that multiplex between cpu specific operations, arc uses physical addresses, mips uses virtual addresses (because of highmem), and arm even uses both because of incompatible requirements between l1 and l2 cache operations. arm32 also seems to have the superset of all possible corner cases that one might see elsewhere (prefetching vs in-order, writethrough vs writeback, broken broadcast invalidation, ...). > 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. Arnd