From: James Clark <james.clark@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Qi Liu <liuqi115@huawei.com>, Junhao He <hejunhao3@huawei.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
Mike Leach <mike.leach@arm.com>, Leo Yan <leo.yan@arm.com>,
Suyash Mahar <smahar@meta.com>, Yeoreum Yun <yeoreum.yun@arm.com>
Subject: Re: [PATCH v4 01/10] coresight: configfs: Don't assume active until cscfg_mgr is set
Date: Wed, 28 Oct 2026 13:00:14 +0000 [thread overview]
Message-ID: <59d1e508-365a-4960-9938-d4fbc4141590@linaro.org> (raw)
In-Reply-To: <3eda6e99-291f-40b1-9fd8-13ca193b5fa4@arm.com>
On 28/10/2026 10:14, Suzuki K Poulose wrote:
> 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.
No component drivers are needed for this path. etm_perf_init() creates
the PMU regardless of whether any sources or sinks exist. Perf can use
perf_event_open() on it immediately (although it would fail eventually),
but it would be after hitting this part.
>
> Or the other way to fix this is delay the etm_perf init after the cscfg
> init, which clearly is the order of dependencies ?
That's what I tried initially, and that's what Leo suggested on V3. But
cscfg is dependent on the core creating some sysfs files first, so the
init dependency is currently in the correct order.
>
> Cheers
> Suzuki
>
>
>> Fixes: a0114b4740dd ("coresight: etm-perf: Update to activate selected
>> configuration")
>> Signed-off-by: James Clark <james.clark@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) {
>>
>
next prev parent reply other threads:[~2026-10-28 13:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 10:46 [PATCH v4 00/10] coresight: Prevent per-thread events from sharing a sink James Clark
2026-10-16 10:46 ` [PATCH v4 01/10] coresight: configfs: Don't assume active until cscfg_mgr is set James Clark
2026-10-28 10:14 ` Suzuki K Poulose
2026-10-28 13:00 ` James Clark [this message]
2026-11-12 17:10 ` Leo Yan
2026-10-16 10:46 ` [PATCH v4 02/10] coresight: etm-perf: Remove workqueue for freeing AUX data James Clark
2026-11-12 17:13 ` Leo Yan
2026-10-16 10:46 ` [PATCH v4 03/10] coresight: etm-perf: Serialize AUX topology access James Clark
2026-11-12 18:09 ` Leo Yan
2026-10-16 10:46 ` [PATCH v4 04/10] coresight: etm-perf: Reject event if building path fails James Clark
2026-10-16 10:46 ` [PATCH v4 05/10] coresight: etm-perf: Prevent sink sharing at setup time James Clark
2026-10-16 10:46 ` [PATCH v4 06/10] coresight: tmc-etr: Reflect new sharing rules in allocator James Clark
2026-10-16 10:46 ` [PATCH v4 07/10] coresight: tmc-etr: Remove sharing guards from ETR James Clark
2026-10-16 10:46 ` [PATCH v4 08/10] coresight: tmc-etf: Remove sharing guards from ETF James Clark
2026-10-16 10:46 ` [PATCH v4 09/10] coresight: etb10: Remove sharing guards from ETB10 James Clark
2026-10-16 10:46 ` [PATCH v4 10/10] coresight: ultrasoc-smb: Remove sharing guards from SMB James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59d1e508-365a-4960-9938-d4fbc4141590@linaro.org \
--to=james.clark@linaro.org \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hejunhao3@huawei.com \
--cc=jic23@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuqi115@huawei.com \
--cc=mike.leach@arm.com \
--cc=smahar@meta.com \
--cc=suzuki.poulose@arm.com \
--cc=yeoreum.yun@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®