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 EE5EF2DEA73; Wed, 19 Nov 2025 16:37:34 +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=1763570257; cv=none; b=t4CU5kBuOcRnqk43EfjIFdASpYwjfVAX3GghoMschtRUVhqzcAhQ4cyXq3Q7WD46rhiU+DmwypeJw9CqIClKF2wfhfwRYvwWsCmikWrLR8Nv/3zBleOv6uLd5ANguShA4r+bvY7bQchuJYezpfN60YZHUkHCZnXP0flaaXOmFxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763570257; c=relaxed/simple; bh=eApd84uq8i6jk0dHweosHMFZTYzmKJLMt0fyWsaryqY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qRQQ1RQXk4cl2RxnQSGTiPEbrs0ptaNjbODcDZNa4ik8Lu0s+FG0STJF3Aypa4PB00NL3H1+DW36nIEjGm9f/YVp73HLcjfyeuJqYg/rqbeQPwxIX/T1225VpXReoitPoA28BDGfveZDpAG3I90R/UFPm/dEN1ANs57B0qmiU8c= 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 B4FDFFEC; Wed, 19 Nov 2025 08:37:26 -0800 (PST) Received: from [172.27.42.169] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F8833F740; Wed, 19 Nov 2025 08:37:31 -0800 (PST) Message-ID: <92f99246-1533-4bf9-bbb5-39d1c148467f@arm.com> Date: Wed, 19 Nov 2025 10:37:29 -0600 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: [PATCH v5 05/34] ACPI / PPTT: Add a helper to fill a cpumask from a cache_id To: Ben Horgan , james.morse@arm.com Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com, baolin.wang@linux.alibaba.com, bobo.shaobowang@huawei.com, carl@os.amperecomputing.com, catalin.marinas@arm.com, dakr@kernel.org, dave.martin@arm.com, david@redhat.com, dfustini@baylibre.com, fenghuay@nvidia.com, gregkh@linuxfoundation.org, gshan@redhat.com, guohanjun@huawei.com, jonathan.cameron@huawei.com, kobak@nvidia.com, lcherian@marvell.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lpieralisi@kernel.org, peternewman@google.com, quic_jiles@quicinc.com, rafael@kernel.org, robh@kernel.org, rohit.mathew@arm.com, scott@os.amperecomputing.com, sdonthineni@nvidia.com, sudeep.holla@arm.com, tan.shaopeng@fujitsu.com, will@kernel.org, xhao@linux.alibaba.com, Zeng Heng , Shaopeng Tan References: <20251117170014.4113754-1-ben.horgan@arm.com> <20251117170014.4113754-6-ben.horgan@arm.com> Content-Language: en-US From: Jeremy Linton In-Reply-To: <20251117170014.4113754-6-ben.horgan@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/17/25 10:59 AM, Ben Horgan wrote: > From: James Morse > > MPAM identifies CPUs by the cache_id in the PPTT cache structure. > > The driver needs to know which CPUs are associated with the cache. > The CPUs may not all be online, so cacheinfo does not have the > information. > > Add a helper to pull this information out of the PPTT. All the PPTT stuff look fine to me, patch 4+5 continue to build on some of the copy/pasty bits in this module which isn't ideal but seems to be the best way forward at the moment. Reviewed-by: Jeremy Linton Thanks again for taking care of this. > > CC: Rohit Mathew > Reviewed-by: Gavin Shan > Reviewed-by: Fenghua Yu > Tested-by: Fenghua Yu > Tested-by: Carl Worth > Tested-by: Gavin Shan > Tested-by: Zeng Heng > Tested-by: Shaopeng Tan > Signed-off-by: James Morse > Signed-off-by: Ben Horgan > --- > Changes since v4: > Same changes as previous patch in series > do/while > initialisation of acpi_cpu_id > use new version of acpi_pptt_cache_v1_full > > Changes since v3: > Equivalent changes to the previous patch: > Tags dropped due to rework > Fallout/simplification from adding acpi_pptt_cache_v1_full > Look for each cache type before incrementing level > --- > drivers/acpi/pptt.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ > include/linux/acpi.h | 6 ++++ > 2 files changed, 71 insertions(+) > > diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c > index 5b1e9e410204..cea80337f01f 100644 > --- a/drivers/acpi/pptt.c > +++ b/drivers/acpi/pptt.c > @@ -998,3 +998,68 @@ int find_acpi_cache_level_from_id(u32 cache_id) > > return -ENOENT; > } > + > +/** > + * acpi_pptt_get_cpumask_from_cache_id() - Get the cpus associated with the > + * specified cache > + * @cache_id: The id field of the cache > + * @cpus: Where to build the cpumask > + * > + * Determine which CPUs are below this cache in the PPTT. This allows the property > + * to be found even if the CPUs are offline. > + * > + * The PPTT table must be rev 3 or later, > + * > + * Return: -ENOENT if the PPTT doesn't exist, or the cache cannot be found. > + * Otherwise returns 0 and sets the cpus in the provided cpumask. > + */ > +int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus) > +{ > + int cpu; > + struct acpi_table_header *table; > + > + cpumask_clear(cpus); > + > + table = acpi_get_pptt(); > + if (!table) > + return -ENOENT; > + > + if (table->revision < 3) > + return -ENOENT; > + > + for_each_possible_cpu(cpu) { > + bool empty; > + int level = 1; > + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); > + struct acpi_pptt_cache *cache; > + struct acpi_pptt_processor *cpu_node; > + > + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); > + if (!cpu_node) > + continue; > + > + do { > + int cache_type[] = {CACHE_TYPE_INST, CACHE_TYPE_DATA, CACHE_TYPE_UNIFIED}; > + > + empty = true; > + for (int i = 0; i < ARRAY_SIZE(cache_type); i++) { > + struct acpi_pptt_cache_v1_full *cache_v1; > + > + cache = acpi_find_cache_node(table, acpi_cpu_id, cache_type[i], > + level, &cpu_node); > + > + if (!cache) > + continue; > + > + empty = false; > + > + cache_v1 = upgrade_pptt_cache(cache); > + if (cache_v1 && cache_v1->cache_id == cache_id) > + cpumask_set_cpu(cpu, cpus); > + } > + level++; > + } while (!empty); > + } > + > + return 0; > +} > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index be074bdfd4d1..a9dbacabdf89 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -1543,6 +1543,7 @@ int find_acpi_cpu_topology_package(unsigned int cpu); > int find_acpi_cpu_topology_hetero_id(unsigned int cpu); > void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus); > int find_acpi_cache_level_from_id(u32 cache_id); > +int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus); > #else > static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) > { > @@ -1570,6 +1571,11 @@ static inline int find_acpi_cache_level_from_id(u32 cache_id) > { > return -ENOENT; > } > +static inline int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, > + cpumask_t *cpus) > +{ > + return -ENOENT; > +} > #endif > > void acpi_arch_init(void);