Skip to content

Commit 2e96492

Browse files
committed
coresight: configuration: Update API to introduce load owner concept
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2055405 commit da7000e Author: Mike Leach <mike.leach@linaro.org> Date: Wed Nov 24 20:00:33 2021 +0000 coresight: configuration: Update API to introduce load owner concept Update the existing load API to introduce a "load owner" concept. This allows the tracking of the loaded configurations and features against the loading owner type, to allow later unload according to owner. A list of loaded configurations by owner is created. The load owner infrastructure will be used in following patches to implement dynanic load and unload, alongside dependency tracking. Signed-off-by: Mike Leach <mike.leach@linaro.org> Link: https://lore.kernel.org/r/20211124200038.28662-2-mike.leach@linaro.org Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Jeremy Linton <jlinton@redhat.com>
1 parent 400c6b6 commit 2e96492

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

drivers/hwtracing/coresight/coresight-cfg-preload.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ static struct cscfg_config_desc *preload_cfgs[] = {
2424
NULL
2525
};
2626

27+
static struct cscfg_load_owner_info preload_owner = {
28+
.type = CSCFG_OWNER_PRELOAD,
29+
};
30+
2731
/* preload called on initialisation */
28-
int cscfg_preload(void)
32+
int cscfg_preload(void *owner_handle)
2933
{
30-
return cscfg_load_config_sets(preload_cfgs, preload_feats);
34+
preload_owner.owner_handle = owner_handle;
35+
return cscfg_load_config_sets(preload_cfgs, preload_feats, &preload_owner);
3136
}

drivers/hwtracing/coresight/coresight-config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct cscfg_regval_desc {
9797
* @params_desc: array of parameters used.
9898
* @nr_regs: number of registers used.
9999
* @regs_desc: array of registers used.
100+
* @load_owner: handle to load owner for dynamic load and unload of features.
100101
*/
101102
struct cscfg_feature_desc {
102103
const char *name;
@@ -107,6 +108,7 @@ struct cscfg_feature_desc {
107108
struct cscfg_parameter_desc *params_desc;
108109
int nr_regs;
109110
struct cscfg_regval_desc *regs_desc;
111+
void *load_owner;
110112
};
111113

112114
/**
@@ -128,7 +130,7 @@ struct cscfg_feature_desc {
128130
* @presets: Array of preset values.
129131
* @event_ea: Extended attribute for perf event value
130132
* @active_cnt: ref count for activate on this configuration.
131-
*
133+
* @load_owner: handle to load owner for dynamic load and unload of configs.
132134
*/
133135
struct cscfg_config_desc {
134136
const char *name;
@@ -141,6 +143,7 @@ struct cscfg_config_desc {
141143
const u64 *presets; /* nr_presets * nr_total_params */
142144
struct dev_ext_attribute *event_ea;
143145
atomic_t active_cnt;
146+
void *load_owner;
144147
};
145148

146149
/**

drivers/hwtracing/coresight/coresight-syscfg.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,22 @@ int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc,
361361
* descriptors and load into the system.
362362
* Features are loaded first to ensure configuration dependencies can be met.
363363
*
364+
* To facilitate dynamic loading and unloading, features and configurations
365+
* have a "load_owner", to allow later unload by the same owner. An owner may
366+
* be a loadable module or configuration dynamically created via configfs.
367+
* As later loaded configurations can use earlier loaded features, creating load
368+
* dependencies, a load order list is maintained. Unload is strictly in the
369+
* reverse order to load.
370+
*
364371
* @config_descs: 0 terminated array of configuration descriptors.
365372
* @feat_descs: 0 terminated array of feature descriptors.
373+
* @owner_info: Information on the owner of this set.
366374
*/
367375
int cscfg_load_config_sets(struct cscfg_config_desc **config_descs,
368-
struct cscfg_feature_desc **feat_descs)
376+
struct cscfg_feature_desc **feat_descs,
377+
struct cscfg_load_owner_info *owner_info)
369378
{
370-
int err, i = 0;
379+
int err = 0, i = 0;
371380

372381
mutex_lock(&cscfg_mutex);
373382

@@ -382,6 +391,7 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs,
382391
feat_descs[i]->name);
383392
goto exit_unlock;
384393
}
394+
feat_descs[i]->load_owner = owner_info;
385395
i++;
386396
}
387397
}
@@ -398,10 +408,14 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs,
398408
config_descs[i]->name);
399409
goto exit_unlock;
400410
}
411+
config_descs[i]->load_owner = owner_info;
401412
i++;
402413
}
403414
}
404415

