[PATCH v4 01/10] coresight: configfs: Don't assume active until cscfg_mgr is set
Suzuki K Poulose
suzuki.poulose at arm.com
Wed Oct 28 03:14:30 PDT 2026
On 16/10/2026 11:46, James Clark wrote:
> Perf's etm_setup_aux() calls cscfg_activate_config() and dereferences
> cscfg_mgr, which can be done after coresight_init() has initialized the
> Perf PMU but before cscfg_init() has finished while the driver is still
> loading.
>
> Fix it by only assuming cscfg is initialized if cscfg_mgr is set.
>
Is this possible though ? The component drivers are dependent on the
coresight-core being loaded and this is not complete until the coresight
module has been initialised.
Or the other way to fix this is delay the etm_perf init after the cscfg
init, which clearly is the order of dependencies ?
Cheers
Suzuki
> Fixes: a0114b4740dd ("coresight: etm-perf: Update to activate selected configuration")
> Signed-off-by: James Clark <james.clark at linaro.org>
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index 2bfdd7b45e49..7e3c9844bc00 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -26,6 +26,11 @@ static DEFINE_MUTEX(cscfg_mutex);
> /* only one of these */
> static struct cscfg_manager *cscfg_mgr;
>
> +static enum cscfg_load_ops cscfg_get_state(void)
> +{
> + return cscfg_mgr ? cscfg_mgr->load_state : CSCFG_UNLOAD;
> +}
> +
> /* load features and configuations into the lists */
>
> /* get name feature instance from a coresight device list of features */
> @@ -581,7 +586,7 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs,
> int err = 0;
>
> mutex_lock(&cscfg_mutex);
> - if (cscfg_mgr->load_state != CSCFG_NONE) {
> + if (cscfg_get_state() != CSCFG_NONE) {
> mutex_unlock(&cscfg_mutex);
> return -EBUSY;
> }
> @@ -662,7 +667,7 @@ int cscfg_unload_config_sets(struct cscfg_load_owner_info *owner_info)
> struct cscfg_load_owner_info *load_list_item = NULL;
>
> mutex_lock(&cscfg_mutex);
> - if (cscfg_mgr->load_state != CSCFG_NONE) {
> + if (cscfg_get_state() != CSCFG_NONE) {
> mutex_unlock(&cscfg_mutex);
> return -EBUSY;
> }
> @@ -902,7 +907,7 @@ static int _cscfg_activate_config(unsigned long cfg_hash)
> struct cscfg_config_desc *config_desc;
> int err = -EINVAL;
>
> - if (cscfg_mgr->load_state == CSCFG_UNLOAD)
> + if (cscfg_get_state() == CSCFG_UNLOAD)
> return -EBUSY;
>
> list_for_each_entry(config_desc, &cscfg_mgr->config_desc_list, item) {
>
More information about the linux-arm-kernel
mailing list