From: Mike Leach <mike.leach@linaro.org> To: Mao Jinlong <quic_jinlmao@quicinc.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>, Suzuki K Poulose <suzuki.poulose@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Leo Yan <leo.yan@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang <quic_tingweiz@quicinc.com>, Yuanfang Zhang <quic_yuanfang@quicinc.com>, Tao Zhang <quic_taozha@quicinc.com>, Trilok Soni <quic_tsoni@quicinc.com>, Hao Zhang <quic_hazha@quicinc.com>, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v3 02/10] coresight: Use bitmap to assign trace id to the sources Date: Thu, 17 Feb 2022 17:35:02 +0000 [thread overview] Message-ID: <CAJ9a7Vj2eZOD-2v5Y+CPgBZiDsAw39N8YFK3xX4sozc1Rs1D=Q@mail.gmail.com> (raw) In-Reply-To: <20220209105706.18852-3-quic_jinlmao@quicinc.com> Hi, On Wed, 9 Feb 2022 at 10:57, Mao Jinlong <quic_jinlmao@quicinc.com> wrote: > > Except from STM and ETM/ETE, there could be other sources. Each > source needs a unique trace id. Define a bitmap for the trace ids. > The position of each bit represents trace id of the source. > > Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> > --- > drivers/hwtracing/coresight/coresight-core.c | 48 ++++++++++++++++++++ > include/linux/coresight-pmu.h | 11 +++++ > 2 files changed, 59 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index a90097f88425..6cb55c3f41d5 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -16,6 +16,7 @@ > #include <linux/mutex.h> > #include <linux/clk.h> > #include <linux/coresight.h> > +#include <linux/coresight-pmu.h> see my comment below about using coresigh-priv.h > #include <linux/of_platform.h> > #include <linux/delay.h> > #include <linux/pm_runtime.h> > @@ -25,8 +26,11 @@ > #include "coresight-syscfg.h" > > static DEFINE_MUTEX(coresight_mutex); > +static DEFINE_MUTEX(coresight_id_mutex); > static DEFINE_PER_CPU(struct coresight_device *, csdev_sink); > > +static DECLARE_BITMAP(coresight_trace_id, CORESIGHT_TRACE_ID_NUM); > + > /* > * Use IDR to map the hash length of the source's device name > * to the pointer of path for the source > @@ -51,6 +55,48 @@ struct coresight_node { > const u32 coresight_barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; > EXPORT_SYMBOL_GPL(coresight_barrier_pkt); > > +/* Init the coresight_trace_id bit map. */ > +static void coresight_init_trace_id(void) > +{ > + int i; > + > + /* Trace id 0 is invalid. */ > + set_bit(CORESIGHT_TRACE_ID_0, coresight_trace_id); > + /* Trace id 1 is fixed for STM. */ > + set_bit(CORESIGHT_TRACE_ID_1, coresight_trace_id); > + /* Trace id from 112 to 127 are reserved. */ > + for (i = CORESIGHT_TRACE_ID_112; i <= CORESIGHT_TRACE_ID_127; i++) > + set_bit(i, coresight_trace_id); > + /* Skip the trace ids of ETM/ETE. */ > + for (i = 0; i <= cpumask_last(cpu_possible_mask); i++) > + set_bit(coresight_get_trace_id(i), coresight_trace_id); > + > +} > + > +/* > + * Return the first zero bit position of bitmap coresight_trace_id > + * as source's trace id. > + * > + */ > +int coresight_get_system_trace_id(void) > +{ > + int id; > + > + mutex_lock(&coresight_id_mutex); > + id = find_first_zero_bit(coresight_trace_id, CORESIGHT_TRACE_ID_NUM); > + /* If no zero bit is found, return error value. */ > + if (id == CORESIGHT_TRACE_ID_NUM) { > + mutex_unlock(&coresight_id_mutex); > + return -EINVAL; > + } > + > + set_bit(id, coresight_trace_id); > + mutex_unlock(&coresight_id_mutex); > + > + return id; > +} > +EXPORT_SYMBOL(coresight_get_system_trace_id); > + > static const struct cti_assoc_op *cti_assoc_ops; > > void coresight_set_cti_ops(const struct cti_assoc_op *cti_op) > @@ -1750,6 +1796,8 @@ static int __init coresight_init(void) > return 0; > > etm_perf_exit(); > + > + coresight_init_trace_id(); > exit_bus_unregister: > bus_unregister(&coresight_bustype); > return ret; > diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h > index 4ac5c081af93..1e2c5ca4c6e6 100644 > --- a/include/linux/coresight-pmu.h > +++ b/include/linux/coresight-pmu.h > @@ -32,6 +32,14 @@ > #define ETM4_CFG_BIT_RETSTK 12 > #define ETM4_CFG_BIT_VMID_OPT 15 > The following additional defines and function should appear in coresight-priv.h The coresight-pmu.h file contains data for the interface between the drivers and perf. > +/* Coresight component supports 7 bits trace id. */ additional comment here to explain that 0, 0x70- 0x7F IDs are reserved by the architecture, 1 is default for STM > +#define CORESIGHT_TRACE_ID_NUM 128 > + > +#define CORESIGHT_TRACE_ID_0 0 > +#define CORESIGHT_TRACE_ID_1 1 > +#define CORESIGHT_TRACE_ID_112 112 > +#define CORESIGHT_TRACE_ID_127 127 > + can we have these names a little more descriptive - e.g. CORESIGHT_TRACE_ID_0_RES 0 CORESIGHT_TRACE_ID_STM 1 CORESIGHT_TRACE_ID_RANGE_LO_RES 0x70 CORESIGHT_TRACE_ID_RANGE_HI_RES 0x7F Additionally - now we are declaring a #define for the STM ID - it would be better to use that in coresight-stm.c stm_init_default_data() to set the trace id for the STM. Regards Mike > static inline int coresight_get_trace_id(int cpu) > { > /* > @@ -43,4 +51,7 @@ static inline int coresight_get_trace_id(int cpu) > return (CORESIGHT_ETM_PMU_SEED + (cpu * 2)); > } > > +/* Get the trace id for the sources except from STM, ETM/ETE. */ > +extern int coresight_get_system_trace_id(void); > + > #endif > -- > 2.17.1 > -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK
WARNING: multiple messages have this Message-ID (diff)
From: Mike Leach <mike.leach@linaro.org> To: Mao Jinlong <quic_jinlmao@quicinc.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>, Suzuki K Poulose <suzuki.poulose@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Leo Yan <leo.yan@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang <quic_tingweiz@quicinc.com>, Yuanfang Zhang <quic_yuanfang@quicinc.com>, Tao Zhang <quic_taozha@quicinc.com>, Trilok Soni <quic_tsoni@quicinc.com>, Hao Zhang <quic_hazha@quicinc.com>, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v3 02/10] coresight: Use bitmap to assign trace id to the sources Date: Thu, 17 Feb 2022 17:35:02 +0000 [thread overview] Message-ID: <CAJ9a7Vj2eZOD-2v5Y+CPgBZiDsAw39N8YFK3xX4sozc1Rs1D=Q@mail.gmail.com> (raw) In-Reply-To: <20220209105706.18852-3-quic_jinlmao@quicinc.com> Hi, On Wed, 9 Feb 2022 at 10:57, Mao Jinlong <quic_jinlmao@quicinc.com> wrote: > > Except from STM and ETM/ETE, there could be other sources. Each > source needs a unique trace id. Define a bitmap for the trace ids. > The position of each bit represents trace id of the source. > > Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> > --- > drivers/hwtracing/coresight/coresight-core.c | 48 ++++++++++++++++++++ > include/linux/coresight-pmu.h | 11 +++++ > 2 files changed, 59 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index a90097f88425..6cb55c3f41d5 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -16,6 +16,7 @@ > #include <linux/mutex.h> > #include <linux/clk.h> > #include <linux/coresight.h> > +#include <linux/coresight-pmu.h> see my comment below about using coresigh-priv.h > #include <linux/of_platform.h> > #include <linux/delay.h> > #include <linux/pm_runtime.h> > @@ -25,8 +26,11 @@ > #include "coresight-syscfg.h" > > static DEFINE_MUTEX(coresight_mutex); > +static DEFINE_MUTEX(coresight_id_mutex); > static DEFINE_PER_CPU(struct coresight_device *, csdev_sink); > > +static DECLARE_BITMAP(coresight_trace_id, CORESIGHT_TRACE_ID_NUM); > + > /* > * Use IDR to map the hash length of the source's device name > * to the pointer of path for the source > @@ -51,6 +55,48 @@ struct coresight_node { > const u32 coresight_barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; > EXPORT_SYMBOL_GPL(coresight_barrier_pkt); > > +/* Init the coresight_trace_id bit map. */ > +static void coresight_init_trace_id(void) > +{ > + int i; > + > + /* Trace id 0 is invalid. */ > + set_bit(CORESIGHT_TRACE_ID_0, coresight_trace_id); > + /* Trace id 1 is fixed for STM. */ > + set_bit(CORESIGHT_TRACE_ID_1, coresight_trace_id); > + /* Trace id from 112 to 127 are reserved. */ > + for (i = CORESIGHT_TRACE_ID_112; i <= CORESIGHT_TRACE_ID_127; i++) > + set_bit(i, coresight_trace_id); > + /* Skip the trace ids of ETM/ETE. */ > + for (i = 0; i <= cpumask_last(cpu_possible_mask); i++) > + set_bit(coresight_get_trace_id(i), coresight_trace_id); > + > +} > + > +/* > + * Return the first zero bit position of bitmap coresight_trace_id > + * as source's trace id. > + * > + */ > +int coresight_get_system_trace_id(void) > +{ > + int id; > + > + mutex_lock(&coresight_id_mutex); > + id = find_first_zero_bit(coresight_trace_id, CORESIGHT_TRACE_ID_NUM); > + /* If no zero bit is found, return error value. */ > + if (id == CORESIGHT_TRACE_ID_NUM) { > + mutex_unlock(&coresight_id_mutex); > + return -EINVAL; > + } > + > + set_bit(id, coresight_trace_id); > + mutex_unlock(&coresight_id_mutex); > + > + return id; > +} > +EXPORT_SYMBOL(coresight_get_system_trace_id); > + > static const struct cti_assoc_op *cti_assoc_ops; > > void coresight_set_cti_ops(const struct cti_assoc_op *cti_op) > @@ -1750,6 +1796,8 @@ static int __init coresight_init(void) > return 0; > > etm_perf_exit(); > + > + coresight_init_trace_id(); > exit_bus_unregister: > bus_unregister(&coresight_bustype); > return ret; > diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h > index 4ac5c081af93..1e2c5ca4c6e6 100644 > --- a/include/linux/coresight-pmu.h > +++ b/include/linux/coresight-pmu.h > @@ -32,6 +32,14 @@ > #define ETM4_CFG_BIT_RETSTK 12 > #define ETM4_CFG_BIT_VMID_OPT 15 > The following additional defines and function should appear in coresight-priv.h The coresight-pmu.h file contains data for the interface between the drivers and perf. > +/* Coresight component supports 7 bits trace id. */ additional comment here to explain that 0, 0x70- 0x7F IDs are reserved by the architecture, 1 is default for STM > +#define CORESIGHT_TRACE_ID_NUM 128 > + > +#define CORESIGHT_TRACE_ID_0 0 > +#define CORESIGHT_TRACE_ID_1 1 > +#define CORESIGHT_TRACE_ID_112 112 > +#define CORESIGHT_TRACE_ID_127 127 > + can we have these names a little more descriptive - e.g. CORESIGHT_TRACE_ID_0_RES 0 CORESIGHT_TRACE_ID_STM 1 CORESIGHT_TRACE_ID_RANGE_LO_RES 0x70 CORESIGHT_TRACE_ID_RANGE_HI_RES 0x7F Additionally - now we are declaring a #define for the STM ID - it would be better to use that in coresight-stm.c stm_init_default_data() to set the trace id for the STM. Regards Mike > static inline int coresight_get_trace_id(int cpu) > { > /* > @@ -43,4 +51,7 @@ static inline int coresight_get_trace_id(int cpu) > return (CORESIGHT_ETM_PMU_SEED + (cpu * 2)); > } > > +/* Get the trace id for the sources except from STM, ETM/ETE. */ > +extern int coresight_get_system_trace_id(void); > + > #endif > -- > 2.17.1 > -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-17 17:35 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-09 10:56 [PATCH v3 00/10] Coresight: Add support for TPDM and TPDA Mao Jinlong 2022-02-09 10:56 ` Mao Jinlong 2022-02-09 10:56 ` [PATCH v3 01/10] Use IDR to maintain all the enabled sources' paths Mao Jinlong 2022-02-09 10:56 ` Mao Jinlong 2022-02-09 15:34 ` Mike Leach 2022-02-09 15:34 ` Mike Leach 2022-02-09 10:56 ` [PATCH v3 02/10] coresight: Use bitmap to assign trace id to the sources Mao Jinlong 2022-02-09 10:56 ` Mao Jinlong 2022-02-17 17:35 ` Mike Leach [this message] 2022-02-17 17:35 ` Mike Leach 2022-02-09 10:56 ` [PATCH v3 03/10] Coresight: Add coresight TPDM source driver Mao Jinlong 2022-02-09 10:56 ` Mao Jinlong 2022-02-18 16:10 ` Mike Leach 2022-02-18 16:10 ` Mike Leach 2022-02-09 10:57 ` [PATCH v3 04/10] dt-bindings: arm: Adds CoreSight TPDM hardware definitions Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-17 17:48 ` Mike Leach 2022-02-17 17:48 ` Mike Leach 2022-02-09 10:57 ` [PATCH v3 05/10] coresight-tpdm: Add DSB dataset support Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-18 16:10 ` Mike Leach 2022-02-18 16:10 ` Mike Leach 2022-02-09 10:57 ` [PATCH v3 06/10] coresight-tpdm: Add integration test support Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-09 10:57 ` [PATCH v3 07/10] docs: sysfs: coresight: Add sysfs ABI documentation for TPDM Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-09 10:57 ` [PATCH v3 08/10] Coresight: Add TPDA link driver Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-09 10:57 ` [PATCH v3 09/10] dt-bindings: arm: Adds CoreSight TPDA hardware definitions Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-09 10:57 ` [PATCH v3 10/10] ARM: dts: msm: Add coresight components for SM8250 Mao Jinlong 2022-02-09 10:57 ` Mao Jinlong 2022-02-18 16:10 ` Mike Leach 2022-02-18 16:10 ` Mike Leach 2022-02-10 10:30 ` [PATCH v3 00/10] Coresight: Add support for TPDM and TPDA Mike Leach 2022-02-10 10:30 ` Mike Leach 2022-02-11 4:17 ` Jinlong Mao 2022-02-11 4:17 ` Jinlong Mao 2022-02-17 9:16 ` Jinlong Mao 2022-02-17 9:16 ` Jinlong Mao 2022-02-17 15:30 ` Mike Leach 2022-02-17 15:30 ` Mike Leach 2022-02-28 2:49 ` Jinlong Mao 2022-02-28 2:49 ` Jinlong Mao
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='CAJ9a7Vj2eZOD-2v5Y+CPgBZiDsAw39N8YFK3xX4sozc1Rs1D=Q@mail.gmail.com' \ --to=mike.leach@linaro.org \ --cc=alexander.shishkin@linux.intel.com \ --cc=coresight@lists.linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=leo.yan@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mathieu.poirier@linaro.org \ --cc=quic_hazha@quicinc.com \ --cc=quic_jinlmao@quicinc.com \ --cc=quic_taozha@quicinc.com \ --cc=quic_tingweiz@quicinc.com \ --cc=quic_tsoni@quicinc.com \ --cc=quic_yuanfang@quicinc.com \ --cc=suzuki.poulose@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.