Skip to content

Commit 1c1e296

Browse files
benhor01James Morse
authored andcommitted
arm_mpam: resctrl: Wait for cacheinfo to be ready
In order to calculate the rmid realloc threshold the size of the cache needs to be known. Cache domains will also be named after the cache id. So that this information can be extracted from cacheinfo we need to wait for it to be ready. The cacheinfo information is populated in device_initcall() so we wait for that. Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com> Tested-by: Jesse Chick <jessechick@os.amperecomputing.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent 3e9b358 commit 1c1e296

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/resctrl/mpam_resctrl.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/resctrl.h>
1717
#include <linux/slab.h>
1818
#include <linux/types.h>
19+
#include <linux/wait.h>
1920

2021
#include <asm/mpam.h>
2122

@@ -42,6 +43,13 @@ static DEFINE_MUTEX(domain_list_lock);
4243
*/
4344
static bool cdp_enabled;
4445

46+
/*
47+
* We use cacheinfo to discover the size of the caches and their id. cacheinfo
48+
* populates this from a device_initcall(). mpam_resctrl_setup() must wait.
49+
*/
50+
static bool cacheinfo_ready;
51+
static DECLARE_WAIT_QUEUE_HEAD(wait_cacheinfo_ready);
52+
4553
bool resctrl_arch_alloc_capable(void)
4654
{
4755
struct mpam_resctrl_res *res;
@@ -757,6 +765,8 @@ int mpam_resctrl_setup(void)
757765
struct mpam_resctrl_res *res;
758766
enum resctrl_res_level rid;
759767

768+
wait_event(wait_cacheinfo_ready, cacheinfo_ready);
769+
760770
cpus_read_lock();
761771
for_each_mpam_resctrl_control(res, rid) {
762772
INIT_LIST_HEAD_RCU(&res->resctrl_res.ctrl_domains);
@@ -794,3 +804,12 @@ int mpam_resctrl_setup(void)
794804

795805
return 0;
796806
}
807+
808+
static int __init __cacheinfo_ready(void)
809+
{
810+
cacheinfo_ready = true;
811+
wake_up(&wait_cacheinfo_ready);
812+
813+
return 0;
814+
}
815+
device_initcall_sync(__cacheinfo_ready);

0 commit comments

Comments
 (0)