From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72EDF306B20 for ; Thu, 11 Dec 2025 13:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765460475; cv=none; b=Hi1/BhARC8XN00VZjSiMN1V/aKUNWAvJTgcCEV5nthSjXIpP5v2PBfIQNAst8445ycmafvulWdoqaROpFf6eaJ/TKqifjKuyikflUrncK1IJ4CGejgDjU50aowrU9yMzNt8tf/ble45/IOT8IIriMsrmXBHIRN+hNrahj43ANNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765460475; c=relaxed/simple; bh=2eNLjmlrEsk6wlGRlCY7u2A3BqHGmWGCfpqx84StrFw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=O9lK9JagfNqpZPJVKQRBniVwdesVyiBAp1o9xAGPDQuyDgkR8mg2xtVRCmXDIaqTyQjNk7In4jBI6BFJ3k36bsdyqyuYEm29SBtVUqGrLDB6k/490p2u7LA4WcTfMYYveZyoKS/cZIHOKQvto06fuDdt0M74V3skM1oUHsbkK7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 153221688; Thu, 11 Dec 2025 05:41:04 -0800 (PST) Received: from [10.1.196.46] (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F37F43F740; Thu, 11 Dec 2025 05:41:07 -0800 (PST) Message-ID: Date: Thu, 11 Dec 2025 13:41:06 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 04/38] arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs To: James Morse , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Dave Martin , Koba Ko , Shanker Donthineni , fenghuay@nvidia.com, baisheng.gao@unisoc.com, Jonathan Cameron , Gavin Shan , rohit.mathew@arm.com, reinette.chatre@intel.com, Punit Agrawal References: <20251205215901.17772-1-james.morse@arm.com> <20251205215901.17772-5-james.morse@arm.com> From: Ben Horgan Content-Language: en-US In-Reply-To: <20251205215901.17772-5-james.morse@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi James, On 12/5/25 21:58, James Morse wrote: > The MPAM system registers will be lost if the CPU is reset during > PSCI's CPU_SUSPEND. > > Add a PM notifier to restore them. > > mpam_thread_switch(current) can't be used as this won't make any > changes if the in-memory copy says the register already has the > correct value. In reality the system register is UNKNOWN out of reset. If CONFIG_ARM64_MPAM is not enabled then the PM notifier is never registered but the MPAMx_ELy will still come out of reset with UNKNOWN values and we need to set the PARTID values back to 0 as the MSC are only guaranteed to provide good defaults for that value. (We aren't using the MPAM driver to initialise the other PARTID.) > > Signed-off-by: James Morse > --- > arch/arm64/kernel/mpam.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c > index e6feff2324ac..dbe0a2d05abb 100644 > --- a/arch/arm64/kernel/mpam.c > +++ b/arch/arm64/kernel/mpam.c > @@ -4,6 +4,7 @@ > #include > > #include > +#include > #include > #include > > @@ -13,12 +14,41 @@ DEFINE_PER_CPU(u64, arm64_mpam_current); > > u64 arm64_mpam_global_default; > > +static int mpam_pm_notifier(struct notifier_block *self, > + unsigned long cmd, void *v) > +{ > + u64 regval; > + int cpu = smp_processor_id(); > + > + switch (cmd) { > + case CPU_PM_EXIT: > + /* > + * Don't use mpam_thread_switch() as the system register > + * value has changed under our feet. > + */ > + regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu)); > + write_sysreg_s(regval, SYS_MPAM1_EL1); > + isb(); > + > + write_sysreg_s(regval, SYS_MPAM0_EL1); > + > + return NOTIFY_OK; > + default: > + return NOTIFY_DONE; > + } > +} > + > +static struct notifier_block mpam_pm_nb = { > + .notifier_call = mpam_pm_notifier, > +}; > + > static int __init arm64_mpam_register_cpus(void) > { > u64 mpamidr = read_sanitised_ftr_reg(SYS_MPAMIDR_EL1); > u16 partid_max = FIELD_GET(MPAMIDR_EL1_PARTID_MAX, mpamidr); > u8 pmg_max = FIELD_GET(MPAMIDR_EL1_PMG_MAX, mpamidr); > > + cpu_pm_register_notifier(&mpam_pm_nb); > return mpam_register_requestor(partid_max, pmg_max); > } > /* Must occur before mpam_msc_driver_init() from subsys_initcall() */ Thanks, Ben