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 CA701C4167B for ; Tue, 7 Nov 2023 10:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233847AbjKGKSX (ORCPT ); Tue, 7 Nov 2023 05:18:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjKGKSV (ORCPT ); Tue, 7 Nov 2023 05:18:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54274ED for ; Tue, 7 Nov 2023 02:18:19 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 605EFC433C8; Tue, 7 Nov 2023 10:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699352299; bh=q8eY4EmrfBXA7u5V9AK9XhPz+GlLL9tTLPPqNj+/O/k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=utqlKarTZNJ4XwUGN3QZ2N1tzNPwdVdtG6LxAjX8pE1VX1C+buPLjmvdCm2Q7zNov p8vhw4Pb1krnOx4/XyMhDUmtZTfXFywc/ssufmGuMnn+E8qkKdUimfX081lxqbXp8z m0CDTKaDyRN/0jgXs7LutAQ3dbVgeAyZdwDg6sI7gOOUt39tCvSs8gEEPBoI/79ilZ r0pQ5/zxabo2bJgIK8/xpWi6krxZHWEzAj83AnxoN6HFgE96x4x+wIAE21vYvHLa8h jAnAVNkTXQYukvnf28GgVFPJKcy+EqA+FQ8dj7tPHbR76Aw4vswoT2LX/Yq9swEYQu PlB0QFSdwLJPw== Date: Tue, 7 Nov 2023 10:18:12 +0000 From: Will Deacon To: Doug Anderson Cc: Mark Rutland , Marc Zyngier , Catalin Marinas , Chen-Yu Tsai , Amit Daniel Kachhap , AngeloGioacchino Del Regno , James Morse , Joey Gouly , Mark Brown , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 1/3] arm64: Disable GiC priorities on Mediatek devices w/ firmware issues Message-ID: <20231107101812.GC18944@willie-the-truck> References: <20231006151547.1.Ide945748593cffd8ff0feb9ae22b795935b944d6@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 30, 2023 at 04:19:55PM -0700, Doug Anderson wrote: > On Wed, Oct 18, 2023 at 4:01 AM Mark Rutland wrote: > > On Fri, Oct 06, 2023 at 03:15:51PM -0700, Douglas Anderson wrote: > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > > index 2806a2850e78..e35efab8efa9 100644 > > > --- a/arch/arm64/kernel/cpufeature.c > > > +++ b/arch/arm64/kernel/cpufeature.c > > > @@ -2094,9 +2094,30 @@ static int __init early_enable_pseudo_nmi(char *p) > > > } > > > early_param("irqchip.gicv3_pseudo_nmi", early_enable_pseudo_nmi); > > > > > > +static bool are_gic_priorities_broken(void) > > > +{ > > > + bool is_broken = false; > > > + struct device_node *np; > > > + > > > + /* > > > + * Detect broken Mediatek firmware that doesn't properly save and > > > + * restore GIC priorities. > > > + */ > > > + np = of_find_compatible_node(NULL, NULL, "arm,gic-v3"); > > > + if (np) { > > > + is_broken = of_property_read_bool(np, "mediatek,broken-save-restore-fw"); > > > + of_node_put(np); > > > + } > > > + > > > + return is_broken; > > > +} > > > > I'm definitely in favour of detecting this in the cpucap, but I think it'd be > > better to parse the DT once on the boot CPU rather than on each CPU every time > > it's brought up. > > > > I think if we add something like: > > > > #ifdef CONFIG_ARM64_PSEUDO_NMI > > static void detect_system_supports_pseudo_nmi(void) > > { > > struct device_node *np; > > > > if (!enable_pseudo_nmi) > > return; > > > > /* > > * Detect broken Mediatek firmware that doesn't properly save and > > * restore GIC priorities. > > */ > > np = of_find_compatible_node(NULL, NULL, "arm,gic-v3"); > > if (np && of_property_read_bool(np, "mediatek,broken-save-restore-fw")) { > > pr_info("Pseudo-NMI disabled due to Mediatek Chromebook GICR save problem"); > > enable_pseudo_nmi = false; > > } > > of_node_put(np); > > } > > #endif /* CONFIG_ARM64_PSEUDO_NMI */ > > static inline void detect_system_supports_pseudo_nmi(void) { } > > #endif > > > > ... then we can call that from init_cpu_features() before we call > > setup_boot_cpu_capabilities(), and then the existing logic in > > can_use_gic_priorities() should just work as that returns the value of > > enable_pseudo_nmi. > > > > Note: of_node_put(NULL) does nothing, like kfree(NULL), so it's fine for that > > to be called in the !np case. > > > > Would you be happy to fold that in? I'm happy with a Suggested-by tag if so. :) > > Yup, that looks good to me and I can fold it in (fixing a few nits > like missing "\n" and adding __init to the function). I'll wait to get > maintainers opinions on whether to fold patch #3 in here and then send > a v2. No preference from me; I assume this stuff's all going in together anyway. Will