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

cacheinfo: Expose the code to generate a cache-id from a device_node

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



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

The MPAM driver identifies caches by id for use with resctrl. It
needs to know the cache-id when probeing, but the value isn't set
in cacheinfo until device_initcall().

Expose the code that generates the cache-id. The parts of the MPAM
driver that run early can use this to set up the resctrl structures.

Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 120ad2f7
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static bool cache_node_is_unified(struct cacheinfo *this_leaf,
	return of_property_read_bool(np, "cache-unified");
}

static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np)
unsigned long cache_of_get_id(struct device_node *np)
{
	struct device_node *cpu;
	unsigned long min_id = ~0UL;
@@ -202,8 +202,15 @@ static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np)
		}
	}

	if (min_id != ~0UL) {
		this_leaf->id = min_id;
	return min_id;
}

static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np)
{
	unsigned long id = cache_of_get_id(np);

	if (id != ~0UL) {
		this_leaf->id = id;
		this_leaf->attributes |= CACHE_ID;
	}
}
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ int acpi_get_cache_info(unsigned int cpu,
#endif

const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
unsigned long cache_of_get_id(struct device_node *np);

/*
 * Get the id of the cache associated with @cpu at level @level.