Commit 6c344860 authored by James Morse's avatar James Morse Committed by Zeng Heng
Browse files

drivers: base: cacheinfo: Add helper to find the cache size from cpu+level

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/snapshot/v6.7-rc2



---------------------------

MPAM needs to know the size of a cache associated with a particular CPU.
The DT/ACPI agnostic way of doing this is to ask cacheinfo.

Add a helper to do this.

Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 6a5b1dcf
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -133,6 +133,27 @@ static inline unsigned long get_cpu_cacheinfo_id(int cpu, int level)
	return ~0UL;
}

/*
 * Get the size of the cache associated with @cpu at level @level.
 * cpuhp lock must be held.
 */
static inline unsigned int get_cpu_cacheinfo_size(int cpu, int level)
{
	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
	int i;

	if (!ci->info_list)
		return 0;

	for (i = 0; i < ci->num_leaves; i++) {
		if (ci->info_list[i].level == level) {
			return ci->info_list[i].size;
		}
	}

	return 0;
}

#ifdef CONFIG_ARM64
#define use_arch_cache_info()	(true)
#else