416+
/* add the load owner to the load order list */
417+
list_add_tail(&owner_info->item, &cscfg_mgr->load_order_list);
418+
405419
exit_unlock:
406420
mutex_unlock(&cscfg_mutex);
407421
return err;
@@ -827,10 +841,11 @@ int __init cscfg_init(void)
827841
INIT_LIST_HEAD(&cscfg_mgr->csdev_desc_list);
828842
INIT_LIST_HEAD(&cscfg_mgr->feat_desc_list);
829843
INIT_LIST_HEAD(&cscfg_mgr->config_desc_list);
844+
INIT_LIST_HEAD(&cscfg_mgr->load_order_list);
830845
atomic_set(&cscfg_mgr->sys_active_cnt, 0);
831846

832847
/* preload built-in configurations */
833-
err = cscfg_preload();
848+
err = cscfg_preload(THIS_MODULE);
834849
if (err)
835850
goto exit_err;
836851

drivers/hwtracing/coresight/coresight-syscfg.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @csdev_desc_list: List of coresight devices registered with the configuration manager.
2626
* @feat_desc_list: List of feature descriptors to load into registered devices.
2727
* @config_desc_list: List of system configuration descriptors to load into registered devices.
28+
* @load_order_list: Ordered list of owners for dynamically loaded configurations.
2829
* @sys_active_cnt: Total number of active config descriptor references.
2930
* @cfgfs_subsys: configfs subsystem used to manage configurations.
3031
*/
@@ -33,6 +34,7 @@ struct cscfg_manager {
3334
struct list_head csdev_desc_list;
3435
struct list_head feat_desc_list;
3536
struct list_head config_desc_list;
37+
struct list_head load_order_list;
3638
atomic_t sys_active_cnt;
3739
struct configfs_subsystem cfgfs_subsys;
3840
};
@@ -56,18 +58,41 @@ struct cscfg_registered_csdev {
5658
struct list_head item;
5759
};
5860

61+
/* owner types for loading and unloading of config and feature sets */
62+
enum cscfg_load_owner_type {
63+
CSCFG_OWNER_PRELOAD,
64+
};
65+
66+
/**
67+
* Load item - item to add to the load order list allowing dynamic load and
68+
* unload of configurations and features. Caller loading a config
69+
* set provides a context handle for unload. API ensures that
70+
* items unloaded strictly in reverse order from load to ensure
71+
* dependencies are respected.
72+
*
73+
* @item: list entry for load order list.
74+
* @type: type of owner - allows interpretation of owner_handle.
75+
* @owner_handle: load context - handle for owner of loaded configs.
76+
*/
77+
struct cscfg_load_owner_info {
78+
struct list_head item;
79+
int type;
80+
void *owner_handle;
81+
};
82+
5983
/* internal core operations for cscfg */
6084
int __init cscfg_init(void);
6185
void cscfg_exit(void);
62-
int cscfg_preload(void);
86+
int cscfg_preload(void *owner_handle);
6387
const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name);
6488
int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc,
6589
int param_idx, u64 value);
6690

6791

6892
/* syscfg manager external API */
6993
int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,
70-
struct cscfg_feature_desc **feat_descs);
94+
struct cscfg_feature_desc **feat_descs,
95+
struct cscfg_load_owner_info *owner_info);
7196
int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
7297
struct cscfg_csdev_feat_ops *ops);
7398
void cscfg_unregister_csdev(struct coresight_device *csdev);

0 commit comments

Comments
 (0)