drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / drivers / hwtracing / coresight / coresight-syscfg.h
blob66e2db890d8203853a0c3c907b48aa66dd8014e6
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Coresight system configuration driver.
4 */
6 #ifndef CORESIGHT_SYSCFG_H
7 #define CORESIGHT_SYSCFG_H
9 #include <linux/configfs.h>
10 #include <linux/coresight.h>
11 #include <linux/device.h>
13 #include "coresight-config.h"
16 * Load operation types.
17 * When loading or unloading, another load operation cannot be run.
18 * When unloading configurations cannot be activated.
20 enum cscfg_load_ops {
21 CSCFG_NONE,
22 CSCFG_LOAD,
23 CSCFG_UNLOAD
26 /**
27 * System configuration manager device.
29 * Contains lists of the loaded configurations and features, plus a list of CoreSight devices
30 * registered with the system as supporting configuration management.
32 * Need a device to 'own' some coresight system wide sysfs entries in
33 * perf events, configfs etc.
35 * @dev: The device.
36 * @csdev_desc_list: List of coresight devices registered with the configuration manager.
37 * @feat_desc_list: List of feature descriptors to load into registered devices.
38 * @config_desc_list: List of system configuration descriptors to load into registered devices.
39 * @load_order_list: Ordered list of owners for dynamically loaded configurations.
40 * @sys_active_cnt: Total number of active config descriptor references.
41 * @cfgfs_subsys: configfs subsystem used to manage configurations.
42 * @sysfs_active_config:Active config hash used if CoreSight controlled from sysfs.
43 * @sysfs_active_preset:Active preset index used if CoreSight controlled from sysfs.
44 * @load_state: A multi-stage load/unload operation is in progress.
46 struct cscfg_manager {
47 struct device dev;
48 struct list_head csdev_desc_list;
49 struct list_head feat_desc_list;
50 struct list_head config_desc_list;
51 struct list_head load_order_list;
52 atomic_t sys_active_cnt;
53 struct configfs_subsystem cfgfs_subsys;
54 u32 sysfs_active_config;
55 int sysfs_active_preset;
56 enum cscfg_load_ops load_state;
59 /* get reference to dev in cscfg_manager */
60 struct device *cscfg_device(void);
62 /**
63 * List entry for Coresight devices that are registered as supporting complex
64 * config operations.
66 * @csdev: The registered device.
67 * @match_flags: The matching type information for adding features.
68 * @ops: Operations supported by the registered device.
69 * @item: list entry.
71 struct cscfg_registered_csdev {
72 struct coresight_device *csdev;
73 u32 match_flags;
74 struct cscfg_csdev_feat_ops ops;
75 struct list_head item;
78 /* owner types for loading and unloading of config and feature sets */
79 enum cscfg_load_owner_type {
80 CSCFG_OWNER_PRELOAD,
81 CSCFG_OWNER_MODULE,
84 /**
85 * Load item - item to add to the load order list allowing dynamic load and
86 * unload of configurations and features. Caller loading a config
87 * set provides a context handle for unload. API ensures that
88 * items unloaded strictly in reverse order from load to ensure
89 * dependencies are respected.
91 * @item: list entry for load order list.
92 * @type: type of owner - allows interpretation of owner_handle.
93 * @owner_handle: load context - handle for owner of loaded configs.
95 struct cscfg_load_owner_info {
96 struct list_head item;
97 int type;
98 void *owner_handle;
101 /* internal core operations for cscfg */
102 int __init cscfg_init(void);
103 void cscfg_exit(void);
104 int cscfg_preload(void *owner_handle);
105 const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name);
106 int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc,
107 int param_idx, u64 value);
108 int cscfg_config_sysfs_activate(struct cscfg_config_desc *cfg_desc, bool activate);
109 void cscfg_config_sysfs_set_preset(int preset);
111 /* syscfg manager external API */
112 int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,
113 struct cscfg_feature_desc **feat_descs,
114 struct cscfg_load_owner_info *owner_info);
115 int cscfg_unload_config_sets(struct cscfg_load_owner_info *owner_info);
116 int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
117 struct cscfg_csdev_feat_ops *ops);
118 void cscfg_unregister_csdev(struct coresight_device *csdev);
119 int cscfg_activate_config(unsigned long cfg_hash);
120 void cscfg_deactivate_config(unsigned long cfg_hash);
121 void cscfg_csdev_reset_feats(struct coresight_device *csdev);
122 int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
123 unsigned long cfg_hash, int preset);
124 void cscfg_csdev_disable_active_config(struct coresight_device *csdev);
125 void cscfg_config_sysfs_get_active_cfg(unsigned long *cfg_hash, int *preset);
127 #endif /* CORESIGHT_SYSCFG_H */