coresight: allow to build coresight as modules
v3 cover coresight: allow to build coresight as modules
Allow to build coresight as modules. This gives developers the feasibility to test their code without reboot.
This series is based on below two series.
- "coresight: allow to build components as modules"
https://lkml.org/lkml/2018/6/5/989
- "coresight: make drivers modular"
https://lkml.org/lkml/2020/1/17/468
Change from v2:
Rebase to 5.8-rc5. Export coresight_add_sysfs_link and coresight_remove_sysfs_link
Fix one cut and paste error on MODULE_DESCRIPTION of CTI
Change from v1:
Use try_module_get() to avoid module to be unloaded when device is used in active trace session. (Mathieu P)
Change from above two series.
This series adds the support to dynamically remove module when the device in that module is enabled and used by some trace path. It disables all trace paths with that device and release the trace path.
Kim Phillips (7):
coresight: use IS_ENABLED for CONFIGs that may be modules
coresight: allow etm3x to be built as a module
coresight: allow etm4x to be built as a module
coresight: allow etb to be built as a module
coresight: allow tpiu to be built as a module
coresight: allow tmc to be built as a module
coresight: allow funnel and replicator drivers to be built as modules
Mian Yousaf Kaukab (4):
coresight: export global symbols
coresight: remove multiple init calls from funnel driver
coresight: remove multiple init calls from replicator driver
coresight: tmc-etr: add function to register catu ops
Tingwei Zhang (9):
coresight: cpu_debug: add module name in Kconfig
coresight: cpu_debug: define MODULE_DEVICE_TABLE
coresight: add coresight prefix to barrier_pkt
Allow to build coresight-stm as a module, for ease of development.
coresight: cti: add function to register cti associate ops
coresight: allow cti to be built as a module
coresight: allow catu drivers to be built as modules
coresight: add try_get_module() in coresight_grab_device()
coresight: allow the coresight core driver to be built as a module
drivers/hwtracing/coresight/Kconfig | 54 ++++++++--
drivers/hwtracing/coresight/Makefile | 22 ++--
drivers/hwtracing/coresight/coresight-catu.c | 37 ++++++-
drivers/hwtracing/coresight/coresight-catu.h | 2 -
.../{coresight.c => coresight-core.c} | 102 ++++++++++++++----
.../hwtracing/coresight/coresight-cpu-debug.c | 2 +
.../{coresight-cti.c => coresight-cti-core.c} | 46 +++++++-
drivers/hwtracing/coresight/coresight-etb10.c | 22 +++-
.../hwtracing/coresight/coresight-etm-perf.c | 9 +-
.../hwtracing/coresight/coresight-etm-perf.h | 5 +-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++-
...resight-etm4x.c => coresight-etm4x-core.c} | 31 +++++-
.../hwtracing/coresight/coresight-funnel.c | 62 ++++++++++-
.../hwtracing/coresight/coresight-platform.c | 1 +
drivers/hwtracing/coresight/coresight-priv.h | 24 ++---
.../coresight/coresight-replicator.c | 63 ++++++++++-
drivers/hwtracing/coresight/coresight-stm.c | 20 +++-
drivers/hwtracing/coresight/coresight-sysfs.c | 2 +
.../{coresight-tmc.c => coresight-tmc-core.c} | 19 +++-
.../hwtracing/coresight/coresight-tmc-etf.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 21 +++-
drivers/hwtracing/coresight/coresight-tmc.h | 3 +
drivers/hwtracing/coresight/coresight-tpiu.c | 19 +++-
include/linux/coresight.h | 2 +-
24 files changed, 521 insertions(+), 76 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (94%)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (96%)
rename drivers/hwtracing/coresight/{coresight-etm3x.c => coresight-etm3x-core.c} (97%)
rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)
rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (96%)Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 1/20 coresight: cpu_debug: add module name in Kconfig
Provide name of cpu_debug module in Kconfig help section.
--- drivers/hwtracing/coresight/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/coresight/Kconfig +3 -0
@@ -110,6 +110,9 @@ config CORESIGHT_CPU_DEBUG properly, please refer Documentation/trace/coresight/coresight-cpu-debug.rst for detailed description and the example for usage. + To compile this driver as a module, choose M here: the + module will be called coresight-cpu-debug. + config CORESIGHT_CTI bool "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 2/20 coresight: cpu_debug: define MODULE_DEVICE_TABLE
In reply to Tingwei ZhangDefine a MODULE_DEVICE_TABLE for cpu_debug so module can be auto loaded on boot.
--- drivers/hwtracing/coresight/coresight-cpu-debug.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwtracing/coresight/coresight-cpu-debug.c +2 -0
@@ -665,6 +665,8 @@ static const struct amba_id debug_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, debug_ids); +static struct amba_driver debug_driver = { .drv = { .name ="coresight-cpu-debug" ,
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 3/20 coresight: use IS_ENABLED for CONFIGs that may be modules
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Checking for ifdef CONFIG_x fails if CONFIG_x=m. Use IS_ENABLED that is true for both built-ins and modules, instead. Required when building coresight components as modules.
--- drivers/hwtracing/coresight/coresight-etm-perf.h | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 2 +- include/linux/coresight.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-etm-perf.h +1 -1
@@ -57,7 +57,7 @@ struct etm_event_data {struct list_head *__percpu *path; }; -#ifdef CONFIG_CORESIGHT +#if IS_ENABLED (CONFIG_CORESIGHT )int etm_perf_symlink (struct coresight_device *csdev,bool link);int etm_perf_add_symlink_sink (struct coresight_device *csdev);void etm_perf_del_symlink_sink (struct coresight_device *csdev);
drivers/hwtracing/coresight/coresight-priv.h +1 -1
@@ -163,7 +163,7 @@ int coresight_make_links(struct coresight_device *orig,void coresight_remove_links (struct coresight_device *orig,struct coresight_connection *conn); -#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X +#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM3X )extern int etm_readl_cp14 (u32 off,unsigned int *val);extern int etm_writel_cp14 (u32 off,u32 val);#else
include/linux/coresight.h +1 -1
@@ -320,7 +320,7 @@ struct coresight_ops {const struct coresight_ops_ect *ect_ops; }; -#ifdef CONFIG_CORESIGHT +#if IS_ENABLED (CONFIG_CORESIGHT )extern struct coresight_device *coresight_register (struct coresight_desc *desc);extern void coresight_unregister (struct coresight_device *csdev);
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 4/20 coresight: add coresight prefix to barrier_pkt
In reply to Tingwei ZhangAdd coresight prefix to make it specific. It will be a export symbol.
--- drivers/hwtracing/coresight/coresight-etb10.c | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 8 ++++---- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight.c | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -1
@@ -525,7 +525,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, cur = buf->cur; offset = buf->offset; - barrier = barrier_pkt; + barrier = coresight_barrier_pkt;for (i =0 ; i < to_read; i +=4 ) { buf_ptr = buf->data_pages[cur] + offset;
drivers/hwtracing/coresight/coresight-priv.h +4 -4
@@ -66,8 +66,8 @@ static DEVICE_ATTR_RO(name)#define coresight_simple_reg64 (type, name, lo_off, hi_off) \ __coresight_simple_func(type, NULL, name, lo_off, hi_off) -extern const u32 barrier_pkt[4 ]; -#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(barrier_pkt)) +extern const u32 coresight_barrier_pkt[4 ]; +#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))enum etm_addr_type {ETM_ADDR_TYPE_NONE ,
@@ -104,10 +104,10 @@ struct cs_buffers {static inline void coresight_insert_barrier_packet (void *buf) {if (buf) -memcpy (buf, barrier_pkt,CORESIGHT_BARRIER_PKT_SIZE ); +memcpy (buf, coresight_barrier_pkt, +CORESIGHT_BARRIER_PKT_SIZE ); } -static inline void CS_LOCK (void __iomem *addr) { do {
drivers/hwtracing/coresight/coresight-tmc-etf.c +1 -1
@@ -519,7 +519,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, cur = buf->cur; offset = buf->offset; - barrier = barrier_pkt; + barrier = coresight_barrier_pkt;/* for every byte to read */ for (i =0 ; i < to_read; i +=4 ) {
drivers/hwtracing/coresight/coresight.c +2 -1
@@ -53,7 +53,8 @@ static struct list_head *stm_path;* beginning of the data collected in a buffer. That way the decoder knows that * it needs to look for another sync sequence. */ -const u32 barrier_pkt[4 ] = {0x7fffffff ,0x7fffffff ,0x7fffffff ,0x7fffffff }; +const u32 coresight_barrier_pkt[4 ] = { +0x7fffffff ,0x7fffffff ,0x7fffffff ,0x7fffffff };static int coresight_id_match (struct device *dev,void *data) {
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 5/20 coresight: export global symbols
In reply to Tingwei ZhangFrom: Mian Yousaf Kaukab <[email protected]>
Export symbols used among coresight modules.
--- drivers/hwtracing/coresight/coresight-etm-perf.c | 1 + drivers/hwtracing/coresight/coresight-sysfs.c | 2 ++ drivers/hwtracing/coresight/coresight-tmc-etr.c | 6 ++++++ drivers/hwtracing/coresight/coresight.c | 8 ++++++++ 4 files changed, 17 insertions(+)
drivers/hwtracing/coresight/coresight-etm-perf.c +1 -0
@@ -506,6 +506,7 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link)return 0 ; } +EXPORT_SYMBOL_GPL (etm_perf_symlink); static ssize_t etm_perf_sink_name_show(struct device *dev, struct device_attribute *dattr,
drivers/hwtracing/coresight/coresight-sysfs.c +2 -0
@@ -102,6 +102,7 @@ int coresight_add_sysfs_link(struct coresight_sysfs_link *info)return ret; } +EXPORT_SYMBOL_GPL (coresight_add_sysfs_link);void coresight_remove_sysfs_link (struct coresight_sysfs_link *info) {
@@ -122,6 +123,7 @@ void coresight_remove_sysfs_link(struct coresight_sysfs_link *info) info->orig->nr_links--; info->target->nr_links--; } +EXPORT_SYMBOL_GPL (coresight_remove_sysfs_link);/* * coresight_make_links: Make a link for a connection from a @orig
drivers/hwtracing/coresight/coresight-tmc-etr.c +6 -0
@@ -255,6 +255,7 @@ void tmc_free_sg_table(struct tmc_sg_table *sg_table)tmc_free_table_pages (sg_table);tmc_free_data_pages (sg_table); } +EXPORT_SYMBOL_GPL (tmc_free_sg_table);/* * Alloc pages for the table. Since this will be used by the device,
@@ -340,6 +341,7 @@ struct tmc_sg_table *tmc_alloc_sg_table(struct device *dev,return sg_table; } +EXPORT_SYMBOL_GPL (tmc_alloc_sg_table);/* * tmc_sg_table_sync_data_range: Sync the data buffer written
@@ -360,6 +362,7 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, PAGE_SIZE, DMA_FROM_DEVICE); } } +EXPORT_SYMBOL_GPL (tmc_sg_table_sync_data_range);/* tmc_sg_sync_table: Sync the page table */ void tmc_sg_table_sync_table (struct tmc_sg_table *sg_table)
@@ -372,6 +375,7 @@ void tmc_sg_table_sync_table(struct tmc_sg_table *sg_table)dma_sync_single_for_device (real_dev, table_pages->daddrs[i],PAGE_SIZE ,DMA_TO_DEVICE ); } +EXPORT_SYMBOL_GPL (tmc_sg_table_sync_table);/* * tmc_sg_table_get_data: Get the buffer pointer for data @offset
@@ -401,6 +405,7 @@ ssize_t tmc_sg_table_get_data(struct tmc_sg_table *sg_table, *bufpp =page_address (data_pages->pages[pg_idx]) + pg_offset;return len; } +EXPORT_SYMBOL_GPL (tmc_sg_table_get_data);#ifdef ETR_SG_DEBUG /* Map a dma address to virtual address */
@@ -766,6 +771,7 @@ tmc_etr_get_catu_device(struct tmc_drvdata *drvdata)return NULL ; } +EXPORT_SYMBOL_GPL (tmc_etr_get_catu_device);static inline int tmc_etr_enable_catu (struct tmc_drvdata *drvdata,struct etr_buf *etr_buf)
drivers/hwtracing/coresight/coresight.c +8 -0
@@ -55,6 +55,7 @@ static struct list_head *stm_path;*/ const u32 coresight_barrier_pkt[4 ] = {0x7fffffff ,0x7fffffff ,0x7fffffff ,0x7fffffff }; +EXPORT_SYMBOL_GPL (coresight_barrier_pkt);static int coresight_id_match (struct device *dev,void *data) {
@@ -180,6 +181,7 @@ int coresight_claim_device_unlocked(void __iomem *base)coresight_clear_claim_tags (base);return -EBUSY ; } +EXPORT_SYMBOL_GPL (coresight_claim_device_unlocked);int coresight_claim_device (void __iomem *base) {
@@ -191,6 +193,7 @@ int coresight_claim_device(void __iomem *base)return rc; } +EXPORT_SYMBOL_GPL (coresight_claim_device);/* * coresight_disclaim_device_unlocked : Clear the claim tags for the device.
@@ -209,6 +212,7 @@ void coresight_disclaim_device_unlocked(void __iomem *base)*/ WARN_ON_ONCE (1 ); } +EXPORT_SYMBOL_GPL (coresight_disclaim_device_unlocked);void coresight_disclaim_device (void __iomem *base) {
@@ -216,6 +220,7 @@ void coresight_disclaim_device(void __iomem *base)coresight_disclaim_device_unlocked (base);CS_LOCK (base); } +EXPORT_SYMBOL_GPL (coresight_disclaim_device);/* enable or disable an associated CTI device of the supplied CS device */ static int
@@ -468,6 +473,7 @@ void coresight_disable_path(struct list_head *path) {coresight_disable_path_from (path,NULL ); } +EXPORT_SYMBOL_GPL (coresight_disable_path);int coresight_enable_path (struct list_head *path,u32 mode,void *sink_data) {
@@ -1212,6 +1218,7 @@ int coresight_timeout(void __iomem *addr, u32 offset, int position, int value)return -EAGAIN ; } +EXPORT_SYMBOL_GPL (coresight_timeout);struct bus_type coresight_bustype = { .name ="coresight" ,
@@ -1387,6 +1394,7 @@ bool coresight_loses_context_with_cpu(struct device *dev)return fwnode_property_present (dev_fwnode (dev),"arm,coresight-loses-context-with-cpu" ); } +EXPORT_SYMBOL_GPL (coresight_loses_context_with_cpu);/* * coresight_alloc_device_name - Get an index for a given device in the
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 6/20 Allow to build coresight-stm as a module, for ease of development.
In reply to Tingwei Zhang- Kconfig becomes a tristate, to allow =m
- add a stm_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/coresight-stm.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/Kconfig +4 -1
@@ -86,7 +86,7 @@ config CORESIGHT_SOURCE_ETM4X data tracing may also be available. config CORESIGHT_STM - bool "CoreSight System Trace Macrocell driver" + tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64 select CORESIGHT_LINKS_AND_SINKS select STM
@@ -96,6 +96,9 @@ config CORESIGHT_STM logging useful software events or data coming from various entities in the system, possibly running different OSs + To compile this driver as a module, choose M here: the + module will be called coresight-stm. + config CORESIGHT_CPU_DEBUG tristate "CoreSight CPU Debug driver" depends on ARM || ARM64
drivers/hwtracing/coresight/coresight-stm.c +19 -1
@@ -950,6 +950,17 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)return ret; } +static int __exit stm_remove(struct amba_device *adev) +{ +struct stm_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +stm_unregister_device (&drvdata->stm); + +return 0 ; +} +#ifdef CONFIG_PM static int stm_runtime_suspend (struct device *dev) {
@@ -982,6 +993,8 @@ static const struct amba_id stm_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, stm_ids); + static struct amba_driver stm_driver = { .drv = { .name = "coresight-stm",
@@ -990,7 +1003,12 @@ static struct amba_driver stm_driver = { .suppress_bind_attrs = true, }, .probe = stm_probe, + .remove = stm_remove, .id_table = stm_ids, }; -builtin_amba_driver (stm_driver); +module_amba_driver (stm_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight System Trace Macrocell driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 7/20 coresight: allow etm3x to be built as a module
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-etm3x as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm3x by the Makefile
- add an etm_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
---
drivers/hwtracing/coresight/Kconfig | 5 +++-
drivers/hwtracing/coresight/Makefile | 3 ++-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++++++++++++++++-
3 files changed, 32 insertions(+), 3 deletions(-)
rename drivers/hwtracing/coresight/{coresight-etm3x.c => coresight-etm3x-core.c} (97%)drivers/hwtracing/coresight/Kconfig +4 -1
@@ -65,7 +65,7 @@ config CORESIGHT_SINK_ETBV10 special enhancement or added features. config CORESIGHT_SOURCE_ETM3X - bool "CoreSight Embedded Trace Macrocell 3.x driver" + tristate "CoreSight Embedded Trace Macrocell 3.x driver" depends on !ARM64 select CORESIGHT_LINKS_AND_SINKS help
@@ -74,6 +74,9 @@ config CORESIGHT_SOURCE_ETM3X This is primarily useful for instruction level tracing. Depending the ETM version data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm3x. + config CORESIGHT_SOURCE_ETM4X bool "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64
drivers/hwtracing/coresight/Makefile +2 -1
@@ -11,7 +11,8 @@ obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o obj-$(CONFIG_CORESIGHT_SINK_ETBV10) += coresight-etb10.o obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \ coresight-replicator.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm-cp14.o \ +obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o +coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ coresight-etm4x-sysfs.o
drivers/hwtracing/coresight/coresight-etm3x-core.c renamed from drivers/hwtracing/coresight/coresight-etm3x.c +26 -1
@@ -895,6 +895,23 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)return ret; } +static int __exit etm_remove(struct amba_device *adev) +{ +struct etm_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm_count ==0 ) { +cpuhp_remove_state_nocalls (CPUHP_AP_ARM_CORESIGHT_STARTING ); +if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} +#ifdef CONFIG_PM static int etm_runtime_suspend (struct device *dev) {
@@ -937,6 +954,8 @@ static const struct amba_id etm_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, etm_ids); + static struct amba_driver etm_driver = { .drv = { .name = "coresight-etm3x",
@@ -945,6 +964,12 @@ static struct amba_driver etm_driver = { .suppress_bind_attrs = true, }, .probe = etm_probe, + .remove = etm_remove, .id_table = etm_ids, }; -builtin_amba_driver (etm_driver); +module_amba_driver (etm_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 8/20 coresight: allow etm4x to be built as a module
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by the Makefile
- add an etm4_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
---
drivers/hwtracing/coresight/Kconfig | 5 ++-
drivers/hwtracing/coresight/Makefile | 4 +--
...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++-
3 files changed, 36 insertions(+), 4 deletions(-)
rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4 -1
@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x. config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDR
@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on the implemented version data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64
drivers/hwtracing/coresight/Makefile +2 -2
@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \ obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +30 -1
@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] = { } }; +static int __exit etm4_remove(struct amba_device *adev) +{ +struct etmv4_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +cpuhp_remove_state_nocalls (CPUHP_AP_ARM_CORESIGHT_STARTING ); +if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */
@@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Hi Tingwei,
Couldn't see 00/20 cover note for this set, so reporting this here as it relates to etmv4 in part.
The following sequence:-
(There is a load dependency here of course, if I try to load ETMv4 without the coresight core, then I get a lot of missing symbol error messages - I assume this is expected behaviour?)
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko
correctly loads the coresight core then ETMv4 module.
[ 1208.214674] coresight etm0: CPU0: ETM v4.0 initialized [ 1208.215534] coresight etm1: CPU1: ETM v4.0 initialized [ 1208.221020] coresight etm2: CPU2: ETM v4.0 initialized [ 1208.224757] coresight etm3: CPU3: ETM v4.0 initialized
However, if I then unload the ETMv4 module:-
root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-etm4x.ko
I get a crash:-
[ 1215.963689] ------------[ cut here ]------------ [ 1215.963741] WARNING: CPU: 3 PID: 0 at drivers/hwtracing/coresight/coresight-etm4x-core.c:1364 etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1215.967373] Modules linked in: coresight_etm4x(-) coresight [last unloaded: coresight] [ 1215.979960] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G W 5.8.0-rc5cs-modscs-mods-00020-gc03fe910680d #282 [ 1215.987856] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1215.998531] pstate: 80000085 (Nzcv daIf -PAN -UAO BTYPE=--) [ 1216.005396] pc : etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.010687] lr : notifier_call_chain+0x5c/0xa0 [ 1216.016926] sp : ffff000009fe7d50 [ 1216.021265] x29: ffff000009fe7d50 x28: 0000000000000000 [ 1216.024653] x27: 0000011b1d1464b5 x26: 0000000000000001 [ 1216.030035] x25: ffff00003c79f888 x24: 0000000000000001 [ 1216.035330] x23: 0000000000000000 x22: 0000000000000000 [ 1216.040626] x21: 0000000000000000 x20: 0000000000000000 [ 1216.045921] x19: ffff000038396480 x18: 0000000000000000 [ 1216.051216] x17: 0000000000000000 x16: 0000000000000000 [ 1216.056510] x15: 0000000000000000 x14: ffffffffffffffff [ 1216.061806] x13: ffffffffffffffff x12: 0000000000000000 [ 1216.067101] x11: 0000000000000000 x10: 00000000000009b0 [ 1216.072396] x9 : ffff000009fe7e70 x8 : ffff000009fd4010 [ 1216.077690] x7 : 0000000000000000 x6 : 0000000023c2c562 [ 1216.082986] x5 : 00ffffffffffffff x4 : 0000000000000003 [ 1216.088281] x3 : ffff000038396880 x2 : ffff800008d8d280 [ 1216.093576] x1 : ffff80002b1aa000 x0 : 000000005f454c42 [ 1216.098873] Call trace: [ 1216.104178] etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.106343] notifier_call_chain+0x5c/0xa0 [ 1216.112242] __atomic_notifier_call_chain+0x48/0x60 [ 1216.116236] cpu_pm_notify+0x44/0x70 [ 1216.121008] cpu_pm_enter+0x3c/0x80 [ 1216.124829] psci_enter_domain_idle_state+0x38/0xa8 [ 1216.128040] cpuidle_enter_state+0x88/0x478 [ 1216.132900] cpuidle_enter+0x44/0x58 [ 1216.137069] call_cpuidle+0x40/0x70 [ 1216.140888] do_idle+0x1e0/0x248 [ 1216.144099] cpu_startup_entry+0x28/0x98 [ 1216.147574] secondary_start_kernel+0x1a0/0x1f8 [ 1216.151476] ---[ end trace 97bcd7b8bdd7f9a7 ]---
This happens each time, though the CPU number can change. Test platform is Dragonboard DB410, linux 5.8-rc5 + this patch set.
Regards
Mike
Quoted 131 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c => coresight-etm4x-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4
-1@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x. config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDR@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on the implemented version data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64drivers/hwtracing/coresight/Makefile +2
-2@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \ obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.odrivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +30
-2@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] = { } }; +static int __exit etm4_remove(struct amba_device *adev) +{ +struct etmv4_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +cpuhp_remove_state_nocalls (CPUHP_AP_ARM_CORESIGHT_STARTING ); +if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */ @@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" ); --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 8 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Hi Mike,
Thanks for reporting this. This is a good catch.
I was testing on db845c but I didn't encounter this issue with multiple module load/unload test. I guess it's due to timing difference. The issue is etm4_cpu_pm_notify() is removed from cpu pm notification after last etm4 device is removed. There's racing condition when some etm4 device say etm0 is removed but etm4_cpu_pm_notify() is still called. I reproduced this issue by manually unbind etm4x device.
The fix is clean etmdrvdata[drvdata->cpu] in etm4_remove() so etm4_cpu_pm_notify() is gracefully returned. I've verified this on db845c with manually unbind etm4x device test. Do you mind test on your db410 as well? I'll put it into v4.
@@ -1542,6 +1543,7 @@ static int __exit etm4_remove(struct amba_device *adev)
etm_perf_symlink(drvdata->csdev, false);
+ etmdrvdata[drvdata->cpu] = NULL;
if (--etm4_count == 0) {
etm4_cpu_pm_unregister();Quoted 9 lines · Mike Leach
Hi Tingwei,
Couldn't see 00/20 cover note for this set, so reporting this here as it relates to etmv4 in part.
The following sequence:-
(There is a load dependency here of course, if I try to load ETMv4 without the coresight core, then I get a lot of missing symbol error messages - I assume this is expected behaviour?)
Coresight_etm4x module depends on coresight module, so it's expected behavior.
Quoted 197 lines
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.kocorrectly loads the coresight core then ETMv4 module.
[ 1208.214674] coresight etm0: CPU0: ETM v4.0 initialized [ 1208.215534] coresight etm1: CPU1: ETM v4.0 initialized [ 1208.221020] coresight etm2: CPU2: ETM v4.0 initialized [ 1208.224757] coresight etm3: CPU3: ETM v4.0 initializedHowever, if I then unload the ETMv4 module:-
root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-etm4x.koI get a crash:-
[ 1215.963689] ------------[ cut here ]------------ [ 1215.963741] WARNING: CPU: 3 PID: 0 at drivers/hwtracing/coresight/coresight-etm4x-core.c:1364 etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1215.967373] Modules linked in: coresight_etm4x(-) coresight [last unloaded: coresight] [ 1215.979960] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G W 5.8.0-rc5cs-modscs-mods-00020-gc03fe910680d #282 [ 1215.987856] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1215.998531] pstate: 80000085 (Nzcv daIf -PAN -UAO BTYPE=--) [ 1216.005396] pc : etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.010687] lr : notifier_call_chain+0x5c/0xa0 [ 1216.016926] sp : ffff000009fe7d50 [ 1216.021265] x29: ffff000009fe7d50 x28: 0000000000000000 [ 1216.024653] x27: 0000011b1d1464b5 x26: 0000000000000001 [ 1216.030035] x25: ffff00003c79f888 x24: 0000000000000001 [ 1216.035330] x23: 0000000000000000 x22: 0000000000000000 [ 1216.040626] x21: 0000000000000000 x20: 0000000000000000 [ 1216.045921] x19: ffff000038396480 x18: 0000000000000000 [ 1216.051216] x17: 0000000000000000 x16: 0000000000000000 [ 1216.056510] x15: 0000000000000000 x14: ffffffffffffffff [ 1216.061806] x13: ffffffffffffffff x12: 0000000000000000 [ 1216.067101] x11: 0000000000000000 x10: 00000000000009b0 [ 1216.072396] x9 : ffff000009fe7e70 x8 : ffff000009fd4010 [ 1216.077690] x7 : 0000000000000000 x6 : 0000000023c2c562 [ 1216.082986] x5 : 00ffffffffffffff x4 : 0000000000000003 [ 1216.088281] x3 : ffff000038396880 x2 : ffff800008d8d280 [ 1216.093576] x1 : ffff80002b1aa000 x0 : 000000005f454c42 [ 1216.098873] Call trace: [ 1216.104178] etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.106343] notifier_call_chain+0x5c/0xa0 [ 1216.112242] __atomic_notifier_call_chain+0x48/0x60 [ 1216.116236] cpu_pm_notify+0x44/0x70 [ 1216.121008] cpu_pm_enter+0x3c/0x80 [ 1216.124829] psci_enter_domain_idle_state+0x38/0xa8 [ 1216.128040] cpuidle_enter_state+0x88/0x478 [ 1216.132900] cpuidle_enter+0x44/0x58 [ 1216.137069] call_cpuidle+0x40/0x70 [ 1216.140888] do_idle+0x1e0/0x248 [ 1216.144099] cpu_startup_entry+0x28/0x98 [ 1216.147574] secondary_start_kernel+0x1a0/0x1f8 [ 1216.151476] ---[ end trace 97bcd7b8bdd7f9a7 ]---This happens each time, though the CPU number can change. Test platform is Dragonboard DB410, linux 5.8-rc5 + this patch set.
Regards
Mike
Quoted 20 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>Quoted 7 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Kconfig
Quoted 13 lines
index
8fd9fd139cf3..d6e107bbd30b100644drivers/hwtracing/coresight/Kconfig +1
-1@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x. config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDRdrivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X · line 88
Quoted 1 line
drivers/hwtracing/coresight/Kconfig +0
-0@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on the implementedversion
drivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig +3
-0data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) ||ARM64
Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Makefile
drivers/hwtracing/coresight/Makefile obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=
Quoted 4 lines
index
d619cfd0abd8..271dc255454f100644drivers/hwtracing/coresight/Makefile +0
-0@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=coresight-funnel.o \
Review
Quoted 11 lines
drivers/hwtracing/coresight/Makefile +2
-2obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-etm4x-core.cQuoted 10 lines
similarity index 98%
rename fromdrivers/hwtracing/coresight/coresight-etm4x.crename todrivers/hwtracing/coresight/coresight-etm4x-core.cindex747afc875f91..b5945f62794c100644drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +0
-0@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] = { } };drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] = { · line 1548
Quoted 10 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +10
-0+static int __exit etm4_remove(struct amba_device *adev) +{ +struct etmv4_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);Quoted 31 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +15
-1+if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */ @@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver);
Quoted 15 lines
Quoted 7 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +5
-1+ +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" ); --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 7 lines
a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Hi,
That fix sorts the problem on my board.
However, be aware that the etmv4 PM code changes somewhat due to this patch [1] that is currently on the linux master branch and will appear in 5.8-rc6, and there are further new coresight patches in Mathieu's coresight/next and linux-next.
It may be better to rebase onto coresight/next for the next set.
Regards
Mike
[1] 9b6a3f3633a5 coresight: etmv4: Fix CPU power management setup in probe() function
Quoted 34 lines · On Sat, 18 Jul 2020 at 04:25, <[email protected]> wrote:
Hi Mike,
Thanks for reporting this. This is a good catch.
I was testing on db845c but I didn't encounter this issue with multiple module load/unload test. I guess it's due to timing difference. The issue is
etm4_cpu_pm_notify()is removed from cpu pm notification after last etm4 device is removed. There's racing condition when some etm4 device say etm0 is removed butetm4_cpu_pm_notify()is still called. I reproduced this issue by manually unbind etm4x device.The fix is clean etmdrvdata[drvdata->cpu] in
etm4_remove()soetm4_cpu_pm_notify()is gracefully returned. I've verified this on db845c with manually unbind etm4x device test. Do you mind test on your db410 as well? I'll put it into v4.(quoted diff) +1
-0@@ -1542,6 +1543,7 @@ static int __exit etm4_remove(struct amba_device *adev) etm_perf_symlink(drvdata->csdev, false); + etmdrvdata[drvdata->cpu] = NULL; if (--etm4_count == 0) { etm4_cpu_pm_unregister();Quoted 5 lines · Mike Leach
Hi Tingwei,
Couldn't see 00/20 cover note for this set, so reporting this here as it relates to etmv4 in part.
Quoted 220 lines
Quoted 4 lines
The following sequence:-
(There is a load dependency here of course, if I try to load ETMv4 without the coresight core, then I get a lot of missing symbol error messages - I assume this is expected behaviour?)
Coresight_etm4xmodule depends on coresight module, so it's expected behavior.Quoted 212 lines
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.kocorrectly loads the coresight core then ETMv4 module.
[ 1208.214674] coresight etm0: CPU0: ETM v4.0 initialized [ 1208.215534] coresight etm1: CPU1: ETM v4.0 initialized [ 1208.221020] coresight etm2: CPU2: ETM v4.0 initialized [ 1208.224757] coresight etm3: CPU3: ETM v4.0 initializedHowever, if I then unload the ETMv4 module:-
root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-etm4x.koI get a crash:-
[ 1215.963689] ------------[ cut here ]------------ [ 1215.963741] WARNING: CPU: 3 PID: 0 at drivers/hwtracing/coresight/coresight-etm4x-core.c:1364 etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1215.967373] Modules linked in: coresight_etm4x(-) coresight [last unloaded: coresight] [ 1215.979960] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G W 5.8.0-rc5cs-modscs-mods-00020-gc03fe910680d #282 [ 1215.987856] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1215.998531] pstate: 80000085 (Nzcv daIf -PAN -UAO BTYPE=--) [ 1216.005396] pc : etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.010687] lr : notifier_call_chain+0x5c/0xa0 [ 1216.016926] sp : ffff000009fe7d50 [ 1216.021265] x29: ffff000009fe7d50 x28: 0000000000000000 [ 1216.024653] x27: 0000011b1d1464b5 x26: 0000000000000001 [ 1216.030035] x25: ffff00003c79f888 x24: 0000000000000001 [ 1216.035330] x23: 0000000000000000 x22: 0000000000000000 [ 1216.040626] x21: 0000000000000000 x20: 0000000000000000 [ 1216.045921] x19: ffff000038396480 x18: 0000000000000000 [ 1216.051216] x17: 0000000000000000 x16: 0000000000000000 [ 1216.056510] x15: 0000000000000000 x14: ffffffffffffffff [ 1216.061806] x13: ffffffffffffffff x12: 0000000000000000 [ 1216.067101] x11: 0000000000000000 x10: 00000000000009b0 [ 1216.072396] x9 : ffff000009fe7e70 x8 : ffff000009fd4010 [ 1216.077690] x7 : 0000000000000000 x6 : 0000000023c2c562 [ 1216.082986] x5 : 00ffffffffffffff x4 : 0000000000000003 [ 1216.088281] x3 : ffff000038396880 x2 : ffff800008d8d280 [ 1216.093576] x1 : ffff80002b1aa000 x0 : 000000005f454c42 [ 1216.098873] Call trace: [ 1216.104178] etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.106343] notifier_call_chain+0x5c/0xa0 [ 1216.112242] __atomic_notifier_call_chain+0x48/0x60 [ 1216.116236] cpu_pm_notify+0x44/0x70 [ 1216.121008] cpu_pm_enter+0x3c/0x80 [ 1216.124829] psci_enter_domain_idle_state+0x38/0xa8 [ 1216.128040] cpuidle_enter_state+0x88/0x478 [ 1216.132900] cpuidle_enter+0x44/0x58 [ 1216.137069] call_cpuidle+0x40/0x70 [ 1216.140888] do_idle+0x1e0/0x248 [ 1216.144099] cpu_startup_entry+0x28/0x98 [ 1216.147574] secondary_start_kernel+0x1a0/0x1f8 [ 1216.151476] ---[ end trace 97bcd7b8bdd7f9a7 ]---This happens each time, though the CPU number can change. Test platform is Dragonboard DB410, linux 5.8-rc5 + this patch set.
Regards
Mike
Quoted 20 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>Quoted 7 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Kconfig
Quoted 13 lines
index
8fd9fd139cf3..d6e107bbd30b100644drivers/hwtracing/coresight/Kconfig +1
-1@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x. config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDRdrivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X · line 88
Quoted 1 line
drivers/hwtracing/coresight/Kconfig +0
-0@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on the implementedversion
drivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig +3
-0data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) ||ARM64
Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Makefile
drivers/hwtracing/coresight/Makefile obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=
Quoted 4 lines
index
d619cfd0abd8..271dc255454f100644drivers/hwtracing/coresight/Makefile +0
-0@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=coresight-funnel.o \
Review
Quoted 11 lines
drivers/hwtracing/coresight/Makefile +2
-2obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-etm4x-core.cQuoted 10 lines
similarity index 98%
rename fromdrivers/hwtracing/coresight/coresight-etm4x.crename todrivers/hwtracing/coresight/coresight-etm4x-core.cindex747afc875f91..b5945f62794c100644drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +0
-0@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] = { } };drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] = { · line 1548
Quoted 10 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +10
-0+static int __exit etm4_remove(struct amba_device *adev) +{ +struct etmv4_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);Quoted 37 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +20
-2+if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */ @@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" ); --Quoted 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 7 lines
a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Hi Tingwei,
Quoted 10 lines · Mike Leach
Hi,
That fix sorts the problem on my board.
However, be aware that the etmv4 PM code changes somewhat due to this patch [1] that is currently on the linux master branch and will appear in 5.8-rc6, and there are further new coresight patches in Mathieu's coresight/next and linux-next.It may be better to rebase onto coresight/next for the next set.
As Mike suggested please rebase on coresight/next and send another revision.
Thanks,
Mathieu
Quoted 266 lines
Regards
Mike
[1]
9b6a3f3633a5coresight: etmv4: Fix CPU power management setup inprobe()functionQuoted 34 lines · On Sat, 18 Jul 2020 at 04:25, <[email protected]> wrote:
Hi Mike,
Thanks for reporting this. This is a good catch.
I was testing on db845c but I didn't encounter this issue with multiple module load/unload test. I guess it's due to timing difference. The issue is
etm4_cpu_pm_notify()is removed from cpu pm notification after last etm4 device is removed. There's racing condition when some etm4 device say etm0 is removed butetm4_cpu_pm_notify()is still called. I reproduced this issue by manually unbind etm4x device.The fix is clean etmdrvdata[drvdata->cpu] in
etm4_remove()soetm4_cpu_pm_notify()is gracefully returned. I've verified this on db845c with manually unbind etm4x device test. Do you mind test on your db410 as well? I'll put it into v4.(quoted diff) +1
-0@@ -1542,6 +1543,7 @@ static int __exit etm4_remove(struct amba_device *adev) etm_perf_symlink(drvdata->csdev, false); + etmdrvdata[drvdata->cpu] = NULL; if (--etm4_count == 0) { etm4_cpu_pm_unregister();Quoted 5 lines · Mike Leach
Hi Tingwei,
Couldn't see 00/20 cover note for this set, so reporting this here as it relates to etmv4 in part.
Quoted 220 lines
Quoted 4 lines
The following sequence:-
(There is a load dependency here of course, if I try to load ETMv4 without the coresight core, then I get a lot of missing symbol error messages - I assume this is expected behaviour?)
Coresight_etm4xmodule depends on coresight module, so it's expected behavior.Quoted 212 lines
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.kocorrectly loads the coresight core then ETMv4 module.
[ 1208.214674] coresight etm0: CPU0: ETM v4.0 initialized [ 1208.215534] coresight etm1: CPU1: ETM v4.0 initialized [ 1208.221020] coresight etm2: CPU2: ETM v4.0 initialized [ 1208.224757] coresight etm3: CPU3: ETM v4.0 initializedHowever, if I then unload the ETMv4 module:-
root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-etm4x.koI get a crash:-
[ 1215.963689] ------------[ cut here ]------------ [ 1215.963741] WARNING: CPU: 3 PID: 0 at drivers/hwtracing/coresight/coresight-etm4x-core.c:1364 etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1215.967373] Modules linked in: coresight_etm4x(-) coresight [last unloaded: coresight] [ 1215.979960] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G W 5.8.0-rc5cs-modscs-mods-00020-gc03fe910680d #282 [ 1215.987856] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1215.998531] pstate: 80000085 (Nzcv daIf -PAN -UAO BTYPE=--) [ 1216.005396] pc : etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.010687] lr : notifier_call_chain+0x5c/0xa0 [ 1216.016926] sp : ffff000009fe7d50 [ 1216.021265] x29: ffff000009fe7d50 x28: 0000000000000000 [ 1216.024653] x27: 0000011b1d1464b5 x26: 0000000000000001 [ 1216.030035] x25: ffff00003c79f888 x24: 0000000000000001 [ 1216.035330] x23: 0000000000000000 x22: 0000000000000000 [ 1216.040626] x21: 0000000000000000 x20: 0000000000000000 [ 1216.045921] x19: ffff000038396480 x18: 0000000000000000 [ 1216.051216] x17: 0000000000000000 x16: 0000000000000000 [ 1216.056510] x15: 0000000000000000 x14: ffffffffffffffff [ 1216.061806] x13: ffffffffffffffff x12: 0000000000000000 [ 1216.067101] x11: 0000000000000000 x10: 00000000000009b0 [ 1216.072396] x9 : ffff000009fe7e70 x8 : ffff000009fd4010 [ 1216.077690] x7 : 0000000000000000 x6 : 0000000023c2c562 [ 1216.082986] x5 : 00ffffffffffffff x4 : 0000000000000003 [ 1216.088281] x3 : ffff000038396880 x2 : ffff800008d8d280 [ 1216.093576] x1 : ffff80002b1aa000 x0 : 000000005f454c42 [ 1216.098873] Call trace: [ 1216.104178] etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.106343] notifier_call_chain+0x5c/0xa0 [ 1216.112242] __atomic_notifier_call_chain+0x48/0x60 [ 1216.116236] cpu_pm_notify+0x44/0x70 [ 1216.121008] cpu_pm_enter+0x3c/0x80 [ 1216.124829] psci_enter_domain_idle_state+0x38/0xa8 [ 1216.128040] cpuidle_enter_state+0x88/0x478 [ 1216.132900] cpuidle_enter+0x44/0x58 [ 1216.137069] call_cpuidle+0x40/0x70 [ 1216.140888] do_idle+0x1e0/0x248 [ 1216.144099] cpu_startup_entry+0x28/0x98 [ 1216.147574] secondary_start_kernel+0x1a0/0x1f8 [ 1216.151476] ---[ end trace 97bcd7b8bdd7f9a7 ]---This happens each time, though the CPU number can change. Test platform is Dragonboard DB410, linux 5.8-rc5 + this patch set.
Regards
Mike
Quoted 20 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>Quoted 7 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Kconfig
Quoted 13 lines
index
8fd9fd139cf3..d6e107bbd30b100644drivers/hwtracing/coresight/Kconfig +1
-1@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x. config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDRdrivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X · line 88
Quoted 1 line
drivers/hwtracing/coresight/Kconfig +0
-0@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on the implementedversion
drivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig +3
-0data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) ||ARM64
Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Makefile
drivers/hwtracing/coresight/Makefile obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=
Quoted 4 lines
index
d619cfd0abd8..271dc255454f100644drivers/hwtracing/coresight/Makefile +0
-0@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=coresight-funnel.o \
Review
Quoted 11 lines
drivers/hwtracing/coresight/Makefile +2
-2obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-etm4x-core.cQuoted 10 lines
similarity index 98%
rename fromdrivers/hwtracing/coresight/coresight-etm4x.crename todrivers/hwtracing/coresight/coresight-etm4x-core.cindex747afc875f91..b5945f62794c100644drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +0
-0@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] = { } };drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] = { · line 1548
Quoted 10 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +10
-0+static int __exit etm4_remove(struct amba_device *adev) +{ +struct etmv4_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);Quoted 37 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +20
-2+if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */ @@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" ); --Quoted 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 7 lines
a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 4 lines
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Quoted 11 lines · Mathieu Poirier
Hi Tingwei,
Quoted 8 lines · Mike Leach
Hi,
That fix sorts the problem on my board.
However, be aware that the etmv4 PM code changes somewhat due to this patch [1] that is currently on the linux master branch and will appear in 5.8-rc6, and there are further new coresight patches in Mathieu's coresight/next and linux-next.
Quoted 9 lines
Quoted 2 lines
It may be better to rebase onto coresight/next for the next set.
As Mike suggested please rebase on coresight/next and send another revision.
Thanks,
Mathieu
Sure. I'll rebase to coresight/next and send another revision.
Quoted 280 lines
Quoted 16 lines
Regards
Mike
[1]
9b6a3f3633a5coresight: etmv4: Fix CPU power management setup inprobe()functionQuoted 7 lines · On Sat, 18 Jul 2020 at 04:25, <[email protected]> wrote:
Hi Mike,
Thanks for reporting this. This is a good catch.
I was testing on db845c but I didn't encounter this issue with multiple module load/unload test. I guess it's due to timing
difference.
Quoted 21 lines
Quoted 21 lines
The issue is
etm4_cpu_pm_notify()is removed from cpu pm notification after last etm4 device is removed. There's racing condition when some etm4 device say etm0 is removed butetm4_cpu_pm_notify()is still called. I reproduced this issue by manually unbind etm4x device.The fix is clean etmdrvdata[drvdata->cpu] in
etm4_remove()soetm4_cpu_pm_notify()is gracefully returned. I've verified this on db845c with manually unbind etm4x device test. Do you mind test on your db410 as well? I'll put it into v4.(quoted diff) +1
-0@@ -1542,6 +1543,7 @@ static int __exit etm4_remove(struct amba_device *adev) etm_perf_symlink(drvdata->csdev, false); + etmdrvdata[drvdata->cpu] = NULL; if (--etm4_count == 0) { etm4_cpu_pm_unregister();Quoted 4 lines
Quoted 4 lines · Mike Leach
Quoted 3 lines
Hi Tingwei,
Couldn't see 00/20 cover note for this set, so reporting this here
as
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
it relates to etmv4 in part.
The following sequence:-
(There is a load dependency here of course, if I try to load ETMv4 without the coresight core, then I get a lot of missing symbol error messages - I assume this is expected behaviour?)Quoted 6 lines
Quoted 6 lines
Coresight_etm4xmodule depends on coresight module, so it's expected behavior.Quoted 3 lines
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmodcoresight-etm4x.ko
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
correctly loads the coresight core then ETMv4 module.
[ 1208.214674] coresight etm0: CPU0: ETM v4.0 initialized [ 1208.215534] coresight etm1: CPU1: ETM v4.0 initialized [ 1208.221020] coresight etm2: CPU2: ETM v4.0 initialized [ 1208.224757] coresight etm3: CPU3: ETM v4.0 initializedHowever, if I then unload the ETMv4 module:-
root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-etm4x.koI get a crash:-
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
[ 1215.963689] ------------[ cut here ]------------ [ 1215.963741] WARNING: CPU: 3 PID: 0 at drivers/hwtracing/coresight/coresight-etm4x-core.c:1364 etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1215.967373] Modules linked in: coresight_etm4x(-) coresight [last unloaded: coresight] [ 1215.979960] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G W 5.8.0-rc5cs-modscs-mods-00020-gc03fe910680d #282 [ 1215.987856] Hardware name: Qualcomm Technologies, Inc. APQ 8016SBC
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
(DT)
[ 1215.998531] pstate: 80000085 (Nzcv daIf -PAN -UAO BTYPE=--) [ 1216.005396] pc : etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.010687] lr : notifier_call_chain+0x5c/0xa0 [ 1216.016926] sp : ffff000009fe7d50 [ 1216.021265] x29: ffff000009fe7d50 x28: 0000000000000000 [ 1216.024653] x27: 0000011b1d1464b5 x26: 0000000000000001 [ 1216.030035] x25: ffff00003c79f888 x24: 0000000000000001 [ 1216.035330] x23: 0000000000000000 x22: 0000000000000000 [ 1216.040626] x21: 0000000000000000 x20: 0000000000000000 [ 1216.045921] x19: ffff000038396480 x18: 0000000000000000 [ 1216.051216] x17: 0000000000000000 x16: 0000000000000000 [ 1216.056510] x15: 0000000000000000 x14: ffffffffffffffff [ 1216.061806] x13: ffffffffffffffff x12: 0000000000000000 [ 1216.067101] x11: 0000000000000000 x10: 00000000000009b0 [ 1216.072396] x9 : ffff000009fe7e70 x8 : ffff000009fd4010 [ 1216.077690] x7 : 0000000000000000 x6 : 0000000023c2c562 [ 1216.082986] x5 : 00ffffffffffffff x4 : 0000000000000003 [ 1216.088281] x3 : ffff000038396880 x2 : ffff800008d8d280 [ 1216.093576] x1 : ffff80002b1aa000 x0 : 000000005f454c42 [ 1216.098873] Call trace: [ 1216.104178] etm4_cpu_pm_notify+0xad8/0xb48 [coresight_etm4x] [ 1216.106343] notifier_call_chain+0x5c/0xa0 [ 1216.112242] __atomic_notifier_call_chain+0x48/0x60 [ 1216.116236] cpu_pm_notify+0x44/0x70 [ 1216.121008] cpu_pm_enter+0x3c/0x80 [ 1216.124829] psci_enter_domain_idle_state+0x38/0xa8 [ 1216.128040] cpuidle_enter_state+0x88/0x478 [ 1216.132900] cpuidle_enter+0x44/0x58 [ 1216.137069] call_cpuidle+0x40/0x70 [ 1216.140888] do_idle+0x1e0/0x248 [ 1216.144099] cpu_startup_entry+0x28/0x98 [ 1216.147574] secondary_start_kernel+0x1a0/0x1f8 [ 1216.151476] ---[ end trace 97bcd7b8bdd7f9a7 ]---This happens each time, though the CPU number can change. Test platform is Dragonboard DB410, linux 5.8-rc5 + this patch set.
Regards
Mike
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of
development.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 16 lines
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>Quoted 7 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Kconfig
Quoted 6 lines
index
8fd9fd139cf3..d6e107bbd30b100644drivers/hwtracing/coresight/Kconfig +0
-0@@ -78,7 +78,7 @@ config CORESIGHT_SOURCE_ETM3X module will be called coresight-etm3x.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X · line 88
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig +1
-1config CORESIGHT_SOURCE_ETM4X - bool "CoreSight Embedded Trace Macrocell 4.x driver" + tristate "CoreSight Embedded Trace Macrocell 4.x driver" depends on ARM64 select CORESIGHT_LINKS_AND_SINKS select PID_IN_CONTEXTIDR@@ -88,6 +88,9 @@ config CORESIGHT_SOURCE_ETM4X for instruction level tracing. Depending on theimplemented
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
version
drivers/hwtracing/coresight/Kconfig config CORESIGHT_SOURCE_ETM4X
Quoted 8 lines
drivers/hwtracing/coresight/Kconfig +3
-0data tracing may also be available. + To compile this driver as a module, choose M here: the + module will be called coresight-etm4x. + config CORESIGHT_STM tristate "CoreSight System Trace Macrocell driver" depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) ||ARM64
Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Makefile
drivers/hwtracing/coresight/Makefile obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=
Quoted 4 lines
index
d619cfd0abd8..271dc255454f100644drivers/hwtracing/coresight/Makefile +0
-0@@ -14,8 +14,8 @@ obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) +=coresight-funnel.o \
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/hwtracing/coresight/Makefile obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \
Quoted 7 lines
drivers/hwtracing/coresight/Makefile +2
-2obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \ coresight-etm3x-sysfs.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \ - coresight-etm4x-sysfs.o +obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o +coresight-etm4x-y := coresight-etm4x-core.ocoresight-etm4x-sysfs.o
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 4 lines
drivers/hwtracing/coresight/Makefile +0
-0obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-etm4x-core.cQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] =
Quoted 7 lines
similarity index 98%
rename fromdrivers/hwtracing/coresight/coresight-etm4x.crename todrivers/hwtracing/coresight/coresight-etm4x-core.cindex747afc875f91..b5945f62794c100644drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +0
-0@@ -1536,6 +1536,26 @@ static struct amba_cs_uci_id uci_id_etm4[] ={
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] = {
Quoted 6 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +3
-0} }; +static int __exit etm4_remove(struct amba_device *adev) +{ + struct etmv4_drvdata *drvdata =
dev_get_drvdata(&adev->dev);Quoted 57 lines
Quoted 47 lines
Quoted 47 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c static struct amba_cs_uci_id uci_id_etm4[] = { · line 1552
Quoted 7 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +7
-0+ +etm_perf_symlink (drvdata->csdev, false); + +if (--etm4_count ==0 ) { +etm4_cpu_pm_unregister (); + +
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);Quoted 37 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c renamed from drivers/hwtracing/coresight/coresight-etm4x.c +20
-2+if (hp_online) +cpuhp_remove_state_nocalls (hp_online); + } + +coresight_unregister (drvdata->csdev); + +return 0 ; +} + +static const struct amba_id etm4_ids[] = {CS_AMBA_ID (0x000bb95d ),/* Cortex-A53 */ CS_AMBA_ID (0x000bb95e ),/* Cortex-A57 */ @@ -1553,12 +1573,21 @@ static const struct amba_id etm4_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, etm4_ids); +static struct amba_driver etm4x_driver = { .drv = { .name ="coresight-etm4x" , + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = etm4_probe, + .remove = etm4_remove, .id_table = etm4_ids, }; -builtin_amba_driver (etm4x_driver); +module_amba_driver (etm4x_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Program Flow Trace v4 driver" ); +MODULE_LICENSE ("GPL v2" ); --Quoted 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernelQuoted 4 lines
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
In reply to Tingwei ZhangHi Tingwei,
Quoted 19 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>
Quoted 8 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)
<snip>...
Thanks for adding this support. etm4_cpu_pm_unregister() is dropped now with change to ETM PM code. You can base the patches on coresight-next - https://git.linaro.org/kernel/coresight.git/log/?h=next
Also I am trying this series on SDM845 MTP (5.8.0-rc5) with Debian distribution, I see below warning when trying to disable ETM, logs below:
root@linaro-developer:~# lsmod Module Size Used by cpufreq_powersave 16384 0 cpufreq_conservative 16384 0 msm 856064 1 coresight_stm 24576 0 crct10dif_ce 20480 1 stm_core 28672 1 coresight_stm i2c_qcom_geni 24576 0 qcom_rng 16384 0 coresight_tmc 40960 0 coresight_funnel 20480 0 coresight_etm4x 61440 0 coresight_replicator 20480 0 camcc_sdm845 49152 0 ath10k_snoc 53248 0 socinfo 20480 0 ip_tables 32768 0 x_tables 45056 1 ip_tables ipv6 458752 26 nf_defrag_ipv6 24576 1 ipv6 root@linaro-developer:~# root@linaro-developer:~# echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink root@linaro-developer:~# echo 1 > /sys/bus/coresight/devices/etm0/enable_source root@linaro-developer:~# echo 0 > /sys/bus/coresight/devices/etm0/enable_source [ 332.855363] ------------[ cut here ]------------ [ 332.860175] WARNING: CPU: 0 PID: 0 at drivers/hwtracing/coresight/coresight-core.c:227 coresight_disclaim_device_unlocked+0x28/0x50 [ 332.872177] Modules linked in: cpufreq_powersave cpufreq_conservative msm(+) coresight_stm crct10dif_ce stm_core i2c_qcom_geni qcom_rng coresi ght_tmc coresight_funnel coresight_etm4x coresight_replicator camcc_sdm845 ath10k_snoc socinfo ip_tables x_tables ipv6 nf_defrag_ipv6 [ 332.897043] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G D W 5.8.0-rc5-next-20200716-00040-g50ad3222c13f-dirty #80 [ 332.908330] Hardware name: Qualcomm Technologies, Inc. SDM845 MTP (DT) [ 332.914969] pstate: 80400085 (Nzcv daIf +PAN -UAO BTYPE=--) [ 332.920643] pc : coresight_disclaim_device_unlocked+0x28/0x50 [ 332.926543] lr : etm4_disable_hw+0xd8/0x128 [coresight_etm4x] [ 332.932391] sp : ffff800010003ed0 [ 332.935775] x29: ffff800010003ed0 x28: ffffb05e1bd13980 [ 332.941193] x27: 0000004d7fb06ef3 x26: ffff800010004000 [ 332.946606] x25: 0000000000000000 x24: ffffb05e1bd03cc0 [ 332.952022] x23: 0000000000000000 x22: 0000000000000000 [ 332.957436] x21: ffff800010c73c00 x20: ffff000175547400 [ 332.962851] x19: ffff8000103af000 x18: 0000000000000005 [ 332.968267] x17: 0000000000000000 x16: ffffb05e1a875f38 [ 332.973678] x15: 0000000000000000 x14: ffffb05e1bd13980 [ 332.979093] x13: ffff4fa361082000 x12: 000000003474591d [ 332.984507] x11: 0000000000000000 x10: 0000000000001000 [ 332.989920] x9 : ffffb05e19a81800 x8 : 000001b2b5503510 [ 332.995336] x7 : 000000b2b5503510 x6 : 000000003fd5ea33 [ 333.000749] x5 : 00ffffffffffffff x4 : 000000000000b2be [ 333.006162] x3 : ffff0001725c8150 x2 : ffff8000103af168 [ 333.011574] x1 : 0000000000000000 x0 : ffff8000103affa4 [ 333.016993] Call trace: [ 333.019516] coresight_disclaim_device_unlocked+0x28/0x50 [ 333.025035] etm4_disable_hw+0xd8/0x128 [coresight_etm4x] [ 333.030552] flush_smp_call_function_queue+0x154/0x250 [ 333.035795] generic_smp_call_function_single_interrupt+0x18/0x20 [ 333.041999] handle_IPI+0x32c/0x390 [ 333.045569] gic_handle_irq+0x15c/0x160 [ 333.049489] el1_irq+0xb8/0x180 [ 333.052709] cpuidle_enter_state+0xac/0x4e8 [ 333.056983] cpuidle_enter+0x3c/0x50 [ 333.060646] call_cpuidle+0x40/0x70 [ 333.064210] do_idle+0x20c/0x290 [ 333.067516] cpu_startup_entry+0x28/0x70 [ 333.071528] rest_init+0xdc/0xe8 [ 333.074847] arch_call_rest_init+0x14/0x1c [ 333.079027] start_kernel+0x4e0/0x518 [ 333.082764] ---[ end trace 162d5cef8c2b863b ]--- root@linaro-developer:~#
Thanks,
Sai
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 08/20] coresight: allow etm4x to be built as a module
Hi Tingwei,
Quoted 110 lines · Sai Prakash Ranjan
Hi Tingwei,
Quoted 19 lines · Tingwei Zhang
From: Kim Phillips <[email protected]>
Allow to build coresight-etm4x as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-etm4x by theMakefile
- add anetm4_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootCc Mathieu Poirier <[email protected]>Cc Leo Yan <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Randy Dunlap <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Signed-off-by Kim Phillips <[email protected]>Signed-off-by Tingwei Zhang <[email protected]>Quoted 9 lines
--- drivers/hwtracing/coresight/Kconfig | 5 ++- drivers/hwtracing/coresight/Makefile | 4 +-- ...resight-etm4x.c => coresight-etm4x-core.c} | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) rename drivers/hwtracing/coresight/{coresight-etm4x.c =>
coresight-etm4x-core.c} (98%)<snip>...
Thanks for adding this support.
etm4_cpu_pm_unregister()is dropped now with change to ETM PM code.
You can base the patches on coresight-next -
https://git.linaro.org/kernel/coresight.git/log/?h=nextAlso I am trying this series on SDM845 MTP (5.8.0-rc5) with Debian distribution, I see below warning when trying to disable ETM, logs below:
root@linaro-developer:~# lsmod Module Size Used by cpufreq_powersave 16384 0 cpufreq_conservative 16384 0 msm 856064 1 coresight_stm 24576 0 crct10dif_ce 20480 1 stm_core 28672 1 coresight_stm i2c_qcom_geni 24576 0 qcom_rng 16384 0 coresight_tmc 40960 0 coresight_funnel 20480 0 coresight_etm4x 61440 0 coresight_replicator 20480 0 camcc_sdm845 49152 0 ath10k_snoc 53248 0 socinfo 20480 0 ip_tables 32768 0 x_tables 45056 1 ip_tables ipv6 458752 26 nf_defrag_ipv6 24576 1 ipv6 root@linaro-developer:~# root@linaro-developer:~# echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink root@linaro-developer:~# echo 1 > /sys/bus/coresight/devices/etm0/enable_source root@linaro-developer:~# echo 0 > /sys/bus/coresight/devices/etm0/enable_source [ 332.855363] ------------[ cut here ]------------ [ 332.860175] WARNING: CPU: 0 PID: 0 at drivers/hwtracing/coresight/coresight-core.c:227 coresight_disclaim_device_unlocked+0x28/0x50 [ 332.872177] Modules linked in: cpufreq_powersave cpufreq_conservative msm(+) coresight_stm crct10dif_ce stm_core i2c_qcom_geni qcom_rng coresi ght_tmc coresight_funnel coresight_etm4x coresight_replicator camcc_sdm845 ath10k_snoc socinfo ip_tables x_tables ipv6 nf_defrag_ipv6 [ 332.897043] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G D W 5.8.0-rc5-next-20200716-00040-g50ad3222c13f-dirty #80 [ 332.908330] Hardware name: Qualcomm Technologies, Inc. SDM845 MTP (DT) [ 332.914969] pstate: 80400085 (Nzcv daIf +PAN -UAO BTYPE=--) [ 332.920643] pc : coresight_disclaim_device_unlocked+0x28/0x50 [ 332.926543] lr : etm4_disable_hw+0xd8/0x128 [coresight_etm4x] [ 332.932391] sp : ffff800010003ed0 [ 332.935775] x29: ffff800010003ed0 x28: ffffb05e1bd13980 [ 332.941193] x27: 0000004d7fb06ef3 x26: ffff800010004000 [ 332.946606] x25: 0000000000000000 x24: ffffb05e1bd03cc0 [ 332.952022] x23: 0000000000000000 x22: 0000000000000000 [ 332.957436] x21: ffff800010c73c00 x20: ffff000175547400 [ 332.962851] x19: ffff8000103af000 x18: 0000000000000005 [ 332.968267] x17: 0000000000000000 x16: ffffb05e1a875f38 [ 332.973678] x15: 0000000000000000 x14: ffffb05e1bd13980 [ 332.979093] x13: ffff4fa361082000 x12: 000000003474591d [ 332.984507] x11: 0000000000000000 x10: 0000000000001000 [ 332.989920] x9 : ffffb05e19a81800 x8 : 000001b2b5503510 [ 332.995336] x7 : 000000b2b5503510 x6 : 000000003fd5ea33 [ 333.000749] x5 : 00ffffffffffffff x4 : 000000000000b2be [ 333.006162] x3 : ffff0001725c8150 x2 : ffff8000103af168 [ 333.011574] x1 : 0000000000000000 x0 : ffff8000103affa4 [ 333.016993] Call trace: [ 333.019516] coresight_disclaim_device_unlocked+0x28/0x50 [ 333.025035] etm4_disable_hw+0xd8/0x128 [coresight_etm4x] [ 333.030552] flush_smp_call_function_queue+0x154/0x250 [ 333.035795] generic_smp_call_function_single_interrupt+0x18/0x20 [ 333.041999] handle_IPI+0x32c/0x390 [ 333.045569] gic_handle_irq+0x15c/0x160 [ 333.049489] el1_irq+0xb8/0x180 [ 333.052709] cpuidle_enter_state+0xac/0x4e8 [ 333.056983] cpuidle_enter+0x3c/0x50
Quoted 9 lines
[ 333.060646] call_cpuidle+0x40/0x70 [ 333.064210] do_idle+0x20c/0x290 [ 333.067516] cpu_startup_entry+0x28/0x70 [ 333.071528] rest_init+0xdc/0xe8 [ 333.074847] arch_call_rest_init+0x14/0x1c [ 333.079027] start_kernel+0x4e0/0x518 [ 333.082764] ---[ end trace 162d5cef8c2b863b ]--- root@linaro-developer:~#
I found that above warning is not due to your changes. If I add "arm,coresight-loses-context-with-cpu" to SDM845 ETM nodes then I don't see these warnings, so will add them since idle support is present on sdm845.
Thanks,
Sai
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 9/20 coresight: allow etb to be built as a module
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-etb10 as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- add an etb_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/coresight-etb10.c | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/Kconfig +4 -1
@@ -57,13 +57,16 @@ config CORESIGHT_SINK_TPIU the on-board coresight memory can handle. config CORESIGHT_SINK_ETBV10 - bool "Coresight ETBv1.0 driver" + tristate "Coresight ETBv1.0 driver" depends on CORESIGHT_LINKS_AND_SINKS help This enables support for the Embedded Trace Buffer version 1.0 driver that complies with the generic implementation of the component without special enhancement or added features. + To compile this driver as a module, choose M here: the + module will be called coresight-etb10. + config CORESIGHT_SOURCE_ETM3X tristate "CoreSight Embedded Trace Macrocell 3.x driver" depends on !ARM64
drivers/hwtracing/coresight/coresight-etb10.c +19 -1
@@ -801,6 +801,16 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)return ret; } +static int __exit etb_remove(struct amba_device *adev) +{ +struct etb_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +misc_deregister (&drvdata->miscdev); +coresight_unregister (drvdata->csdev); + +return 0 ; +} +#ifdef CONFIG_PM static int etb_runtime_suspend (struct device *dev) {
@@ -835,6 +845,8 @@ static const struct amba_id etb_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, etb_ids); + static struct amba_driver etb_driver = { .drv = { .name = "coresight-etb10",
@@ -844,6 +856,12 @@ static struct amba_driver etb_driver = { }, .probe = etb_probe, + .remove = etb_remove, .id_table = etb_ids, }; -builtin_amba_driver (etb_driver); +module_amba_driver (etb_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Embedded Trace Buffer driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 10/20 coresight: allow tpiu to be built as a module
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-tpiu as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- add a tpiu_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/coresight-tpiu.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/Kconfig +4 -1
@@ -46,7 +46,7 @@ config CORESIGHT_CATU mode where the address is not translated. config CORESIGHT_SINK_TPIU - bool "Coresight generic TPIU driver" + tristate "Coresight generic TPIU driver" depends on CORESIGHT_LINKS_AND_SINKS help This enables support for the Trace Port Interface Unit driver,
@@ -56,6 +56,9 @@ config CORESIGHT_SINK_TPIU connected to an external host for use case capturing more traces than the on-board coresight memory can handle. + To compile this driver as a module, choose M here: the + module will be called coresight-tpiu. + config CORESIGHT_SINK_ETBV10 tristate "Coresight ETBv1.0 driver" depends on CORESIGHT_LINKS_AND_SINKS
drivers/hwtracing/coresight/coresight-tpiu.c +18 -1
@@ -173,6 +173,15 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)return PTR_ERR (drvdata->csdev); } +static int __exit tpiu_remove(struct amba_device *adev) +{ +struct tpiu_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +} +#ifdef CONFIG_PM static int tpiu_runtime_suspend (struct device *dev) {
@@ -216,6 +225,8 @@ static const struct amba_id tpiu_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, tpiu_ids); + static struct amba_driver tpiu_driver = { .drv = { .name = "coresight-tpiu",
@@ -224,6 +235,12 @@ static struct amba_driver tpiu_driver = { .suppress_bind_attrs = true, }, .probe = tpiu_probe, + .remove = tpiu_remove, .id_table = tpiu_ids, }; -builtin_amba_driver (tpiu_driver); +module_amba_driver (tpiu_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight TPIU (Trace Port Interface Unit) driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 11/20 coresight: allow tmc to be built as a module
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-tmc as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-tmc by the Makefile
- add an tmc_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
---
drivers/hwtracing/coresight/Kconfig | 6 +++++-
drivers/hwtracing/coresight/Makefile | 6 +++---
.../{coresight-tmc.c => coresight-tmc-core.c} | 19 ++++++++++++++++++-
3 files changed, 26 insertions(+), 5 deletions(-)
rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (96%)drivers/hwtracing/coresight/Kconfig +5 -1
@@ -25,7 +25,8 @@ config CORESIGHT_LINKS_AND_SINKS entity at run time to form a complete trace path. config CORESIGHT_LINK_AND_SINK_TMC - bool "Coresight generic TMC driver" + tristate "Coresight generic TMC driver" + depends on CORESIGHT_LINKS_AND_SINKS help This enables support for the Trace Memory Controller driver.
@@ -34,6 +35,9 @@ config CORESIGHT_LINK_AND_SINK_TMC complies with the generic implementation of the component without special enhancement or added features. + To compile this driver as a module, choose M here: the + module will be called coresight-tmc. + config CORESIGHT_CATU bool "Coresight Address Translation Unit (CATU) driver" depends on CORESIGHT_LINK_AND_SINK_TMC
drivers/hwtracing/coresight/Makefile +3 -3
@@ -4,9 +4,9 @@ # obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o \ coresight-platform.o coresight-sysfs.o -obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \ - coresight-tmc-etf.o \ - coresight-tmc-etr.o +obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o +coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \ + coresight-tmc-etr.o obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o obj-$(CONFIG_CORESIGHT_SINK_ETBV10) += coresight-etb10.o obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \
drivers/hwtracing/coresight/coresight-tmc-core.c renamed from drivers/hwtracing/coresight/coresight-tmc.c +18 -1
@@ -538,6 +538,16 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)return ret; } +static int __exit tmc_remove(struct amba_device *adev) +{ +struct tmc_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +misc_deregister (&drvdata->miscdev); +coresight_unregister (drvdata->csdev); + +return 0 ; +} +static const struct amba_id tmc_ids[] = {CS_AMBA_ID (0x000bb961 ),/* Coresight SoC 600 TMC-ETR/ETS */
@@ -549,6 +559,8 @@ static const struct amba_id tmc_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, tmc_ids); + static struct amba_driver tmc_driver = { .drv = { .name = "coresight-tmc",
@@ -556,6 +568,11 @@ static struct amba_driver tmc_driver = { .suppress_bind_attrs = true, }, .probe = tmc_probe, + .remove = tmc_remove, .id_table = tmc_ids, }; -builtin_amba_driver (tmc_driver); +module_amba_driver (tmc_driver); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Trace Memory Controller driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 12/20 coresight: remove multiple init calls from funnel driver
In reply to Tingwei ZhangFrom: Mian Yousaf Kaukab <[email protected]>
Dynamic-funnel uses module_amba_driver to register. Whereas static-funnel uses builtin_platform_driver. Combine these init calls into a single module_init/exit pair in preparation to make the driver modular.
--- .../hwtracing/coresight/coresight-funnel.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-funnel.c +28 -2
@@ -341,7 +341,6 @@ static struct platform_driver static_funnel_driver = { .suppress_bind_attrs = true, }, }; -builtin_platform_driver (static_funnel_driver);static int dynamic_funnel_probe (struct amba_device *adev,const struct amba_id *id)
@@ -372,4 +371,31 @@ static struct amba_driver dynamic_funnel_driver = { .probe = dynamic_funnel_probe, .id_table = dynamic_funnel_ids, }; -builtin_amba_driver (dynamic_funnel_driver); + +static int __init funnel_init (void ) +{ +int ret; + + ret =platform_driver_register (&static_funnel_driver); +if (ret) { +pr_info ("Error registering platform driver\n" ); +return ret; + } + + ret =amba_driver_register (&dynamic_funnel_driver); +if (ret) { +pr_info ("Error registering amba driver\n" ); +platform_driver_unregister (&static_funnel_driver); + } + +return ret; +} + +static void __exit funnel_exit(void) +{ +platform_driver_unregister (&static_funnel_driver); +amba_driver_unregister (&dynamic_funnel_driver); +} + +module_init (funnel_init); +module_exit (funnel_exit);
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 13/20 coresight: remove multiple init calls from replicator driver
In reply to Tingwei ZhangFrom: Mian Yousaf Kaukab <[email protected]>
Dynamic-replicator uses module_amba_driver to register. Whereas static-replicator uses builtin_platform_driver. Combine these init calls into a single module_init/exit pair in preparation to make the driver modular.
--- .../coresight/coresight-replicator.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-replicator.c +28 -2
@@ -339,7 +339,6 @@ static struct platform_driver static_replicator_driver = { .suppress_bind_attrs = true, }, }; -builtin_platform_driver (static_replicator_driver);static int dynamic_replicator_probe (struct amba_device *adev,const struct amba_id *id)
@@ -369,4 +368,31 @@ static struct amba_driver dynamic_replicator_driver = { .probe = dynamic_replicator_probe, .id_table = dynamic_replicator_ids, }; -builtin_amba_driver (dynamic_replicator_driver); + +static int __init replicator_init (void ) +{ +int ret; + + ret =platform_driver_register (&static_replicator_driver); +if (ret) { +pr_info ("Error registering platform driver\n" ); +return ret; + } + + ret =amba_driver_register (&dynamic_replicator_driver); +if (ret) { +pr_info ("Error registering amba driver\n" ); +platform_driver_unregister (&static_replicator_driver); + } + +return ret; +} + +static void __exit replicator_exit(void) +{ +platform_driver_unregister (&static_replicator_driver); +amba_driver_unregister (&dynamic_replicator_driver); +} + +module_init (replicator_init); +module_exit (replicator_exit);
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 14/20 coresight: allow funnel and replicator drivers to be built as modules
In reply to Tingwei ZhangFrom: Kim Phillips <[email protected]>
Allow to build coresight-funnel and coresight-replicator as modules, for ease of development.
- Kconfig becomes a tristate, to allow =m
- add funnel_remove and replicator_remove functions, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
--- drivers/hwtracing/coresight/Kconfig | 5 ++- .../hwtracing/coresight/coresight-funnel.c | 32 ++++++++++++++++++ .../coresight/coresight-replicator.c | 33 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/Kconfig +4 -1
@@ -17,13 +17,16 @@ menuconfig CORESIGHT if CORESIGHT config CORESIGHT_LINKS_AND_SINKS - bool "CoreSight Link and Sink drivers" + tristate "CoreSight Link and Sink drivers" help This enables support for CoreSight link and sink drivers that are responsible for transporting and collecting the trace data respectively. Link and sinks are dynamically aggregated with a trace entity at run time to form a complete trace path. + To compile these drivers as modules, choose M here: the + modules will be called coresight-funnel and coresight-replicator. + config CORESIGHT_LINK_AND_SINK_TMC tristate "Coresight generic TMC driver"
drivers/hwtracing/coresight/coresight-funnel.c +32 -0
@@ -274,6 +274,15 @@ static int funnel_probe(struct device *dev, struct resource *res)return ret; } +static int __exit funnel_remove(struct device *dev) +{ +struct funnel_drvdata *drvdata =dev_get_drvdata (dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +} +#ifdef CONFIG_PM static int funnel_runtime_suspend (struct device *dev) {
@@ -319,20 +328,31 @@ static int static_funnel_probe(struct platform_device *pdev)return ret; } +static int __exit static_funnel_remove(struct platform_device *pdev) +{ +funnel_remove (&pdev->dev); +pm_runtime_disable (&pdev->dev); +return 0 ; +} +static const struct of_device_id static_funnel_match[] = { {.compatible ="arm,coresight-static-funnel" }, {} }; +MODULE_DEVICE_TABLE (of, static_funnel_match); +#ifdef CONFIG_ACPI static const struct acpi_device_id static_funnel_ids[] = { {"ARMHC9FE" ,0 }, {}, }; +MODULE_DEVICE_TABLE (acpi, static_funnel_ids);#endif static struct platform_driver static_funnel_driver = { .probe = static_funnel_probe, + .probe = static_funnel_remove, .driver = { .name ="coresight-static-funnel" , .of_match_table = static_funnel_match,
@@ -348,6 +368,11 @@ static int dynamic_funnel_probe(struct amba_device *adev,return funnel_probe (&adev->dev, &adev->res); } +static int __exit dynamic_funnel_remove(struct amba_device *adev) +{ +return funnel_remove (&adev->dev); +} +static const struct amba_id dynamic_funnel_ids[] = { { .id =0x000bb908 ,
@@ -361,6 +386,8 @@ static const struct amba_id dynamic_funnel_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, dynamic_funnel_ids); + static struct amba_driver dynamic_funnel_driver = { .drv = { .name = "coresight-dynamic-funnel",
@@ -369,6 +396,7 @@ static struct amba_driver dynamic_funnel_driver = { .suppress_bind_attrs = true, }, .probe = dynamic_funnel_probe, + .remove = dynamic_funnel_remove, .id_table = dynamic_funnel_ids, };
@@ -399,3 +427,7 @@ static void __exit funnel_exit(void)module_init (funnel_init);module_exit (funnel_exit); + +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Funnel Driver" ); +MODULE_LICENSE ("GPL v2" );
drivers/hwtracing/coresight/coresight-replicator.c +33 -0
@@ -270,6 +270,14 @@ static int replicator_probe(struct device *dev, struct resource *res)return ret; } +static int __exit replicator_remove(struct device *dev) +{ +struct replicator_drvdata *drvdata =dev_get_drvdata (dev); + +coresight_unregister (drvdata->csdev); +return 0 ; +} +static int static_replicator_probe (struct platform_device *pdev) {int ret;
@@ -289,6 +297,13 @@ static int static_replicator_probe(struct platform_device *pdev)return ret; } +static int __exit static_replicator_remove(struct platform_device *pdev) +{ +replicator_remove (&pdev->dev); +pm_runtime_disable (&pdev->dev); +return 0 ; +} +#ifdef CONFIG_PM static int replicator_runtime_suspend (struct device *dev) {
@@ -321,18 +336,22 @@ static const struct of_device_id static_replicator_match[] = { {.compatible = "arm,coresight-static-replicator"}, {} }; +MODULE_DEVICE_TABLE (of, static_replicator_match);#ifdef CONFIG_ACPI static const struct acpi_device_id static_replicator_acpi_ids[] = { {"ARMHC985" ,0 },/* ARM CoreSight Static Replicator */ {} }; +MODULE_DEVICE_TABLE (acpi, static_replicator_acpi_ids);#endif static struct platform_driver static_replicator_driver = { .probe = static_replicator_probe, + .remove = static_replicator_remove, .driver = { .name ="coresight-static-replicator" , + .owner =THIS_MODULE , .of_match_table =of_match_ptr (static_replicator_match), .acpi_match_table =ACPI_PTR (static_replicator_acpi_ids), .pm = &replicator_dev_pm_ops,
@@ -346,6 +365,11 @@ static int dynamic_replicator_probe(struct amba_device *adev,return replicator_probe (&adev->dev, &adev->res); } +static int __exit dynamic_replicator_remove(struct amba_device *adev) +{ +return replicator_remove (&adev->dev); +} +static const struct amba_id dynamic_replicator_ids[] = { { .id =0x000bb909 ,
@@ -359,13 +383,17 @@ static const struct amba_id dynamic_replicator_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE (amba, dynamic_replicator_ids); +static struct amba_driver dynamic_replicator_driver = { .drv = { .name ="coresight-dynamic-replicator" , .pm = &replicator_dev_pm_ops, + .owner =THIS_MODULE , .suppress_bind_attrs = true, }, .probe = dynamic_replicator_probe, + .remove = dynamic_replicator_remove, .id_table = dynamic_replicator_ids, };
@@ -396,3 +424,8 @@ static void __exit replicator_exit(void)module_init (replicator_init);module_exit (replicator_exit); + +MODULE_AUTHOR ("Pratik Patel <[email protected]>" ); +MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Replicator Driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 15/20 coresight: cti: add function to register cti associate ops
In reply to Tingwei ZhangAdd static cti_assoc_ops to coresight core driver. Let cti driver register the add_assoc and remove_assoc call back. Avoid coresight core driver to depend on cti driver.
--- drivers/hwtracing/coresight/coresight-cti.c | 32 ++++++++++++++++++-- drivers/hwtracing/coresight/coresight-priv.h | 14 ++++----- drivers/hwtracing/coresight/coresight.c | 21 +++++++++++-- 3 files changed, 53 insertions(+), 14 deletions(-)
drivers/hwtracing/coresight/coresight-cti.c +29 -3
@@ -589,7 +589,6 @@ void cti_add_assoc_to_csdev(struct coresight_device *csdev) cti_add_done:mutex_unlock (&ect_mutex); } -EXPORT_SYMBOL_GPL (cti_add_assoc_to_csdev);/* * Removing the associated devices is easier.
@@ -616,7 +615,15 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev) }mutex_unlock (&ect_mutex); } -EXPORT_SYMBOL_GPL (cti_remove_assoc_from_csdev); + +/* +* Operations to add and remove associated CTI. +* Register to coresight core driver as call back function. +*/ +static struct cti_assoc_op cti_assoc_ops = { + .add = cti_add_assoc_to_csdev, + .remove = cti_remove_assoc_from_csdev +};/* * Update the cross references where the associated device was found
@@ -960,4 +967,23 @@ static struct amba_driver cti_driver = { .probe = cti_probe, .id_table = cti_ids, }; -builtin_amba_driver (cti_driver); + +static int __init cti_init (void ) +{ +int ret; + + ret =amba_driver_register (&cti_driver); +if (ret) +pr_info ("Error registering cti driver\n" ); +coresight_set_cti_ops (&cti_assoc_ops); +return ret; +} + +static void __exit cti_exit(void) +{ +coresight_remove_cti_ops (); +amba_driver_unregister (&cti_driver); +} + +module_init (cti_init); +module_exit (cti_exit);
drivers/hwtracing/coresight/coresight-priv.h +6 -8
@@ -171,15 +171,13 @@ static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }static inline int etm_writel_cp14 (u32 off,u32 val) {return 0 ; }#endif -#ifdef CONFIG_CORESIGHT_CTI -extern void cti_add_assoc_to_csdev (struct coresight_device *csdev); -extern void cti_remove_assoc_from_csdev (struct coresight_device *csdev); +struct cti_assoc_op { +void (*add)(struct coresight_device *csdev); +void (*remove)(struct coresight_device *csdev); +}; -#else -static inline void cti_add_assoc_to_csdev (struct coresight_device *csdev) {} -static inline void -cti_remove_assoc_from_csdev (struct coresight_device *csdev) {} -#endif +extern void coresight_set_cti_ops (const struct cti_assoc_op *cti_op); +extern void coresight_remove_cti_ops (void );/* * Macros and inline functions to handle CoreSight UCI data and driver
drivers/hwtracing/coresight/coresight.c +18 -3
@@ -57,6 +57,20 @@ const u32 coresight_barrier_pkt[4] = { 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};EXPORT_SYMBOL_GPL (coresight_barrier_pkt); +static const struct cti_assoc_op *cti_assoc_ops; + +void coresight_set_cti_ops (const struct cti_assoc_op *cti_op) +{ + cti_assoc_ops = cti_op; +} +EXPORT_SYMBOL_GPL (coresight_set_cti_ops); + +void coresight_remove_cti_ops (void ) +{ + cti_assoc_ops =NULL ; +} +EXPORT_SYMBOL_GPL (coresight_remove_cti_ops); +static int coresight_id_match (struct device *dev,void *data) {int trace_id, i_trace_id;
@@ -1030,7 +1044,8 @@ static void coresight_device_release(struct device *dev) {struct coresight_device *csdev =to_coresight_device (dev); -cti_remove_assoc_from_csdev (csdev); +if (cti_assoc_ops && cti_assoc_ops->remove) + cti_assoc_ops->remove (csdev);fwnode_handle_put (csdev->dev.fwnode);kfree (csdev->refcnt);kfree (csdev);
@@ -1341,8 +1356,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) ret =coresight_fixup_device_conns (csdev);if (!ret) ret =coresight_fixup_orphan_conns (csdev); -if (!ret) -cti_add_assoc_to_csdev (csdev); +if (!ret && cti_assoc_ops && cti_assoc_ops->add) + cti_assoc_ops->add (csdev);mutex_unlock (&coresight_mutex);if (ret) {
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 16/20 coresight: allow cti to be built as a module
In reply to Tingwei ZhangAllow to build coresight-cti as a module, for ease of development.
- Kconfig becomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-cti by the Makefile
- add an cti_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
---
drivers/hwtracing/coresight/Kconfig | 5 ++++-
drivers/hwtracing/coresight/Makefile | 4 ++--
.../{coresight-cti.c => coresight-cti-core.c} | 14 ++++++++++++++
drivers/hwtracing/coresight/coresight-platform.c | 1 +
drivers/hwtracing/coresight/coresight.c | 1 +
5 files changed, 22 insertions(+), 3 deletions(-)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4 -1
@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG module will be called coresight-cpu-debug. config CORESIGHT_CTI - bool "CoreSight Cross Trigger Interface (CTI) driver" + tristate "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64 help This driver provides support for CoreSight CTI and CTM components.
@@ -147,6 +147,9 @@ config CORESIGHT_CTI halt compared to disabling sources and sinks normally in driver software. + To compile this driver as a module, choose M here: the + module will be called coresight-cti. + config CORESIGHT_CTI_INTEGRATION_REGS bool "Access CTI CoreSight Integration Registers" depends on CORESIGHT_CTI
drivers/hwtracing/coresight/Makefile +2 -2
@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o -obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \ - coresight-cti-platform.o \ +obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o +coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \ coresight-cti-sysfs.o
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +14 -0
@@ -817,6 +817,14 @@ static void cti_device_release(struct device *dev)if (drvdata->csdev_release) drvdata->csdev_release (dev); } +static int __exit cti_remove(struct amba_device *adev) +{ +struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +}static int cti_probe (struct amba_device *adev,const struct amba_id *id) {
@@ -957,6 +965,7 @@ static const struct amba_id cti_ids[] = {CS_AMBA_UCI_ID (0x000bb9ed , uci_id_cti),/* Coresight CTI (SoC 600) */ { 0, 0}, }; +MODULE_DEVICE_TABLE (amba, cti_ids);static struct amba_driver cti_driver = { .drv = {
@@ -965,6 +974,7 @@ static struct amba_driver cti_driver = { .suppress_bind_attrs = true, }, .probe = cti_probe, + .remove = cti_remove, .id_table = cti_ids, };
@@ -987,3 +997,7 @@ static void __exit cti_exit(void)module_init (cti_init);module_exit (cti_exit); + +MODULE_AUTHOR ("Mike Leach <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight CTI Driver" ); +MODULE_LICENSE ("GPL v2" );
drivers/hwtracing/coresight/coresight-platform.c +1 -0
@@ -76,6 +76,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode) }return csdev; } +EXPORT_SYMBOL_GPL (coresight_find_csdev_by_fwnode);#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input (struct device_node *ep)
drivers/hwtracing/coresight/coresight.c +1 -0
@@ -273,6 +273,7 @@ void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, csdev->ect_dev = ect_csdev;mutex_unlock (&coresight_mutex); } +EXPORT_SYMBOL_GPL (coresight_set_assoc_ectdev_mutex);static int coresight_enable_sink (struct coresight_device *csdev,u32 mode,void *data)
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 16/20] coresight: allow cti to be built as a module
Hi,
Once again testing on DB410c.
The following sequence:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.ko
results in:-
This in my command console:-
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Segmentation fault
root@linaro-developer:/home/linaro/cs-mods#
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260)
AND this in the boot console:-
root@linaro-developer:~# [ 188.804340] Unable to handle kernel paging request at virtual address 97e3327491382070 [ 188.804370] Mem abort info: [ 188.811217] ESR = 0x96000004 [ 188.813832] EC = 0x25: DABT (current EL), IL = 32 bits [ 188.817009] SET = 0, FnV = 0 [ 188.822448] EA = 0, S1PTW = 0 [ 188.825284] Data abort info: [ 188.828346] ISV = 0, ISS = 0x00000004 [ 188.831471] CM = 0, WnR = 0 [ 188.835029] [97e3327491382070] address between user and kernel address ranges [ 188.838141] Internal error: Oops: 96000004 [#1] SMP [ 188.845252] Modules linked in: coresight_cti(-) coresight_etm4x coresight [ 188.849947] CPU: 2 PID: 4233 Comm: rmmod Not tainted 5.8.0-rc5cs-modscs-mods-00021-gcac254d1f7cc-dirty #284 [ 188.856890] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 188.866439] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--) [ 188.873387] pc : kernfs_find_ns+0x28/0x120 [ 188.878673] lr : kernfs_find_and_get_ns+0x44/0x68 [ 188.882838] sp : ffff000034e77b00 [ 188.887611] x29: ffff000034e77b00 x28: ffff000034d50d80 [ 188.890912] x27: 0000000000000000 x26: 0000000000000000 [ 188.896294] x25: 0000000000000000 x24: ffff0000382aa898 [ 188.901589] x23: ffff800008d84938 x22: 0000000000000000 [ 188.906883] x21: ffff800008d84938 x20: 97e3327491382000 [ 188.912179] x19: 97e3327491382000 x18: ffffffffffffffff [ 188.917473] x17: 0000000000000000 x16: 0000000000000000 [ 188.922770] x15: ffff800011609948 x14: 0000000000000040 [ 188.928064] x13: 0000000000000228 x12: 0000000000000008 [ 188.933360] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 188.938654] x9 : 0000001d9cd9e3a6 x8 : 0000b790773d66d4 [ 188.943950] x7 : 0000000000000002 x6 : ffff0000382a8ed4 [ 188.949244] x5 : 0000000000000000 x4 : ffff0000382a8ed4 [ 188.954540] x3 : 0000000000000000 x2 : 0000000000000000 [ 188.959836] x1 : ffff800008d84938 x0 : ffff8000103609fc [ 188.965131] Call trace: [ 188.970428] kernfs_find_ns+0x28/0x120 [ 188.972596] kernfs_find_and_get_ns+0x44/0x68 [ 188.976419] sysfs_remove_link_from_group+0x34/0x60 [ 188.980857] coresight_remove_sysfs_link+0x4c/0x88 [coresight] [ 188.985541] cti_device_release+0x7c/0x170 [coresight_cti] [ 188.991435] device_release+0x34/0x90 [ 188.996905] kobject_put+0x70/0x200 [ 189.000634] device_unregister+0x30/0x78 [ 189.003942] coresight_unregister+0x60/0x70 [coresight] [ 189.008107] cti_remove+0x14/0x20 [coresight_cti] [ 189.013050] amba_remove+0x34/0x1a0 [ 189.017910] device_release_driver_internal+0x100/0x1b8 [ 189.021210] driver_detach+0xa8/0x178 [ 189.026417] bus_remove_driver+0x64/0x100 [ 189.030237] driver_unregister+0x34/0x60 [ 189.034228] amba_driver_unregister+0x20/0x30 [ 189.038228] cti_exit+0x1c/0xd60 [coresight_cti] [ 189.042478] __arm64_sys_delete_module+0x1c0/0x280 [ 189.047167] el0_svc_common.constprop.3+0xc8/0x170 [ 189.051765] do_el0_svc+0x34/0xc0 [ 189.056538] el0_sync_handler+0x144/0x1c0 [ 189.059923] el0_sync+0x140/0x180 [ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260) [ 189.067218] ---[ end trace 05494e5d41cb7242 ]---
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260)
Looks to be in the code that maintains the sysfs connections between the devices. I haven't looked deeper than that.
Regards
Mike
Quoted 134 lines · Tingwei Zhang
Allow to build coresight-cti as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-cti by theMakefile
- add ancti_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootSigned-off-by Tingwei Zhang <[email protected]>--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/Makefile | 4 ++-- .../{coresight-cti.c => coresight-cti-core.c} | 14 ++++++++++++++ drivers/hwtracing/coresight/coresight-platform.c | 1 + drivers/hwtracing/coresight/coresight.c | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4
-1@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG module will be called coresight-cpu-debug. config CORESIGHT_CTI - bool "CoreSight Cross Trigger Interface (CTI) driver" + tristate "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64 help This driver provides support for CoreSight CTI and CTM components.@@ -147,6 +147,9 @@ config CORESIGHT_CTI halt compared to disabling sources and sinks normally in driver software. + To compile this driver as a module, choose M here: the + module will be called coresight-cti. + config CORESIGHT_CTI_INTEGRATION_REGS bool "Access CTI CoreSight Integration Registers" depends on CORESIGHT_CTIdrivers/hwtracing/coresight/Makefile +2
-2@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o -obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \ - coresight-cti-platform.o \ +obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o +coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \ coresight-cti-sysfs.odrivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +14
-0@@ -817,6 +817,14 @@ static void cti_device_release(struct device *dev)if (drvdata->csdev_release) drvdata->csdev_release (dev); } +static int __exit cti_remove(struct amba_device *adev) +{ +struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +}static int cti_probe (struct amba_device *adev,const struct amba_id *id) {@@ -957,6 +965,7 @@ static const struct amba_id cti_ids[] = {CS_AMBA_UCI_ID (0x000bb9ed , uci_id_cti),/* Coresight CTI (SoC 600) */ { 0, 0}, }; +MODULE_DEVICE_TABLE (amba, cti_ids);static struct amba_driver cti_driver = { .drv = {@@ -965,6 +974,7 @@ static struct amba_driver cti_driver = { .suppress_bind_attrs = true, }, .probe = cti_probe, + .remove = cti_remove, .id_table = cti_ids, };@@ -987,3 +997,7 @@ static void __exit cti_exit(void)module_init (cti_init);module_exit (cti_exit); + +MODULE_AUTHOR ("Mike Leach <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight CTI Driver" ); +MODULE_LICENSE ("GPL v2" );drivers/hwtracing/coresight/coresight-platform.c +1
-0@@ -76,6 +76,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode) }return csdev; } +EXPORT_SYMBOL_GPL (coresight_find_csdev_by_fwnode);#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input (struct device_node *ep)drivers/hwtracing/coresight/coresight.c +1
-1@@ -273,6 +273,7 @@ void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, csdev->ect_dev = ect_csdev;mutex_unlock (&coresight_mutex); } +EXPORT_SYMBOL_GPL (coresight_set_assoc_ectdev_mutex);static int coresight_enable_sink (struct coresight_device *csdev,u32 mode,void *data) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 8 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 16/20] coresight: allow cti to be built as a module
Hi,
I've further looked into this - there is a bug in the CTI driver cleanup that is unrelated to the module work. I will issue a patch to fix.
Regards
Mike
Quoted 241 lines · Mike Leach
Hi,
Once again testing on DB410c.
The following sequence:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.koresults in:-
This in my command console:-
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Segmentation fault
root@linaro-developer:/home/linaro/cs-mods#
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 189.063920] Code:aa0203f6aa0103f7aa1e03e0d503201f(7940e260)AND this in the boot console:-
root@linaro-developer:~# [ 188.804340] Unable to handle kernel paging request at virtual address 97e3327491382070 [ 188.804370] Mem abort info: [ 188.811217] ESR = 0x96000004 [ 188.813832] EC = 0x25: DABT (current EL), IL = 32 bits [ 188.817009] SET = 0, FnV = 0 [ 188.822448] EA = 0, S1PTW = 0 [ 188.825284] Data abort info: [ 188.828346] ISV = 0, ISS = 0x00000004 [ 188.831471] CM = 0, WnR = 0 [ 188.835029] [97e3327491382070] address between user and kernel address ranges [ 188.838141] Internal error: Oops: 96000004 [#1] SMP [ 188.845252] Modules linked in: coresight_cti(-) coresight_etm4x coresight [ 188.849947] CPU: 2 PID: 4233 Comm: rmmod Not tainted 5.8.0-rc5cs-modscs-mods-00021-gcac254d1f7cc-dirty #284 [ 188.856890] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 188.866439] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--) [ 188.873387] pc : kernfs_find_ns+0x28/0x120 [ 188.878673] lr : kernfs_find_and_get_ns+0x44/0x68 [ 188.882838] sp : ffff000034e77b00 [ 188.887611] x29: ffff000034e77b00 x28: ffff000034d50d80 [ 188.890912] x27: 0000000000000000 x26: 0000000000000000 [ 188.896294] x25: 0000000000000000 x24: ffff0000382aa898 [ 188.901589] x23: ffff800008d84938 x22: 0000000000000000 [ 188.906883] x21: ffff800008d84938 x20: 97e3327491382000 [ 188.912179] x19: 97e3327491382000 x18: ffffffffffffffff [ 188.917473] x17: 0000000000000000 x16: 0000000000000000 [ 188.922770] x15: ffff800011609948 x14: 0000000000000040 [ 188.928064] x13: 0000000000000228 x12: 0000000000000008 [ 188.933360] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 188.938654] x9 : 0000001d9cd9e3a6 x8 : 0000b790773d66d4 [ 188.943950] x7 : 0000000000000002 x6 : ffff0000382a8ed4 [ 188.949244] x5 : 0000000000000000 x4 : ffff0000382a8ed4 [ 188.954540] x3 : 0000000000000000 x2 : 0000000000000000 [ 188.959836] x1 : ffff800008d84938 x0 : ffff8000103609fc [ 188.965131] Call trace: [ 188.970428] kernfs_find_ns+0x28/0x120 [ 188.972596] kernfs_find_and_get_ns+0x44/0x68 [ 188.976419] sysfs_remove_link_from_group+0x34/0x60 [ 188.980857] coresight_remove_sysfs_link+0x4c/0x88 [coresight] [ 188.985541] cti_device_release+0x7c/0x170 [coresight_cti] [ 188.991435] device_release+0x34/0x90 [ 188.996905] kobject_put+0x70/0x200 [ 189.000634] device_unregister+0x30/0x78 [ 189.003942] coresight_unregister+0x60/0x70 [coresight] [ 189.008107] cti_remove+0x14/0x20 [coresight_cti] [ 189.013050] amba_remove+0x34/0x1a0 [ 189.017910] device_release_driver_internal+0x100/0x1b8 [ 189.021210] driver_detach+0xa8/0x178 [ 189.026417] bus_remove_driver+0x64/0x100 [ 189.030237] driver_unregister+0x34/0x60 [ 189.034228] amba_driver_unregister+0x20/0x30 [ 189.038228] cti_exit+0x1c/0xd60 [coresight_cti] [ 189.042478] __arm64_sys_delete_module+0x1c0/0x280 [ 189.047167] el0_svc_common.constprop.3+0xc8/0x170 [ 189.051765] do_el0_svc+0x34/0xc0 [ 189.056538] el0_sync_handler+0x144/0x1c0 [ 189.059923] el0_sync+0x140/0x180 [ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260) [ 189.067218] ---[ end trace 05494e5d41cb7242 ]---Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 189.063920] Code:
aa0203f6aa0103f7aa1e03e0d503201f(7940e260)Looks to be in the code that maintains the sysfs connections between the devices. I haven't looked deeper than that.
Regards
Mike
Quoted 130 lines · Tingwei Zhang
Allow to build coresight-cti as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-cti by theMakefile
- add ancti_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootSigned-off-by Tingwei Zhang <[email protected]>--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/Makefile | 4 ++-- .../{coresight-cti.c => coresight-cti-core.c} | 14 ++++++++++++++ drivers/hwtracing/coresight/coresight-platform.c | 1 + drivers/hwtracing/coresight/coresight.c | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4
-1@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG module will be called coresight-cpu-debug. config CORESIGHT_CTI - bool "CoreSight Cross Trigger Interface (CTI) driver" + tristate "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64 help This driver provides support for CoreSight CTI and CTM components.@@ -147,6 +147,9 @@ config CORESIGHT_CTI halt compared to disabling sources and sinks normally in driver software. + To compile this driver as a module, choose M here: the + module will be called coresight-cti. + config CORESIGHT_CTI_INTEGRATION_REGS bool "Access CTI CoreSight Integration Registers" depends on CORESIGHT_CTIdrivers/hwtracing/coresight/Makefile +2
-2@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o -obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \ - coresight-cti-platform.o \ +obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o +coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \ coresight-cti-sysfs.odrivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +14
-0@@ -817,6 +817,14 @@ static void cti_device_release(struct device *dev)if (drvdata->csdev_release) drvdata->csdev_release (dev); } +static int __exit cti_remove(struct amba_device *adev) +{ +struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +}static int cti_probe (struct amba_device *adev,const struct amba_id *id) {@@ -957,6 +965,7 @@ static const struct amba_id cti_ids[] = {CS_AMBA_UCI_ID (0x000bb9ed , uci_id_cti),/* Coresight CTI (SoC 600) */ { 0, 0}, }; +MODULE_DEVICE_TABLE (amba, cti_ids);static struct amba_driver cti_driver = { .drv = {@@ -965,6 +974,7 @@ static struct amba_driver cti_driver = { .suppress_bind_attrs = true, }, .probe = cti_probe, + .remove = cti_remove, .id_table = cti_ids, };@@ -987,3 +997,7 @@ static void __exit cti_exit(void)module_init (cti_init);module_exit (cti_exit); + +MODULE_AUTHOR ("Mike Leach <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight CTI Driver" ); +MODULE_LICENSE ("GPL v2" );drivers/hwtracing/coresight/coresight-platform.c +1
-0@@ -76,6 +76,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode) }return csdev; } +EXPORT_SYMBOL_GPL (coresight_find_csdev_by_fwnode);#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input (struct device_node *ep)drivers/hwtracing/coresight/coresight.c +1
-1@@ -273,6 +273,7 @@ void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, csdev->ect_dev = ect_csdev;mutex_unlock (&coresight_mutex); } +EXPORT_SYMBOL_GPL (coresight_set_assoc_ectdev_mutex);static int coresight_enable_sink (struct coresight_device *csdev,u32 mode,void *data) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Signature · 8 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 16/20] coresight: allow cti to be built as a module
Hi Tingwei,
Quoted 11 lines · Mike Leach
Hi,
I've further looked into this - there is a bug in the CTI driver cleanup that is unrelated to the module work. I will issue a patch to fix.
Regards
Mike
In addition to the patch I sent to the mailing list that fixes existing code in the CTI driver, the following alteration is needed to the module code to make it work:-
------------------------------
(quoted diff) +0 -0
b/drivers/hwtracing/coresight/coresight-cti-core.c index adc05e3f2e40..d1cbc35e2b68 100644
drivers/hwtracing/coresight/coresight-cti-core.c +4 -1
@@ -809,7 +809,6 @@ static void cti_device_release(struct device *dev)struct cti_drvdata *ect_item, *ect_tmp;mutex_lock (&ect_mutex); -cti_remove_conn_xrefs (drvdata);cti_pm_release (drvdata);/* remove from the list */
@@ -828,6 +827,10 @@ static int __exit cti_remove(struct amba_device *adev) {struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); +mutex_lock (&ect_mutex); +cti_remove_conn_xrefs (drvdata); +mutex_unlock (&ect_mutex); +coresight_unregister (drvdata->csdev);return 0 ;
----------------------------
Additional testing showed that once this was added then the cti module could be removed.
However, the following sequence failed.
1) Insert all modules needed for trace (testing cti can be removed:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-tmc.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-replicator.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-funnel.ko
2) run script to trace into etf
Tracing via sysfs
enabling etf
wait before enable etm
enabling etm 0.
enabling etm 1.
enabling etm 2.
enabling etm 3.
waiting for trace
disabling etm 0.
disabling etm 1.
disabling etm 2.
disabling etm 3.
disabling etf
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.00134308 s, 6.1 MB/s
3) remove CTI module - this should not make a difference to normal tracing as the script used does not program the CTIs.
rmmod ../cs-mods/coresight-cti.ko
4) re-run the script to trace:
Tracing via sysfs
enabling etf
wait before enable etm
enabling etm 0.
enabling etm 1.
enabling etm 2.
enabling etm 3.
waiting for trace
disabling etm 0.
disabling etm 1.
disabling etm 2.
disabling etm 3.
disabling etf
Killed
Here I had to kill the command console as the system had crashed and automatically restarted due to an internal error.
The only message in the boot console, before the restart was:-
[ 2089.183265] Internal error: synchronous external abort: 96000010 [#1] SMP
Format: Log Type - Time(microsec) - Message - Optional Info Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.0-00261
S - IMAGE_VARIANT_STRING=HAAAANAAA
S - OEM_IMAGE_VERSION_STRING=C-BPATTH
S - Boot Config, 0x000002e1
S - Core 0 Frequency, 0 MHz
----- reboot continues ----
This could be an issue that has been fixed by patches on coresight/next, or directly related to module load/unload.
As Mathieu has mentioned, the set needs to be rebased onto coresight/next. You will then need to test that trace is successful before and after removing the CTI module, before sending a new version.
Regards
Mike
Quoted 249 lines · Mike Leach
Quoted 230 lines
Hi,
Once again testing on DB410c.
The following sequence:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.koresults in:-
This in my command console:-
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Segmentation fault
root@linaro-developer:/home/linaro/cs-mods#
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 189.063920] Code:aa0203f6aa0103f7aa1e03e0d503201f(7940e260)AND this in the boot console:-
root@linaro-developer:~# [ 188.804340] Unable to handle kernel paging request at virtual address 97e3327491382070 [ 188.804370] Mem abort info: [ 188.811217] ESR = 0x96000004 [ 188.813832] EC = 0x25: DABT (current EL), IL = 32 bits [ 188.817009] SET = 0, FnV = 0 [ 188.822448] EA = 0, S1PTW = 0 [ 188.825284] Data abort info: [ 188.828346] ISV = 0, ISS = 0x00000004 [ 188.831471] CM = 0, WnR = 0 [ 188.835029] [97e3327491382070] address between user and kernel address ranges [ 188.838141] Internal error: Oops: 96000004 [#1] SMP [ 188.845252] Modules linked in: coresight_cti(-) coresight_etm4x coresight [ 188.849947] CPU: 2 PID: 4233 Comm: rmmod Not tainted 5.8.0-rc5cs-modscs-mods-00021-gcac254d1f7cc-dirty #284 [ 188.856890] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 188.866439] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--) [ 188.873387] pc : kernfs_find_ns+0x28/0x120 [ 188.878673] lr : kernfs_find_and_get_ns+0x44/0x68 [ 188.882838] sp : ffff000034e77b00 [ 188.887611] x29: ffff000034e77b00 x28: ffff000034d50d80 [ 188.890912] x27: 0000000000000000 x26: 0000000000000000 [ 188.896294] x25: 0000000000000000 x24: ffff0000382aa898 [ 188.901589] x23: ffff800008d84938 x22: 0000000000000000 [ 188.906883] x21: ffff800008d84938 x20: 97e3327491382000 [ 188.912179] x19: 97e3327491382000 x18: ffffffffffffffff [ 188.917473] x17: 0000000000000000 x16: 0000000000000000 [ 188.922770] x15: ffff800011609948 x14: 0000000000000040 [ 188.928064] x13: 0000000000000228 x12: 0000000000000008 [ 188.933360] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 188.938654] x9 : 0000001d9cd9e3a6 x8 : 0000b790773d66d4 [ 188.943950] x7 : 0000000000000002 x6 : ffff0000382a8ed4 [ 188.949244] x5 : 0000000000000000 x4 : ffff0000382a8ed4 [ 188.954540] x3 : 0000000000000000 x2 : 0000000000000000 [ 188.959836] x1 : ffff800008d84938 x0 : ffff8000103609fc [ 188.965131] Call trace: [ 188.970428] kernfs_find_ns+0x28/0x120 [ 188.972596] kernfs_find_and_get_ns+0x44/0x68 [ 188.976419] sysfs_remove_link_from_group+0x34/0x60 [ 188.980857] coresight_remove_sysfs_link+0x4c/0x88 [coresight] [ 188.985541] cti_device_release+0x7c/0x170 [coresight_cti] [ 188.991435] device_release+0x34/0x90 [ 188.996905] kobject_put+0x70/0x200 [ 189.000634] device_unregister+0x30/0x78 [ 189.003942] coresight_unregister+0x60/0x70 [coresight] [ 189.008107] cti_remove+0x14/0x20 [coresight_cti] [ 189.013050] amba_remove+0x34/0x1a0 [ 189.017910] device_release_driver_internal+0x100/0x1b8 [ 189.021210] driver_detach+0xa8/0x178 [ 189.026417] bus_remove_driver+0x64/0x100 [ 189.030237] driver_unregister+0x34/0x60 [ 189.034228] amba_driver_unregister+0x20/0x30 [ 189.038228] cti_exit+0x1c/0xd60 [coresight_cti] [ 189.042478] __arm64_sys_delete_module+0x1c0/0x280 [ 189.047167] el0_svc_common.constprop.3+0xc8/0x170 [ 189.051765] do_el0_svc+0x34/0xc0 [ 189.056538] el0_sync_handler+0x144/0x1c0 [ 189.059923] el0_sync+0x140/0x180 [ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260) [ 189.067218] ---[ end trace 05494e5d41cb7242 ]---Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 189.063920] Code:
aa0203f6aa0103f7aa1e03e0d503201f(7940e260)Looks to be in the code that maintains the sysfs connections between the devices. I haven't looked deeper than that.
Regards
Mike
Quoted 130 lines · Tingwei Zhang
Allow to build coresight-cti as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-cti by theMakefile
- add ancti_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootSigned-off-by Tingwei Zhang <[email protected]>--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/Makefile | 4 ++-- .../{coresight-cti.c => coresight-cti-core.c} | 14 ++++++++++++++ drivers/hwtracing/coresight/coresight-platform.c | 1 + drivers/hwtracing/coresight/coresight.c | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4
-1@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG module will be called coresight-cpu-debug. config CORESIGHT_CTI - bool "CoreSight Cross Trigger Interface (CTI) driver" + tristate "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64 help This driver provides support for CoreSight CTI and CTM components.@@ -147,6 +147,9 @@ config CORESIGHT_CTI halt compared to disabling sources and sinks normally in driver software. + To compile this driver as a module, choose M here: the + module will be called coresight-cti. + config CORESIGHT_CTI_INTEGRATION_REGS bool "Access CTI CoreSight Integration Registers" depends on CORESIGHT_CTIdrivers/hwtracing/coresight/Makefile +2
-2@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o -obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \ - coresight-cti-platform.o \ +obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o +coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \ coresight-cti-sysfs.odrivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +14
-0@@ -817,6 +817,14 @@ static void cti_device_release(struct device *dev)if (drvdata->csdev_release) drvdata->csdev_release (dev); } +static int __exit cti_remove(struct amba_device *adev) +{ +struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +}static int cti_probe (struct amba_device *adev,const struct amba_id *id) {@@ -957,6 +965,7 @@ static const struct amba_id cti_ids[] = {CS_AMBA_UCI_ID (0x000bb9ed , uci_id_cti),/* Coresight CTI (SoC 600) */ { 0, 0}, }; +MODULE_DEVICE_TABLE (amba, cti_ids);static struct amba_driver cti_driver = { .drv = {@@ -965,6 +974,7 @@ static struct amba_driver cti_driver = { .suppress_bind_attrs = true, }, .probe = cti_probe, + .remove = cti_remove, .id_table = cti_ids, };@@ -987,3 +997,7 @@ static void __exit cti_exit(void)module_init (cti_init);module_exit (cti_exit); + +MODULE_AUTHOR ("Mike Leach <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight CTI Driver" ); +MODULE_LICENSE ("GPL v2" );drivers/hwtracing/coresight/coresight-platform.c +1
-0@@ -76,6 +76,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode) }return csdev; } +EXPORT_SYMBOL_GPL (coresight_find_csdev_by_fwnode);#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input (struct device_node *ep)drivers/hwtracing/coresight/coresight.c +1
-1@@ -273,6 +273,7 @@ void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, csdev->ect_dev = ect_csdev;mutex_unlock (&coresight_mutex); } +EXPORT_SYMBOL_GPL (coresight_set_assoc_ectdev_mutex);static int coresight_enable_sink (struct coresight_device *csdev,u32 mode,void *data) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 11 lines
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Signature · 8 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 16/20] coresight: allow cti to be built as a module
Hi Mike,
Thanks for your verification and fix on this. I've tested tracing in one thread and keep rmmod/insmod in another thread. I'll make sure to test trace after remove cti after rebase on coresight-next.
Quoted 379 lines · Mike Leach
Hi Tingwei,
Quoted 11 lines · Mike Leach
Hi,
I've further looked into this - there is a bug in the CTI driver cleanup that is unrelated to the module work. I will issue a patch to fix.
Regards
Mike
In addition to the patch I sent to the mailing list that fixes existing code in the CTI driver, the following alteration is needed to the module code to make it work:-
------------------------------drivers/hwtracing/coresight/coresight-cti-core.c +4
-1@@ -809,7 +809,6 @@ static void cti_device_release(struct device *dev)struct cti_drvdata *ect_item, *ect_tmp;mutex_lock (&ect_mutex); -cti_remove_conn_xrefs (drvdata);cti_pm_release (drvdata);/* remove from the list */ @@ -828,6 +827,10 @@ static int __exit cti_remove(struct amba_device *adev) {struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); +mutex_lock (&ect_mutex); +cti_remove_conn_xrefs (drvdata); +mutex_unlock (&ect_mutex); +coresight_unregister (drvdata->csdev);return 0;----------------------------
Additional testing showed that once this was added then the cti module could be removed.
However, the following sequence failed.
1) Insert all modules needed for trace (testing cti can be removed:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-tmc.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-replicator.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-funnel.ko2) run script to trace into etf
Tracing via sysfs
enabling etf
wait before enable etm
enabling etm 0.
enabling etm 1.
enabling etm 2.
enabling etm 3.
waiting for trace
disabling etm 0.
disabling etm 1.
disabling etm 2.
disabling etm 3.
disabling etf
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.00134308 s, 6.1 MB/s3) remove CTI module - this should not make a difference to normal tracing as the script used does not program the CTIs.
rmmod
../cs-mods/coresight-cti.ko4) re-run the script to trace:
Tracing via sysfs
enabling etf
wait before enable etm
enabling etm 0.
enabling etm 1.
enabling etm 2.
enabling etm 3.
waiting for trace
disabling etm 0.
disabling etm 1.
disabling etm 2.
disabling etm 3.
disabling etf
KilledHere I had to kill the command console as the system had crashed and automatically restarted due to an internal error.
The only message in the boot console, before the restart was:-
[ 2089.183265] Internal error: synchronous external abort: 96000010 [#1]SMP
Format: Log Type - Time(microsec) - Message - Optional Info Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.0-00261
S - IMAGE_VARIANT_STRING=HAAAANAAA
S - OEM_IMAGE_VERSION_STRING=C-BPATTH
S - Boot Config,0x000002e1
S - Core 0 Frequency, 0 MHz
----- reboot continues ----This could be an issue that has been fixed by patches on coresight/next, or directly related to module load/unload.
As Mathieu has mentioned, the set needs to be rebased onto coresight/next. You will then need to test that trace is successful before and after removing the CTI module, before sending a new version.
Regards
Mike
Quoted 15 lines · Mike Leach
Quoted 14 lines
Hi,
Once again testing on DB410c.
The following sequence:-
root@linaro-developer:/home/linaro/cs-mods# insmod coresight.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-etm4x.ko root@linaro-developer:/home/linaro/cs-mods# insmod coresight-cti.ko root@linaro-developer:/home/linaro/cs-mods# rmmod coresight-cti.koresults in:-
Quoted 8 lines
Quoted 8 lines
This in my command console:-
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Segmentation fault root@linaro-developer:/home/linaro/cs-mods#
Message from syslogd@linaro-developer at Jul 20 16:51:40 ...
kernel:[ 189.063920] Code:aa0203f6aa0103f7aa1e03e0d503201f(
7940e260)Quoted 14 lines
Quoted 14 lines
AND this in the boot console:-
root@linaro-developer:~# [ 188.804340] Unable to handle kernel paging request at virtual address 97e3327491382070 [ 188.804370] Mem abort info: [ 188.811217] ESR = 0x96000004 [ 188.813832] EC = 0x25: DABT (current EL), IL = 32 bits [ 188.817009] SET = 0, FnV = 0 [ 188.822448] EA = 0, S1PTW = 0 [ 188.825284] Data abort info: [ 188.828346] ISV = 0, ISS = 0x00000004 [ 188.831471] CM = 0, WnR = 0 [ 188.835029] [97e3327491382070] address between user and kerneladdress ranges
Quoted 2 lines
Quoted 2 lines
[ 188.838141] Internal error: Oops: 96000004 [#1] SMP [ 188.845252] Modules linked in: coresight_cti(-) coresight_etm4xcoresight
Quoted 3 lines
Quoted 3 lines
[ 188.849947] CPU: 2 PID: 4233 Comm: rmmod Not tainted 5.8.0-rc5cs-modscs-mods-00021-gcac254d1f7cc-dirty #284 [ 188.856890] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC(DT)
Quoted 45 lines
Quoted 45 lines
[ 188.866439] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--) [ 188.873387] pc : kernfs_find_ns+0x28/0x120 [ 188.878673] lr : kernfs_find_and_get_ns+0x44/0x68 [ 188.882838] sp : ffff000034e77b00 [ 188.887611] x29: ffff000034e77b00 x28: ffff000034d50d80 [ 188.890912] x27: 0000000000000000 x26: 0000000000000000 [ 188.896294] x25: 0000000000000000 x24: ffff0000382aa898 [ 188.901589] x23: ffff800008d84938 x22: 0000000000000000 [ 188.906883] x21: ffff800008d84938 x20: 97e3327491382000 [ 188.912179] x19: 97e3327491382000 x18: ffffffffffffffff [ 188.917473] x17: 0000000000000000 x16: 0000000000000000 [ 188.922770] x15: ffff800011609948 x14: 0000000000000040 [ 188.928064] x13: 0000000000000228 x12: 0000000000000008 [ 188.933360] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 188.938654] x9 : 0000001d9cd9e3a6 x8 : 0000b790773d66d4 [ 188.943950] x7 : 0000000000000002 x6 : ffff0000382a8ed4 [ 188.949244] x5 : 0000000000000000 x4 : ffff0000382a8ed4 [ 188.954540] x3 : 0000000000000000 x2 : 0000000000000000 [ 188.959836] x1 : ffff800008d84938 x0 : ffff8000103609fc [ 188.965131] Call trace: [ 188.970428] kernfs_find_ns+0x28/0x120 [ 188.972596] kernfs_find_and_get_ns+0x44/0x68 [ 188.976419] sysfs_remove_link_from_group+0x34/0x60 [ 188.980857] coresight_remove_sysfs_link+0x4c/0x88 [coresight] [ 188.985541] cti_device_release+0x7c/0x170 [coresight_cti] [ 188.991435] device_release+0x34/0x90 [ 188.996905] kobject_put+0x70/0x200 [ 189.000634] device_unregister+0x30/0x78 [ 189.003942] coresight_unregister+0x60/0x70 [coresight] [ 189.008107] cti_remove+0x14/0x20 [coresight_cti] [ 189.013050] amba_remove+0x34/0x1a0 [ 189.017910] device_release_driver_internal+0x100/0x1b8 [ 189.021210] driver_detach+0xa8/0x178 [ 189.026417] bus_remove_driver+0x64/0x100 [ 189.030237] driver_unregister+0x34/0x60 [ 189.034228] amba_driver_unregister+0x20/0x30 [ 189.038228] cti_exit+0x1c/0xd60 [coresight_cti] [ 189.042478] __arm64_sys_delete_module+0x1c0/0x280 [ 189.047167] el0_svc_common.constprop.3+0xc8/0x170 [ 189.051765] do_el0_svc+0x34/0xc0 [ 189.056538] el0_sync_handler+0x144/0x1c0 [ 189.059923] el0_sync+0x140/0x180 [ 189.063920] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260) [ 189.067218] ---[ end trace 05494e5d41cb7242 ]---Quoted 5 lines
Quoted 5 lines
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 188.838141] Internal error: Oops: 96000004 [#1] SMP
Message from syslogd@linaro-developer at Jul 20 16:51:40 ... kernel:[ 189.063920] Code:
aa0203f6aa0103f7aa1e03e0d503201f(
7940e260)Quoted 9 lines
Quoted 9 lines
Looks to be in the code that maintains the sysfs connections between the devices. I haven't looked deeper than that.
Regards
Mike
On Fri, 17 Jul 2020 at 06:49, Tingwei Zhang <[email protected]>
Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 9 lines
Allow to build coresight-cti as a module, for ease of development.
-
Kconfigbecomes a tristate, to allow =m
- append -core to source file name to allow module to be called coresight-cti by theMakefile
- add ancti_removefunction, for module unload
- add aMODULE_DEVICE_TABLEfor autoloading on bootQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Signed-off-by Tingwei Zhang <[email protected]>--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/Makefile | 4 ++-- .../{coresight-cti.c => coresight-cti-core.c} | 14++++++++++++++
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-platform.c | 1 + drivers/hwtracing/coresight/coresight.c | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) rename drivers/hwtracing/coresight/{coresight-cti.c =>
coresight-cti-core.c} (98%)Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/hwtracing/coresight/Kconfig
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
index
f31778dd0b5d..b04aae2ceecc100644drivers/hwtracing/coresight/Kconfig +0
-0@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG module will be called coresight-cpu-debug.Quoted 6 lines
Quoted 6 lines
drivers/hwtracing/coresight/Kconfig config CORESIGHT_CPU_DEBUG · line 142
Quoted 6 lines
drivers/hwtracing/coresight/Kconfig +1
-1config CORESIGHT_CTI - bool "CoreSight Cross Trigger Interface (CTI) driver" + tristate "CoreSight Cross Trigger Interface (CTI) driver" depends on ARM || ARM64 help This driver provides support for CoreSight CTI and CTMcomponents.
Quoted 2 lines
Quoted 2 lines
drivers/hwtracing/coresight/Kconfig config CORESIGHT_CTI · line 147
Quoted 2 lines
drivers/hwtracing/coresight/Kconfig +0
-0@@ -147,6 +147,9 @@ config CORESIGHT_CTI halt compared to disabling sources and sinks normally indriver
Quoted 9 lines
Quoted 9 lines
Review
Quoted 9 lines
drivers/hwtracing/coresight/Kconfig +3
-0software. + To compile this driver as a module, choose M here: the + module will be called coresight-cti. + config CORESIGHT_CTI_INTEGRATION_REGS bool "Access CTI CoreSight Integration Registers" depends on CORESIGHT_CTI(quoted diff) +0
-0b/drivers/hwtracing/coresight/Makefile
Quoted 4 lines
Quoted 4 lines
drivers/hwtracing/coresight/Makefile coresight-etm4x-y := coresight-etm4x-core.o
Quoted 4 lines
index
f2a568b969c4..0359d5a1588f100644drivers/hwtracing/coresight/Makefile +0
-0@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.ocoresight-etm4x-sysfs.o
Quoted 7 lines
Quoted 7 lines
drivers/hwtracing/coresight/Makefile coresight-etm4x-y := coresight-etm4x-core.o · line 23
Quoted 7 lines
drivers/hwtracing/coresight/Makefile +2
-2obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o -obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \ - coresight-cti-platform.o \ +obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o +coresight-cti-y := coresight-cti-core.ocoresight-cti-platform.o \
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
drivers/hwtracing/coresight/Makefile +0
-0coresight-cti-sysfs.o(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-cti-core.cQuoted 7 lines
Quoted 7 lines
drivers/hwtracing/coresight/coresight-cti-core.c static void cti_device_release(struct device
Quoted 7 lines
similarity index 98%
rename fromdrivers/hwtracing/coresight/coresight-cti.crename todrivers/hwtracing/coresight/coresight-cti-core.cindex289b356a64a5..0f8fbe41363a100644drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +0
-0@@ -817,6 +817,14 @@ static void cti_device_release(struct device*dev)
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +8
-0if (drvdata->csdev_release) drvdata->csdev_release (dev); } +static int __exit cti_remove(struct amba_device *adev) +{ +struct cti_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); + +return 0 ; +}Quoted 1 line
Quoted 1 line
drivers/hwtracing/coresight/coresight-cti-core.c static void cti_device_release(struct device · line 829
Quoted 1 line
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +0
-0static int cti_probe(struct amba_device *adev, const struct amba_id*id)
Quoted 3 lines
Quoted 3 lines
drivers/hwtracing/coresight/coresight-cti-core.c static const struct amba_id cti_ids[] = { · line 965
Quoted 3 lines
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +0
-0{@@ -957,6 +965,7 @@ static const struct amba_id cti_ids[] = { CS_AMBA_UCI_ID(0x000bb9ed, uci_id_cti), /* Coresight CTI(SoC 600) */
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +2
-0{ 0, 0}, }; +MODULE_DEVICE_TABLE(amba, cti_ids); static struct amba_driver cti_driver = { .drv = {@@ -965,6 +974,7 @@ static struct amba_driver cti_driver = { .suppress_bind_attrs = true, }, .probe = cti_probe, + .remove = cti_remove, .id_table = cti_ids, };@@ -987,3 +997,7 @@ static void __exit cti_exit(void)Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
drivers/hwtracing/coresight/coresight-cti-core.c renamed from drivers/hwtracing/coresight/coresight-cti.c +4
-0module_init (cti_init);module_exit (cti_exit); + +MODULE_AUTHOR ("Mike Leach <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight CTI Driver" ); +MODULE_LICENSE ("GPL v2" );(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight-platform.cQuoted 4 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-platform.c coresight_find_csdev_by_fwnode(struct
Quoted 4 lines
index
e4912abda3aa..70477a256be3100644drivers/hwtracing/coresight/coresight-platform.c +0
-0@@ -76,6 +76,7 @@ coresight_find_csdev_by_fwnode(struct
fwnode_handle*r_fwnode)Quoted 7 lines
Quoted 7 lines
drivers/hwtracing/coresight/coresight-platform.c coresight_find_csdev_by_fwnode(struct · line 82
Quoted 7 lines
drivers/hwtracing/coresight/coresight-platform.c +1
-0}return csdev; } +EXPORT_SYMBOL_GPL (coresight_find_csdev_by_fwnode);#ifdef CONFIG_OF static inline bool of_coresight_legacy_ep_is_input(struct
device_node*ep)Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/hwtracing/coresight/coresight.cQuoted 4 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight.c void coresight_set_assoc_ectdev_mutex(struct
Quoted 4 lines
index
b814ca54acc9..55b699aca9ec100644drivers/hwtracing/coresight/coresight.c +0
-0@@ -273,6 +273,7 @@ void coresight_set_assoc_ectdev_mutex(struct
coresight_device*csdev,Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/hwtracing/coresight/coresight.c +1
-0csdev->ect_dev = ect_csdev;mutex_unlock (&coresight_mutex); } +EXPORT_SYMBOL_GPL (coresight_set_assoc_ectdev_mutex);
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight.c +0
-1static int coresight_enable_sink (struct coresight_device *csdev,u32 mode,void *data) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 21 lines
Quoted 10 lines
Quoted 7 lines
a Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernelQuoted 4 lines
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 17/20 coresight: tmc-etr: add function to register catu ops
In reply to Tingwei ZhangFrom: Mian Yousaf Kaukab <[email protected]>
Make etr_catu_buf_ops static. Instead of directly accessing it in etr_buf_ops[], add a function to let catu driver register the ops at runtime. Break circular dependency between tmc-etr and catu drivers.
--- drivers/hwtracing/coresight/coresight-catu.c | 22 +++++++++++++++++-- drivers/hwtracing/coresight/coresight-catu.h | 2 -- .../hwtracing/coresight/coresight-tmc-etr.c | 15 +++++++++++-- drivers/hwtracing/coresight/coresight-tmc.h | 3 +++ 4 files changed, 36 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-catu.c +20 -2
@@ -358,7 +358,7 @@ static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata,return 0 ; } -const struct etr_buf_operations etr_catu_buf_ops = { +static const struct etr_buf_operations etr_catu_buf_ops = { .alloc = catu_alloc_etr_buf, .free = catu_free_etr_buf, .sync = catu_sync_etr_buf,
@@ -585,4 +585,22 @@ static struct amba_driver catu_driver = { .id_table = catu_ids, }; -builtin_amba_driver (catu_driver); +static int __init catu_init (void ) +{ +int ret; + + ret =amba_driver_register (&catu_driver); +if (ret) +pr_info ("Error registering catu driver\n" ); +tmc_etr_set_catu_ops (&etr_catu_buf_ops); +return ret; +} + +static void __exit catu_exit(void) +{ +tmc_etr_remove_catu_ops (); +amba_driver_unregister (&catu_driver); +} + +module_init (catu_init); +module_exit (catu_exit);
drivers/hwtracing/coresight/coresight-catu.h +0 -2
@@ -108,6 +108,4 @@ static inline bool coresight_is_catu_device(struct coresight_device *csdev) return true; } -extern const struct etr_buf_operations etr_catu_buf_ops; -#endif
drivers/hwtracing/coresight/coresight-tmc-etr.c +13 -2
@@ -794,10 +794,21 @@ static inline void tmc_etr_disable_catu(struct tmc_drvdata *drvdata)static const struct etr_buf_operations *etr_buf_ops[] = { [ETR_MODE_FLAT ] = &etr_flat_buf_ops, [ETR_MODE_ETR_SG ] = &etr_sg_buf_ops, - [ETR_MODE_CATU ] =IS_ENABLED (CONFIG_CORESIGHT_CATU ) - ? &etr_catu_buf_ops :NULL , + [ETR_MODE_CATU ] =NULL , }; +void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu) +{ + etr_buf_ops[ETR_MODE_CATU ] = catu; +} +EXPORT_SYMBOL_GPL (tmc_etr_set_catu_ops); + +void tmc_etr_remove_catu_ops (void ) +{ + etr_buf_ops[ETR_MODE_CATU ] =NULL ; +} +EXPORT_SYMBOL_GPL (tmc_etr_remove_catu_ops); + static inline int tmc_etr_mode_alloc_buf(int mode, struct tmc_drvdata *drvdata, struct etr_buf *etr_buf, int node,
drivers/hwtracing/coresight/coresight-tmc.h +3 -0
@@ -325,4 +325,7 @@ tmc_sg_table_buf_size(struct tmc_sg_table *sg_table)struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata); +void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu); +void tmc_etr_remove_catu_ops (void ); +#endif
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 18/20 coresight: allow catu drivers to be built as modules
In reply to Tingwei ZhangAllow to build coresight-catu as modules, for ease of development.
- Kconfig becomes a tristate, to allow =m
- add catu_remove functions, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot
--- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/coresight-catu.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/Kconfig +4 -1
@@ -42,7 +42,7 @@ config CORESIGHT_LINK_AND_SINK_TMC module will be called coresight-tmc. config CORESIGHT_CATU - bool "Coresight Address Translation Unit (CATU) driver" + tristate "Coresight Address Translation Unit (CATU) driver" depends on CORESIGHT_LINK_AND_SINK_TMC help Enable support for the Coresight Address Translation Unit (CATU).
@@ -52,6 +52,9 @@ config CORESIGHT_CATU by looking up the provided table. CATU can also be used in pass-through mode where the address is not translated. + To compile this driver as a module, choose M here: the + module will be called coresight-catu. + config CORESIGHT_SINK_TPIU tristate "Coresight generic TPIU driver" depends on CORESIGHT_LINKS_AND_SINKS
drivers/hwtracing/coresight/coresight-catu.c +15 -0
@@ -567,6 +567,14 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)return ret; } +static int __exit catu_remove(struct amba_device *adev) +{ +struct catu_drvdata *drvdata =dev_get_drvdata (&adev->dev); + +coresight_unregister (drvdata->csdev); +return 0 ; +} +static struct amba_id catu_ids[] = { { .id =0x000bb9ee ,
@@ -575,6 +583,8 @@ static struct amba_id catu_ids[] = { {}, }; +MODULE_DEVICE_TABLE (amba, catu_ids); +static struct amba_driver catu_driver = { .drv = { .name ="coresight-catu" ,
@@ -582,6 +592,7 @@ static struct amba_driver catu_driver = { .suppress_bind_attrs = true, }, .probe = catu_probe, + .remove = catu_remove, .id_table = catu_ids, };
@@ -604,3 +615,7 @@ static void __exit catu_exit(void)module_init (catu_init);module_exit (catu_exit); + +MODULE_AUTHOR ("Suzuki K Poulose <[email protected]>" ); +MODULE_DESCRIPTION ("Arm CoreSight Replicator Driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 19/20 coresight: add try_get_module() in coresight_grab_device()
In reply to Tingwei ZhangWhen coresight device is in an active session, driver module of that device should not be removed. Use try_get_module() in coresight_grab_device() to prevent module to be unloaded.
--- drivers/hwtracing/coresight/coresight.c | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight.c +23 -4
@@ -655,7 +655,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)* don't appear on the trace path, they should be handled along with the * the master device. */ -static void coresight_grab_device (struct coresight_device *csdev) +static int coresight_grab_device (struct coresight_device *csdev) {int i;
@@ -663,10 +663,25 @@ static void coresight_grab_device(struct coresight_device *csdev)struct coresight_device *child; child = csdev->pdata->conns[i].child_dev; -if (child && child->type ==CORESIGHT_DEV_TYPE_HELPER ) +if (child && child->type ==CORESIGHT_DEV_TYPE_HELPER ) { +if (!try_module_get (child->dev.parent->driver->owner)) + goto err;pm_runtime_get_sync (child->dev.parent); + } } +if (!try_module_get (csdev->dev.parent->driver->owner)) + goto err;pm_runtime_get_sync (csdev->dev.parent); +return 0 ; +err: +for (i--; i >=0 ; i--) { +struct coresight_device *child; + + child = csdev->pdata->conns[i].child_dev; +if (child && child->type ==CORESIGHT_DEV_TYPE_HELPER ) +pm_runtime_put (child->dev.parent); + } +return -ENODEV ; }/*
@@ -678,12 +693,15 @@ static void coresight_drop_device(struct coresight_device *csdev)int i;pm_runtime_put (csdev->dev.parent); +module_put (csdev->dev.parent->driver->owner);for (i =0 ; i < csdev->pdata->nr_outport; i++) {struct coresight_device *child; child = csdev->pdata->conns[i].child_dev; -if (child && child->type ==CORESIGHT_DEV_TYPE_HELPER ) +if (child && child->type ==CORESIGHT_DEV_TYPE_HELPER ) {pm_runtime_put (child->dev.parent); +module_put (child->dev.parent->driver->owner); + } } }
@@ -736,7 +754,8 @@ static int _coresight_build_path(struct coresight_device *csdev,if (!node)return -ENOMEM ; -coresight_grab_device (csdev); +if (coresight_grab_device (csdev)) +return -ENODEV ; node->csdev = csdev;list_add (&node->link, path);
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Suzuki K Poulose
maintainerRe: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Cheers
Suzuki
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Suzuki K Poulose
maintainerRe: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Quoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.
Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Also, logically this refcount solution patch must be applied before the drivers are made modules to prevent breaking bisection failures. So, please re-order the patches in the series to take that into consideration.
Suzuki
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Quoted 14 lines · Suzuki K Poulose
Quoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Quoted 6 lines
Also, logically this refcount solution patch must be applied before the drivers are made modules to prevent breaking bisection failures. So, please re-order the patches in the series to take that into consideration.
Suzuki
That's good point. I'll reorder them in next revision.
Thanks,
Tingwei
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
In reply to Suzuki K PouloseQuoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.
Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Remember there are two separate things here, code and data. There are two different reference counts for them, do not confuse the two.
get/put is needed when you have a reference to the data, module stuff is when you are calling into code.
But note that you do not always need to grab a reference count to the module, as long as the module can properly tear the data down when it is asked to be removed. Look at networking drivers as a great example of that.
thanks,
greg k-h
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Suzuki K Poulose
maintainerRe: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Quoted 14 lines · Greg KH
Quoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Quoted 5 lines
Remember there are two separate things here, code and data. There are two different reference counts for them, do not confuse the two.
get/put is needed when you have a reference to the data, module stuff is when you are calling into code.
Exactly. In this case, we have reference to the data specific to the device in a data structure specific to one session, which doesn't have any link back from the device to release it. Thus we need get/put here to make sure that data doesn't get released under our feet.
Quoted 5 lines
But note that you do not always need to grab a reference count to the module, as long as the module can properly tear the data down when it is asked to be removed. Look at networking drivers as a great example of that.
Thanks
Suzuki
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Quoted 18 lines · Suzuki K Poulose
Quoted 17 lines · Greg KH
Quoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Remember there are two separate things here, code and data. There are two different reference counts for them, do not confuse the two.
Quoted 8 lines
Quoted 2 lines
get/put is needed when you have a reference to the data, module stuff is when you are calling into code.
Exactly. In this case, we have reference to the data specific to the device in a data structure specific to one session, which doesn't have any link back from the device to release it. Thus we need get/put here to make sure that data doesn't get released under our feet.
Agree with you, Suzuki and Greg. Device refcount should be used to protect the device data and module refcount should be used to protect module code.
This series is trying to add support to load/unload coresight module. When there's active session ongoing, coresight framework could call operation of client driver like sink->enable(). If module is removed at that time, it will be an issue. Add refcount to module here protect this kind of situation.
For device count, coresight framework currently doesn't hold device refcount. I think that's because coresight client drivers doesn't support dynamic remove the device. As a consequence of module unload, devices which are using that module will be removed. However, module framework will first check the module refcount before calls module exit which leads to device remove. It will return without doing anything if refcount of module is hold by coresight framework.
If we want to support dynamic remove device from unbind interface in coresight driver, we should definitely add device refcount there. This is out of this series' scope.
Thanks, Tingwei
Quoted 6 lines
Quoted 5 lines
But note that you do not always need to grab a reference count to the module, as long as the module can properly tear the data down when it is asked to be removed. Look at networking drivers as a great example of that.
Quoted 8 lines
Thanks
Suzuki
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
In reply to Greg KHQuoted 20 lines · Greg KH
Quoted 8 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Quoted 4 lines
Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Remember there are two separate things here, code and data. There are two different reference counts for them, do not confuse the two.
get/put is needed when you have a reference to the data, module stuff is when you are calling into code.
Quoted 9 lines
But note that you do not always need to grab a reference count to the module, as long as the module can properly tear the data down when it is asked to be removed. Look at networking drivers as a great example of that.
thanks,
greg k-h
Hi Greg,
Understand your point. I made the attempt to not hold the refcount of module but stop/clean up active session in v1 of this series. Link is as below.
https://lore.kernel.org/linux-arm-kernel/[email protected]/
However, there's a lot of tricks to play to make it work especially on perf trace when trace session is dynamically created/start/stop by perf framework. It may have performance overhead as well.
With the suggestion from Mathieu, I'm wondering whether this complexity introduced really worth. Remove a coresight module driver with active trace session ongoing is a corner case. From v2, I turned to another alternative to grad a reference count to module when the operation function in that module could be called by coresight framework. That's a simpler and cleaner solution in my opinion.
Thanks,
Tingwei
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
In reply to Suzuki K PouloseHi Suzuki,
Quoted 10 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This
If I understand correctly you are worried about cases where drivers would be removed but not the reference of the devices using those drivers in the coresight port connections? If so you are very right. Otherwise please expand on the scenario you have in mind.
The first version of this set was doing all that cleanup... I haven't looked at this set yet but from what I've seen the cleanup code is not present in any of the sets after V1. Tingwei, is the work done in coresight_disable_match() part of the later revisions?
Quoted 5 lines
could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Cheers
Suzuki
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 19/20] coresight: add try_get_module() in coresight_grab_device()
Quoted 14 lines · Mathieu Poirier
Hi Suzuki,
Quoted 10 lines · Suzuki K Poulose
Hi Tingwei,
Quoted 4 lines · Tingwei Zhang
When coresight device is in an active session, driver module of that device should not be removed. Use
try_get_module()incoresight_grab_device()to prevent module to be unloaded.Is this really sufficient ? AFAIU, a device could be removed, but the module may still be alive due to the refcount on the module. This
Quoted 7 lines
If I understand correctly you are worried about cases where drivers would be
removed but not the reference of the devices using those drivers in the coresight port connections? If so you are very right. Otherwise please expand
on the scenario you have in mind.
Hi Mathieu and Suzuki,
I didn't add get/put_device() here since coresight doesn't support dymanically add/remove device until this series. This series export one possiblity to add/remove device via load/unload module. Since coresight framework holds reference count for module when there's one active session, device won't be removed when it's used by one active session. Module unload routine checks module reference count before doing anything.
With a second thought, I think it may be better to add get/put_device() with try_get_module()/put_module here to indicate we need protect both code and data when there's on active session.
Quoted 7 lines
The first version of this set was doing all that cleanup... I haven't looked at
this set yet but from what I've seen the cleanup code is not present in any
of the sets after V1. Tingwei, is the work done incoresight_disable_match()
part of the later revisions?
I didn't include cleanup patch in later revision. Module reference count is hold by coresight framework when there's one active session, so the cleanup code won't get chance to be executed.
Thanks, Tingwei
Quoted 11 lines
Quoted 6 lines
could imply that we have stale pointers in the _path_, which could lead to corruption elsewhere. Should we do a get/put_device() instead ?
Cheers
Suzuki_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 20/20 coresight: allow the coresight core driver to be built as a module
In reply to Tingwei ZhangEnhance coresight developer's efficiency to debug coresight drivers.
- Kconfig becomes a tristate, to allow =m
- append -core to source file name to allow module to
be called coresight by the Makefile
- modules can have only one init/exit, so we add the etm_perf register/unregister function calls to the core init/exit functions.
- add a MODULE_DEVICE_TABLE for autoloading on boot
---
drivers/hwtracing/coresight/Kconfig | 5 ++-
drivers/hwtracing/coresight/Makefile | 5 ++-
.../{coresight.c => coresight-core.c} | 42 ++++++++++++++-----
.../hwtracing/coresight/coresight-etm-perf.c | 8 +++-
.../hwtracing/coresight/coresight-etm-perf.h | 3 ++
5 files changed, 48 insertions(+), 15 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (98%)drivers/hwtracing/coresight/Kconfig +4 -1
@@ -3,7 +3,7 @@ # Coresight configuration # menuconfig CORESIGHT - bool "CoreSight Tracing Support" + tristate "CoreSight Tracing Support" depends on ARM || ARM64 depends on OF || ACPI select ARM_AMBA
@@ -15,6 +15,9 @@ menuconfig CORESIGHT specification and configure the right series of components when a trace source gets enabled. + To compile this driver as a module, choose M here: the + module will be called coresight. + if CORESIGHT config CORESIGHT_LINKS_AND_SINKS tristate "CoreSight Link and Sink drivers"
drivers/hwtracing/coresight/Makefile +3 -2
@@ -2,8 +2,9 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o \ - coresight-platform.o coresight-sysfs.o +obj-$(CONFIG_CORESIGHT) += coresight.o +coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ + coresight-sysfs.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \ coresight-tmc-etr.o
drivers/hwtracing/coresight/coresight-core.c renamed from drivers/hwtracing/coresight/coresight.c +32 -10
51 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-etm-perf.c +6 -2
@@ -580,7 +580,7 @@ void etm_perf_del_symlink_sink(struct coresight_device *csdev) csdev->ea =NULL ; } -static int __init etm_perf_init (void ) +int __init etm_perf_init (void ) {int ret;
@@ -607,4 +607,8 @@ static int __init etm_perf_init(void)return ret; } -device_initcall (etm_perf_init); + +void __exit etm_perf_exit(void) +{ +perf_pmu_unregister (&etm_pmu); +}
drivers/hwtracing/coresight/coresight-etm-perf.h +3 -0
@@ -82,4 +82,7 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)#endif /* CONFIG_CORESIGHT */ +int __init etm_perf_init (void ); +void __exit etm_perf_exit(void); +#endif
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel