From mboxrd@z Thu Jan 1 00:00:00 1970 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 9C681C4332F for ; Wed, 4 Jan 2023 10:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234647AbjADKU0 (ORCPT ); Wed, 4 Jan 2023 05:20:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234327AbjADKUL (ORCPT ); Wed, 4 Jan 2023 05:20:11 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D021CFEE; Wed, 4 Jan 2023 02:20:09 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 91F435C01CF; Wed, 4 Jan 2023 05:20:05 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Wed, 04 Jan 2023 05:20:05 -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=1672827605; x=1672914005; bh=8iXmcHFFNZ h9AmH4Kilxio1EfsB6nCxBvRuiZDX3K/M=; b=e2/nToEoyFuPKgFE+6AZ+dnZg8 UbR+0CntnFotz/eOIJHA96OR/Bm7laq07XDlEGGPVyb8f/H93Lp04/Z0XuE0vVzJ WpYjX0Cdzpq2fQongsI6YwJTshAMuYWvGNBsGezajwqxP36bb6gD+GqnTRyxqASC x2oFMtqMMlPYjRT/fzIWYToTUcQYCV/mtFlWguLjp+5dDBd4eKMQlfRGDA1jE93K IRzxQ9mZ7GH/UwpTMR2EYD+QfruHG6uz+JXtXOUacIROjBc7Cym86PVfV2161+9F diP+4IWw0yxVeix/VQysMYaqeXzAx723T7D37Lhr2hprYruNNCx2LMZVRn6w== 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= fm2; t=1672827605; x=1672914005; bh=8iXmcHFFNZh9AmH4Kilxio1EfsB6 nCxBvRuiZDX3K/M=; b=Xd7ZQBRnvHy6TSPL+UJsY+q6W7Hu1G8vJ3ZVFJ7JX2mx 0tKs30DbZrEa+XwJ536vwfKlfv6UmOF5xQE5Xn/N2wRoYYtq6bwFo6eC/abtW0Ls IO0o3BNPAfZ4Ni47sLFh9ZZLd/K5OirVZyOmoZqUYNKc+YEQaeQeXalTKaLlmUXH 1p7eFRvBadX6+/VmGYyxBvZWCENubwR3pqVzqyD7HJo6VbHYKldne7eClVF3wZ2g ZkjSIUtqVgw3CBWyrznltDUx/sgO4FlCaEzN1FRzwE1Ep7/Lh1q0/0oizqsnUFty ubQlxwlYBJIHRXBlCDucPZhW8L/NMD6YCd5jw6rylw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrjeeigddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 688E9B60086; Wed, 4 Jan 2023 05:20:04 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1185-g841157300a-fm-20221208.002-g84115730 Mime-Version: 1.0 Message-Id: <43aee000-5b89-4d94-98d2-b37b1a18a83e@app.fastmail.com> In-Reply-To: References: <20230103210400.3500626-10-conor@kernel.org> Date: Wed, 04 Jan 2023 11:19:44 +0100 From: "Arnd Bergmann" To: "Conor Dooley" Cc: "Palmer Dabbelt" , Prabhakar , "Conor.Dooley" , "Andrew Jones" , "Albert Ou" , "Anup Patel" , "Atish Patra" , "Biju Das" , devicetree@vger.kernel.org, "Geert Uytterhoeven" , guoren , "Christoph Hellwig" , =?UTF-8?Q?Heiko_St=C3=BCbner?= , "Jisheng Zhang" , krzysztof.kozlowski+dt@linaro.org, linux-kernel@vger.kernel.org, Linux-Renesas , linux-riscv@lists.infradead.org, "Magnus Damm" , "Nathan Chancellor" , "Paul Walmsley" , "Philipp Tomsich" , "Lad, Prabhakar" , "Rob Herring" , "Samuel Holland" , soc@kernel.org, "Daire McNamara" Subject: Re: [RFC v5.1 9/9] [DON'T APPLY] cache: sifive-ccache: add cache flushing capability Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 4, 2023, at 10:23, Conor Dooley wrote: >>Right, no need to touch the existing file as part of this series, >>it probably just gets in the way of defining a good interface here. > > Sure. Can leave it where it was & I'll sort it out later when it's > errata etc get added. > > Btw, would you mind pointing out where you wanted to have that if/else > you mentioned on IRC? I meant replacing both of the runtime patching indirections in arch_sync_dma_for_device(). At the moment, this function calls ALT_CMO_OP(), which is patched to either call the ZICBOM or the THEAD variant, and if I read this right you add a third case there with another level of indirection using static_branch. I would try to replace both of these indirections and instead handle it all from C code in arch_sync_dma_for_device() directly, for the purpose of readability and maintainability. static inline void dma_cache_clean(void *vaddr, size_t size) { if (!cache_maint_ops.clean) zicbom_cache_clean(vaddr, size, riscv_cbom_block_size); else cache_maint_ops.clean(vaddr, size, riscv_cbom_block_size); } void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, enum dma_data_direction dir) { void *vaddr = phys_to_virt(paddr); switch (dir) { case DMA_TO_DEVICE: case DMA_FROM_DEVICE: dma_cache_clean(vaddr, size); break; case DMA_BIDIRECTIONAL: dma_cache_flush(vaddr, size); break; default: break; } } which then makes it very clear what the actual code path is, while leaving the zicbom case free of indirect function calls. You can still use a static_branch() to optimize the conditional, but I would try to avoid any extra indirection levels or errata checks. Arnd