Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4345270rwl; Sat, 7 Jan 2023 16:36:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmkK2n98h8hTnHkQsPAAQVbymxTQhqPVIDnK/L2M4qLtuMBIpdmyM2uuQMqSU5IFY3oyTX X-Received: by 2002:a17:902:8688:b0:192:fc9c:a238 with SMTP id g8-20020a170902868800b00192fc9ca238mr10290376plo.66.1673138181457; Sat, 07 Jan 2023 16:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673138181; cv=none; d=google.com; s=arc-20160816; b=C6GRYoJZfdrThA1d5Xt37E3zboc6NT3yuHQauxe3AfiAid0tyk0SrHjU1k4370q6OW 2CM+ek3CKLHaDOzyGym0fOEt6ERi+I0p4ReQ+sqPRtgqJgz3xByJ02GlaGkmDrn4VFBR DEw5ESmEvKqHUWMwbAVUnnBUD2WOzRpcIrqBaabYLinAP5M8a7LmtiYyq9yOGgbbk2JF 1N243ol5N8ogoxCUzQ5OqhsJWVShUFKdy+CNrps0fh3+WTUFoO9XdgE9fHb6XLDzD7Et IW98X3HSnqYDvfuE+NNUbOSGOMpavdyceWWS8KSfVoy619knSAhljY8S366oWxQOFpwY G4rQ== 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=w6+aDVc5tr2uIs4oPoROJd4fXpjR6GDvnU6vXcUl8+E=; b=jODQezB4eOhaYTv+hXnd0wfF9oRffQA1YB0OHoh+/cJjkHG4dAuaAROgLBAclRIQQ3 OIUUM9q8IIc4AmfuGYyPeAAbfmcuTbmyDfhsZNUVmY5Nwd2/C71UmQxpGgS99PKuMgKk hB+6gqC9pl4nUz3VeX4FCRDoiCQgUj/52FNp9CIQhtA1kAFrPuvooT/pBOnb79s48szC xvaGaajVCKMh4lZux6OV0F8St7VTXkyhsjsIrVMvZuMzwl/if4Tr5I1mP93xYivVggfx lgNHOguM+lXB4FMonfvEblyjdGdmM+s6KuvjIYPFJcQgB0esdPDTFEMqKjulmHvJGV/4 xdnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=cp64SsHu; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SBqtoaNd; 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 d14-20020a63734e000000b00478e26efc94si5335885pgn.422.2023.01.07.16.36.14; Sat, 07 Jan 2023 16:36:21 -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=cp64SsHu; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SBqtoaNd; 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 S231357AbjAHAIS (ORCPT + 55 others); Sat, 7 Jan 2023 19:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjAHAIQ (ORCPT ); Sat, 7 Jan 2023 19:08:16 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10F271EEE4; Sat, 7 Jan 2023 16:08:14 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D339E5C007D; Sat, 7 Jan 2023 19:08:10 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Sat, 07 Jan 2023 19:08:10 -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=1673136490; x=1673222890; bh=w6+aDVc5tr 2uIs4oPoROJd4fXpjR6GDvnU6vXcUl8+E=; b=cp64SsHubAH99xcKXc31E50owr wlsfwwUfDFasgRONy24xanJJNwofyBrCQqq9yrDSayVGnfvqKHD8N5J8mJ1zsjMk m2HbIOo0QgUqKJDUoekJs0ZvySSR8ZynasP6zia1kY5qGTsWYi1JD1ipfD3GP9Q/ FAUQ1u9x7k/Ev1jVOG80iHbowRRMSeQkdpVvp22gh5e/69eW0NBGKFYS9V6+GHFJ C4hHjhy/3p80AYxUb/JFgEVxtQnRx6aCTDHQoILBz/NWhFRD/ho24bBB7lHGuVx/ chuK/pREqTqrM15AI5vS8397gk/YVLPsKflFCTO7f8NC3xOOyyAbFK9TEEQw== 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=1673136490; x=1673222890; bh=w6+aDVc5tr2uIs4oPoROJd4fXpjR 6GDvnU6vXcUl8+E=; b=SBqtoaNdbDoKgboEpLb+w8tienE1p0Z5u9EOif9FMYLL gjkQ2YAh+3v8zpK2Fksde3wHXh5Hnj6Z/dv/QEVXbG01tyV3ImVYSTr4DNa5ATnR 4mFmhWKLEnYJ3Ce8XIItTkjRrbEgm05DJMfFqkpMWIcCxz6huTNffz9sl6zevzd0 YyjqLKJHjVSAAxySj5Ow1OnicIN3aTVy2zu26qhvSGkh5bl5ggCloCCo+SCljGQs XvVbEv4ZuywZrF5TgOVlOWVQvtXX5aIvGkMhPmnWscQ/xV+0+lVyWd8pbUKt+B4R fdHYcpY/CSFVzOTPxnrNnrdR0IUtARA+w4kHIRbeDQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrkeefgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3FA10B60086; Sat, 7 Jan 2023 19:08:09 -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: <9017adf0-acd4-4c43-8aea-3579b214b477@app.fastmail.com> In-Reply-To: References: <20230106185526.260163-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230106185526.260163-2-prabhakar.mahadev-lad.rj@bp.renesas.com> <6f7d06ef-d74d-4dfc-9b77-6ae83e0d7816@app.fastmail.com> Date: Sun, 08 Jan 2023 01:07:48 +0100 From: "Arnd Bergmann" To: Prabhakar Cc: "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" 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,SPF_HELO_PASS, SPF_PASS 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 Sat, Jan 7, 2023, at 23:10, Lad, Prabhakar wrote: >> > + >> > + memset(&thead_cmo_ops, 0x0, sizeof(thead_cmo_ops)); >> > + if (IS_ENABLED(CONFIG_ERRATA_THEAD_CMO)) { >> > + thead_cmo_ops.clean_range = &thead_cmo_clean_range; >> > + thead_cmo_ops.inv_range = &thead_cmo_inval_range; >> > + thead_cmo_ops.flush_range = &thead_cmo_flush_range; >> > + riscv_noncoherent_register_cache_ops(&thead_cmo_ops); >> > + } >> >> The implementation here looks reasonable, just wonder whether >> the classification as an 'errata' makes sense. I would probably >> consider this a 'driver' at this point, but that's just >> a question of personal preference. >> > zicbom is a CPU feature that doesn't have any DT node and hence no > driver and similarly for T-HEAD SoC. A driver does not have to be a 'struct platform_driver' that matches to a device node, my point was more about what to name it, regardless of how the code is entered. > Also the arch_setup_dma_ops() > happens quite early before driver probing due to which we get WARN() > messages during bootup hence I have implemented it as errata; as > errata patching happens quite early. But there is no more patching here, just setting the function pointers, right? >> > +struct riscv_cache_ops { >> > + void (*clean_range)(unsigned long addr, unsigned long size); >> > + void (*inv_range)(unsigned long addr, unsigned long size); >> > + void (*flush_range)(unsigned long addr, unsigned long size); >> > + void (*riscv_dma_noncoherent_cmo_ops)(void *vaddr, size_t size, >> > + enum dma_data_direction dir, >> > + enum dma_noncoherent_ops ops); >> > +}; >> >> I don't quite see how the fourth operation is used here. >> Are there cache controllers that need something beyond >> clean/inv/flush? >> > This is for platforms that dont follow standard cache operations (like > done in patch 5/6) and there drivers decide on the operations > depending on the ops and dir. My feeling is that the set of operations that get called should not depend on the cache controller but at best the CPU. I tried to enumerate how zicbom and ax45 differ here, and how that compares to other architectures: zicbom ax45,mips,arc arm arm64 fromdevice clean/flush inval/inval inval/inval clean/inval todevice clean/- clean/- clean/- clean/- bidi flush/flush flush/inval clean/inval clean/inval So everyone does the same operation for DMA_TO_DEVICE, but they differ in the DMA_FROM_DEVICE handling, for reasons I don't quite see: Your ax45 code does the same as arc and mips. arm and arm64 skip invalidating the cache before bidi mappings, but arm has a FIXME comment about that. arm64 does a 'clean' instead of 'inval' when mapping a fromdevice page, which seems valid but slower than necessary. Could the zicbom operations be changed to do the same things as the ax45/mips/arc ones, or are there specific details in the zicbom spec that require this? Arnd