提交 8a6445f7 编写于 作者: W Wang ShaoBo 提交者: Zheng Zengkai

arm64/mpam: Allocate mpam component configuration arrays

hulk inclusion
category: feature
feature: ARM MPAM support
bugzilla: 48265
CVE: NA

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

To bridge resctrl resources and mpam devices, we need somewhere
to store the configuration information.

We allocate a configuration array for each mpam component, which
gets configuration from intermediate structure of resctrl and write
to mpam devices(MSCs).

This config element's categories can be classified as cache ctrl
feature (CPBM and CMAX) and memory ctrl feature (MAX and PBM),
meanwhile some extended features are also supported, including
priority, and hardlimit choice,
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 3022a1c3
...@@ -358,6 +358,25 @@ static void mpam_enable_squash_features(void) ...@@ -358,6 +358,25 @@ static void mpam_enable_squash_features(void)
} }
} }
static int mpam_allocate_config(void)
{
struct mpam_class *class;
struct mpam_component *comp;
lockdep_assert_held(&mpam_devices_lock);
list_for_each_entry(class, &mpam_classes, classes_list) {
list_for_each_entry(comp, &class->components, class_list) {
comp->cfg = kcalloc(mpam_sysprops_num_partid(), sizeof(*comp->cfg),
GFP_KERNEL);
if (!comp->cfg)
return -ENOMEM;
}
}
return 0;
}
/* /*
* Enable mpam once all devices have been probed. * Enable mpam once all devices have been probed.
* Scheduled by mpam_discovery_complete() once all devices have been created. * Scheduled by mpam_discovery_complete() once all devices have been created.
...@@ -365,6 +384,7 @@ static void mpam_enable_squash_features(void) ...@@ -365,6 +384,7 @@ static void mpam_enable_squash_features(void)
*/ */
static void __init mpam_enable(struct work_struct *work) static void __init mpam_enable(struct work_struct *work)
{ {
int err;
unsigned long flags; unsigned long flags;
struct mpam_device *dev; struct mpam_device *dev;
bool all_devices_probed = true; bool all_devices_probed = true;
...@@ -387,6 +407,9 @@ static void __init mpam_enable(struct work_struct *work) ...@@ -387,6 +407,9 @@ static void __init mpam_enable(struct work_struct *work)
mutex_lock(&mpam_devices_lock); mutex_lock(&mpam_devices_lock);
mpam_enable_squash_features(); mpam_enable_squash_features();
err = mpam_allocate_config();
if (err)
return;
mutex_unlock(&mpam_devices_lock); mutex_unlock(&mpam_devices_lock);
} }
...@@ -511,6 +534,7 @@ static void mpam_class_destroy(struct mpam_class *class) ...@@ -511,6 +534,7 @@ static void mpam_class_destroy(struct mpam_class *class)
list_for_each_entry_safe(comp, tmp, &class->components, class_list) { list_for_each_entry_safe(comp, tmp, &class->components, class_list) {
mpam_devices_destroy(comp); mpam_devices_destroy(comp);
list_del(&comp->class_list); list_del(&comp->class_list);
kfree(comp->cfg);
kfree(comp); kfree(comp);
} }
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <linux/types.h> #include <linux/types.h>
#include "mpam_internal.h" #include "mpam_internal.h"
struct mpam_config;
/* /*
* Size of the memory mapped registers: 4K of feature page * Size of the memory mapped registers: 4K of feature page
* then 2x 4K bitmap registers * then 2x 4K bitmap registers
...@@ -74,6 +76,8 @@ struct mpam_component { ...@@ -74,6 +76,8 @@ struct mpam_component {
struct cpumask fw_affinity; struct cpumask fw_affinity;
struct mpam_config *cfg;
/* member of mpam_class:components */ /* member of mpam_class:components */
struct list_head class_list; struct list_head class_list;
}; };
......
...@@ -4,6 +4,37 @@ ...@@ -4,6 +4,37 @@
typedef u32 mpam_features_t; typedef u32 mpam_features_t;
/*
* MPAM component config Structure
*/
struct mpam_config {
/*
* The biggest config we could pass around is 4K, but resctrl's max
* cbm is u32, so we only need the full-size config during reset.
* Just in case a cache with a >u32 bitmap is exported for another
* reason, we need to track which bits of the configuration are valid.
*/
mpam_features_t valid;
u32 cpbm;
u32 mbw_pbm;
u16 mbw_max;
/*
* dspri is downstream priority, intpri is internal priority.
*/
u16 dspri;
u16 intpri;
/*
* hardlimit or not
*/
bool hdl;
u32 intpartid;
};
/* Bits for mpam_features_t */ /* Bits for mpam_features_t */
enum mpam_device_features { enum mpam_device_features {
mpam_feat_ccap_part = 0, mpam_feat_ccap_part = 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册