On Thu, Mar 29, 2018 at 04:42:51PM -0500, Kim Phillips wrote:
Allow to build coresight as modules. This greatly enhances developer efficiency by allowing the development to take place exclusively on the target, and without needing to reboot in between changes.
Kconfig bools become tristates, to allow =m
MODULE_* macros added: Please correct me if I'm wrong:
- assume LICENSE is "GPL v2"
- tried to get as close to original authors for MODULE_AUTHOR
The 'select' Kconfig statements are replaced with 'depends on' clauses, to specify the dependencies between the modules including other fixes, e.g., coresight-stm unconditionally calls stm_register_device, it therefore depends on STM.
use -objs to denote merge object directives in Makefile, adds a coresight-core nomenclature for the base module.
add a coresight_exit() that unregisters the coresight bus, add remove fns for most others.
fix up modules with ID tables for autoloading on boot, add missing __init and __exit attributes
move coresight_vpid_to_pid to an externed, single instance in coresight-core, to be used by all submodules.
Signed-off-by: Kim Phillips kim.phillips@arm.com
So far tested on a Juno (albeit getting dreaded mmap error 12 (ENOMEM) on a linux-next based tree), build-tested for arm32.
It's normal if you're trying to use the ETR as a sink. Otherwise it demands more investigation.
drivers/hwtracing/coresight/Kconfig | 33 ++++++++--------- drivers/hwtracing/coresight/Makefile | 28 ++++++++++----- drivers/hwtracing/coresight/coresight-cpu-debug.c | 2 ++ .../coresight/coresight-dynamic-replicator.c | 18 +++++++++- drivers/hwtracing/coresight/coresight-etb10.c | 18 +++++++++- drivers/hwtracing/coresight/coresight-etm-cp14.c | 4 +++ drivers/hwtracing/coresight/coresight-etm-perf.c | 13 ++++++- drivers/hwtracing/coresight/coresight-etm-perf.h | 2 +- .../hwtracing/coresight/coresight-etm3x-sysfs.c | 5 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 18 +++++++++- .../hwtracing/coresight/coresight-etm4x-sysfs.c | 6 ++++ drivers/hwtracing/coresight/coresight-etm4x.c | 19 +++++++++- drivers/hwtracing/coresight/coresight-funnel.c | 18 +++++++++- drivers/hwtracing/coresight/coresight-priv.h | 2 +- drivers/hwtracing/coresight/coresight-replicator.c | 18 +++++++++- drivers/hwtracing/coresight/coresight-stm.c | 22 ++++++++++-- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++++ drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++ drivers/hwtracing/coresight/coresight-tmc.c | 23 +++++++++++- drivers/hwtracing/coresight/coresight-tpiu.c | 21 +++++++++-- drivers/hwtracing/coresight/coresight.c | 42 ++++++++++++++++++++++ include/linux/coresight.h | 23 ++---------- 22 files changed, 284 insertions(+), 62 deletions(-)
diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig index ef9cb3c164e1..506fe5db3074 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -2,8 +2,8 @@ # Coresight configuration # menuconfig CORESIGHT
- bool "CoreSight Tracing Support"
- select ARM_AMBA
- tristate "CoreSight Tracing Support"
- depends on ARM_AMBA select PERF_EVENTS help This framework provides a kernel interface for the CoreSight debug
@@ -14,7 +14,8 @@ menuconfig CORESIGHT if CORESIGHT config CORESIGHT_LINKS_AND_SINKS
- bool "CoreSight Link and Sink drivers"
- tristate "CoreSight Link and Sink drivers"
- depends on CORESIGHT help This enables support for CoreSight link and sink drivers that are responsible for transporting and collecting the trace data
@@ -22,7 +23,7 @@ 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
It is probably a good time to get rid of the dependency on CORESIGHT_LINKS_AND_SINKS. Once upon a time it was true but not anymore. I suggest to drop it for all devices below. Please do a separate patch for that.
help This enables support for the Trace Memory Controller driver. @@ -32,7 +33,7 @@ config CORESIGHT_LINK_AND_SINK_TMC special enhancement or added features. 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,
@@ -43,7 +44,7 @@ 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
@@ -51,9 +52,8 @@ config CORESIGHT_SINK_ETBV10 special enhancement or added features. config CORESIGHT_SOURCE_ETM3X
- bool "CoreSight Embedded Trace Macrocell 3.x driver"
- depends on !ARM64
- select CORESIGHT_LINKS_AND_SINKS
- tristate "CoreSight Embedded Trace Macrocell 3.x driver"
- depends on !ARM64 && CORESIGHT_LINKS_AND_SINKS help This driver provides support for processor ETM3.x and PTM1.x modules, which allows tracing the instructions that a processor is executing
@@ -61,9 +61,8 @@ config CORESIGHT_SOURCE_ETM3X the ETM version data tracing may also be available. config CORESIGHT_SOURCE_ETM4X
- bool "CoreSight Embedded Trace Macrocell 4.x driver"
- depends on ARM64
- select CORESIGHT_LINKS_AND_SINKS
- tristate "CoreSight Embedded Trace Macrocell 4.x driver"
- depends on ARM64 && CORESIGHT_LINKS_AND_SINKS help This driver provides support for the ETM4.x tracer module, tracing the instructions that a processor is executing. This is primarily useful
@@ -71,7 +70,7 @@ config CORESIGHT_SOURCE_ETM4X data tracing may also be available. config CORESIGHT_DYNAMIC_REPLICATOR
- bool "CoreSight Programmable Replicator driver"
- tristate "CoreSight Programmable Replicator driver" depends on CORESIGHT_LINKS_AND_SINKS help This enables support for dynamic CoreSight replicator link driver.
@@ -79,10 +78,9 @@ config CORESIGHT_DYNAMIC_REPLICATOR trace data based on the traceid. 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
- depends on STM && CORESIGHT_LINKS_AND_SINKS help This driver provides support for hardware assisted software instrumentation based tracing. This is primarily used for
@@ -91,8 +89,7 @@ config CORESIGHT_STM config CORESIGHT_CPU_DEBUG tristate "CoreSight CPU Debug driver"
- depends on ARM || ARM64
- depends on DEBUG_FS
- depends on CORESIGHT && DEBUG_FS help This driver provides support for coresight debugging module. This is primarily used to dump sample-based profiling registers when
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 61db9dd0d571..95a4b1ffe794 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -2,19 +2,29 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o -obj-$(CONFIG_OF) += of_coresight.o -obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \
coresight-tmc-etf.o \
coresight-tmc-etr.o
+obj-$(CONFIG_CORESIGHT) += coresight-core.o
I find the "core" appendage heavy and suggest it be dropped. Same for ETMs and TMC.
+coresight-core-objs := coresight.o \
of_coresight.o
+obj-$(CONFIG_CORESIGHT) += coresight-etm-perf.o
+obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-link-sink-tmc.o
Please move to coresight-tmc.o
+coresight-link-sink-tmc-objs := coresight-tmc.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 \ coresight-replicator.o -obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.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_ETM3X) += coresight-etm3x-core.o +coresight-etm3x-core-objs := coresight-etm3x.o \
coresight-etm-cp14.o \
coresight-etm3x-sysfs.o
+obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x-core.o
+coresight-etm4x-core-objs := coresight-etm4x.o coresight-etm4x-sysfs.o
obj-$(CONFIG_CORESIGHT_DYNAMIC_REPLICATOR) += coresight-dynamic-replicator.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index 9cdb3fbc8c1f..ff6d3be1b13c 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -683,6 +683,8 @@ static const struct amba_id debug_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, debug_ids);
static struct amba_driver debug_driver = { .drv = { .name = "coresight-cpu-debug", diff --git a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c index 043da86b0fe9..a7f486a577b0 100644 --- a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c +++ b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c @@ -167,6 +167,15 @@ static int replicator_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR_OR_ZERO(drvdata->csdev); } +static int __exit replicator_remove(struct amba_device *adev) +{
- struct replicator_state *drvdata = dev_get_drvdata(&adev->dev);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
#ifdef CONFIG_PM static int replicator_runtime_suspend(struct device *dev) { @@ -208,6 +217,8 @@ static const struct amba_id replicator_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, replicator_ids);
static struct amba_driver replicator_driver = { .drv = { .name = "coresight-dynamic-replicator", @@ -215,6 +226,11 @@ static struct amba_driver replicator_driver = { .suppress_bind_attrs = true, }, .probe = replicator_probe,
- .remove = replicator_remove, .id_table = replicator_ids,
}; -builtin_amba_driver(replicator_driver); +module_amba_driver(replicator_driver);
+MODULE_AUTHOR("Suzuki K Poulose suzuki.poulose@arm.com"); +MODULE_DESCRIPTION("ARM Coresight Dynamic Replicator Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 580cd381adf3..b011254f083a 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -719,6 +719,15 @@ 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);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
#ifdef CONFIG_PM static int etb_runtime_suspend(struct device *dev) { @@ -753,6 +762,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", @@ -762,6 +773,11 @@ 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("Mathieu Poirier mathieu.poirier@linaro.org");
Also add Pratik as a module author.
+MODULE_DESCRIPTION("Arm CoreSight Embedded Trace Buffer driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm-cp14.c b/drivers/hwtracing/coresight/coresight-etm-cp14.c index 12a220682117..1e16a6358364 100644 --- a/drivers/hwtracing/coresight/coresight-etm-cp14.c +++ b/drivers/hwtracing/coresight/coresight-etm-cp14.c @@ -589,3 +589,7 @@ int etm_writel_cp14(u32 reg, u32 val) return 0; }
+MODULE_AUTHOR("Pratik Patel pratikp@codeaurora.org"); +MODULE_DESCRIPTION("Arm CoreSight ETM CP14 driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 8a0ad77574e7..9c1b9b359feb 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -484,6 +484,7 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link) return 0; } +EXPORT_SYMBOL_GPL(etm_perf_symlink); static int __init etm_perf_init(void) { @@ -511,4 +512,14 @@ static int __init etm_perf_init(void) return ret; } -device_initcall(etm_perf_init); +module_init(etm_perf_init);
+static void __exit etm_perf_exit(void) +{
- perf_pmu_unregister(&etm_pmu);
+} +module_exit(etm_perf_exit);
+MODULE_AUTHOR("Mathieu Poirier mathieu.poirier@linaro.org"); +MODULE_DESCRIPTION("Arm CoreSight tracer perf driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h index 3ffc9feb2d64..8c49c7b82d84 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -54,7 +54,7 @@ struct etm_filters { }; -#ifdef CONFIG_CORESIGHT +#if IS_ENABLED(CONFIG_CORESIGHT) int etm_perf_symlink(struct coresight_device *csdev, bool link); #else diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c index 6e547ec6fead..bef24b9fe83c 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -17,6 +17,7 @@ #include <linux/pm_runtime.h> #include <linux/sysfs.h> +#include <linux/coresight.h> #include "coresight-etm.h" #include "coresight-priv.h" @@ -1274,3 +1275,7 @@ const struct attribute_group *coresight_etm_groups[] = { &coresight_etm_mgmt_group, NULL, };
+MODULE_AUTHOR("Mathieu Poirier mathieu.poirier@linaro.org");
Also add Pratik.
+MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace sysfs driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 39f42fdd503d..dc6347594ac3 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -873,6 +873,15 @@ 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);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
#ifdef CONFIG_PM static int etm_runtime_suspend(struct device *dev) { @@ -933,6 +942,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", @@ -941,6 +952,11 @@ 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("Mathieu Poirier mathieu.poirier@linaro.org");
Also add Pratik.
+MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index d21961710713..04119b963454 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -17,6 +17,7 @@ #include <linux/pm_runtime.h> #include <linux/sysfs.h> +#include <linux/coresight.h> #include "coresight-etm4x.h" #include "coresight-priv.h" @@ -2155,3 +2156,8 @@ const struct attribute_group *coresight_etmv4_groups[] = { &coresight_etmv4_trcidr_group, NULL, }; +EXPORT_SYMBOL_GPL(coresight_etmv4_groups);
+MODULE_AUTHOR("Mathieu Poirier mathieu.poirier@linaro.org"); +MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace v4 sysfs driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index cf364a514c12..cc8cb519c21b 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -905,6 +905,7 @@ void etm4_config_trace_mode(struct etmv4_config *config) config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc; config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc; } +EXPORT_SYMBOL_GPL(etm4_config_trace_mode);
Not sure this is needed - I was able to compile and insmod without it.
static int etm4_online_cpu(unsigned int cpu) { @@ -1052,6 +1053,15 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) return ret; } +static int __exit etm4_remove(struct amba_device *adev) +{
- struct etmv4_drvdata *drvdata = dev_get_drvdata(&adev->dev);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
static const struct amba_id etm4_ids[] = { { /* ETM 4.0 - Cortex-A53 */ .id = 0x000bb95d, @@ -1071,12 +1081,19 @@ static const struct amba_id etm4_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, etm4_ids);
static struct amba_driver etm4x_driver = { .drv = { .name = "coresight-etm4x", .suppress_bind_attrs = true,
I'm pretty sure we need a ".owner = THIS_MODULE," here.
}, .probe = etm4_probe,
- .remove = etm4_remove, .id_table = etm4_ids,
}; -builtin_amba_driver(etm4x_driver); +module_amba_driver(etm4x_driver);
Add me as author.
+MODULE_AUTHOR("Pratik Patel pratikp@codeaurora.org"); +MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace v4 driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 9f8ac0bef853..bb87902c4f28 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -218,6 +218,15 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR_OR_ZERO(drvdata->csdev); } +static int __exit funnel_remove(struct amba_device *adev) +{
- struct funnel_drvdata *drvdata = dev_get_drvdata(&adev->dev);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
#ifdef CONFIG_PM static int funnel_runtime_suspend(struct device *dev) { @@ -257,6 +266,8 @@ static const struct amba_id funnel_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, funnel_ids);
static struct amba_driver funnel_driver = { .drv = { .name = "coresight-funnel", @@ -265,6 +276,11 @@ static struct amba_driver funnel_driver = { .suppress_bind_attrs = true, }, .probe = funnel_probe,
- .remove = funnel_remove, .id_table = funnel_ids,
}; -builtin_amba_driver(funnel_driver); +module_amba_driver(funnel_driver);
+MODULE_AUTHOR("Mathieu Poirier mathieu.poirier@linaro.org"); +MODULE_DESCRIPTION("ARM Coresight Funnel Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index f1d0e21d8cab..f01e38838cfc 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -143,7 +143,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink); void coresight_release_path(struct list_head *path); -#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X +#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X)
Although trivial it should go in a separate patch.
extern int etm_readl_cp14(u32 off, unsigned int *val); extern int etm_writel_cp14(u32 off, u32 val); #else diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 3756e71cb8f5..25f557c571de 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -119,6 +119,15 @@ static int replicator_probe(struct platform_device *pdev) return ret; } +static int __exit replicator_remove(struct platform_device *pdev) +{
- struct replicator_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
- coresight_unregister(drvdata->csdev);
- return 0;
+}
#ifdef CONFIG_PM static int replicator_runtime_suspend(struct device *dev) { @@ -151,8 +160,11 @@ static const struct of_device_id replicator_match[] = { {} }; +MODULE_DEVICE_TABLE(of, replicator_match);
static struct platform_driver replicator_driver = { .probe = replicator_probe,
- .remove = replicator_remove, .driver = { .name = "coresight-replicator", .of_match_table = replicator_match,
@@ -160,4 +172,8 @@ static struct platform_driver replicator_driver = { .suppress_bind_attrs = true, }, }; -builtin_platform_driver(replicator_driver); +module_platform_driver(replicator_driver);
Add me as a module author.
+MODULE_AUTHOR("Pratik Patel pratikp@codeaurora.org"); +MODULE_DESCRIPTION("ARM Coresight Replicator Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 15e7ef3891f5..e864602956a2 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -790,7 +790,7 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata) drvdata->stm.set_options = stm_generic_set_options; } -static int stm_probe(struct amba_device *adev, const struct amba_id *id) +static int __init stm_probe(struct amba_device *adev, const struct amba_id *id)
This gives me a "section mismatch" warning when compiling (both built-in and as a module). I wonder how you don't see this on your side.
$ aarch64-linux-gnu-gcc --version aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
{ int ret; void __iomem *base; @@ -889,6 +889,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) { @@ -929,6 +940,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", @@ -937,7 +950,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 pratikp@codeaurora.org"); +MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index e2513b786242..df9ea4cb1ed1 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -522,11 +522,13 @@ static const struct coresight_ops_link tmc_etf_link_ops = { const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, }; +EXPORT_SYMBOL_GPL(tmc_etb_cs_ops); const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, }; +EXPORT_SYMBOL_GPL(tmc_etf_cs_ops); int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) { @@ -575,6 +577,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) return ret; } +EXPORT_SYMBOL_GPL(tmc_read_prepare_etb); int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata) { @@ -628,3 +631,6 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata) return 0; } +EXPORT_SYMBOL_GPL(tmc_read_unprepare_etb);
Once again I was able to compile and install the module without those exports.
+MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 68fbc8f7450e..858dff61ef41 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -263,6 +263,7 @@ static const struct coresight_ops_sink tmc_etr_sink_ops = { const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, }; +EXPORT_SYMBOL_GPL(tmc_etr_cs_ops); int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) { @@ -301,6 +302,7 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) return ret; } +EXPORT_SYMBOL_GPL(tmc_read_prepare_etr); int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata) { @@ -342,3 +344,6 @@ int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata) return 0; } +EXPORT_SYMBOL_GPL(tmc_read_unprepare_etr);
Same here.
+MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 0ea04f588de0..564dd85494ee 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -41,6 +41,7 @@ void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata) "timeout while waiting for TMC to be Ready\n"); } } +EXPORT_SYMBOL_GPL(tmc_wait_for_tmcready); void tmc_flush_and_stop(struct tmc_drvdata *drvdata) { @@ -60,16 +61,19 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata) tmc_wait_for_tmcready(drvdata); } +EXPORT_SYMBOL_GPL(tmc_flush_and_stop); void tmc_enable_hw(struct tmc_drvdata *drvdata) { writel_relaxed(TMC_CTL_CAPT_EN, drvdata->base + TMC_CTL); } +EXPORT_SYMBOL_GPL(tmc_enable_hw); void tmc_disable_hw(struct tmc_drvdata *drvdata) { writel_relaxed(0x0, drvdata->base + TMC_CTL); } +EXPORT_SYMBOL_GPL(tmc_disable_hw);
Same here.
static int tmc_read_prepare(struct tmc_drvdata *drvdata) { @@ -437,6 +441,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[] = { { .id = 0x000bb961, @@ -461,6 +475,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", @@ -468,6 +484,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);
Add me as a module author.
+MODULE_AUTHOR("Pratik Patel pratikp@codeaurora.org"); +MODULE_DESCRIPTION("Arm CoreSight Trace Memory Controller driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 805f7c2210fe..20452c5634c7 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -118,7 +118,8 @@ static const struct coresight_ops tpiu_cs_ops = { .sink_ops = &tpiu_sink_ops, }; -static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) +static int __init tpiu_probe(struct amba_device *adev,
const struct amba_id *id)
Another section mismatch with this.
{ int ret; void __iomem *base; @@ -171,6 +172,15 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR_OR_ZERO(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) { @@ -214,6 +224,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", @@ -222,6 +234,11 @@ 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 pratikp@codeaurora.org"); +MODULE_DESCRIPTION("Arm CoreSight TPIU (Trace Port Interface Unit) driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 132dfbcd90c1..e7244ecf663c 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -24,9 +24,32 @@ #include <linux/of_platform.h> #include <linux/delay.h> #include <linux/pm_runtime.h> +#include <linux/sched.h> #include "coresight-priv.h" +#ifdef CONFIG_PID_NS +unsigned long coresight_vpid_to_pid(unsigned long vpid) +{
- struct task_struct *task = NULL;
- unsigned long pid = 0;
- rcu_read_lock();
- task = find_task_by_vpid(vpid);
- if (task)
pid = task_pid_nr(task);
- rcu_read_unlock();
- return pid;
+} +#else +unsigned long coresight_vpid_to_pid(unsigned long vpid) +{
- return vpid;
+} +#endif +EXPORT_SYMBOL_GPL(coresight_vpid_to_pid);
static DEFINE_MUTEX(coresight_mutex); /** @@ -60,6 +83,7 @@ static struct list_head *stm_path; */ const u32 barrier_pkt[5] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x0}; +EXPORT_SYMBOL_GPL(barrier_pkt);
Please move barrier_pkt to coresight-priv.h and declare it there as "static const".
static int coresight_id_match(struct device *dev, void *data) { @@ -317,6 +341,7 @@ void coresight_disable_path(struct list_head *path) } } } +EXPORT_SYMBOL_GPL(coresight_disable_path); int coresight_enable_path(struct list_head *path, u32 mode) { @@ -368,6 +393,7 @@ int coresight_enable_path(struct list_head *path, u32 mode) coresight_disable_path(path); goto out; } +EXPORT_SYMBOL_GPL(coresight_enable_path); struct coresight_device *coresight_get_sink(struct list_head *path) { @@ -383,6 +409,7 @@ struct coresight_device *coresight_get_sink(struct list_head *path) return csdev; } +EXPORT_SYMBOL_GPL(coresight_get_sink); static int coresight_enabled_sink(struct device *dev, void *data) { @@ -407,6 +434,7 @@ static int coresight_enabled_sink(struct device *dev, void *data) return 0; } +EXPORT_SYMBOL_GPL(coresight_enabled_sink); /**
- coresight_get_enabled_sink - returns the first enabled sink found on the bus
@@ -429,6 +457,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate) return dev ? to_coresight_device(dev) : NULL; } +EXPORT_SYMBOL_GPL(coresight_get_enabled_sink); /**
- _coresight_build_path - recursively build a path from a @csdev to a sink.
@@ -508,6 +537,7 @@ struct list_head *coresight_build_path(struct coresight_device *source, return path; } +EXPORT_SYMBOL_GPL(coresight_build_path); /**
- coresight_release_path - release a previously built path.
@@ -532,6 +562,7 @@ void coresight_release_path(struct list_head *path) kfree(path); path = NULL; } +EXPORT_SYMBOL_GPL(coresight_release_path); /** coresight_validate_source - make sure a source has the right credentials
- @csdev: the device structure for a source.
@@ -948,6 +979,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", @@ -959,6 +991,12 @@ static int __init coresight_init(void) } postcore_initcall(coresight_init); +static void __exit coresight_exit(void) +{
- bus_unregister(&coresight_bustype);
+} +module_exit(coresight_exit);
struct coresight_device *coresight_register(struct coresight_desc *desc) { int i; @@ -1056,3 +1094,7 @@ void coresight_unregister(struct coresight_device *csdev) device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister);
+MODULE_AUTHOR("Mathieu Poirier mathieu.poirier@linaro.org"); +MODULE_DESCRIPTION("ARM Coresight Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index d950dad5056a..5863eb1a7335 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -243,7 +243,7 @@ struct coresight_ops { const struct coresight_ops_source *source_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); @@ -274,24 +274,5 @@ static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, const struct device_node *node) { return NULL; } #endif -#ifdef CONFIG_PID_NS -static inline unsigned long -coresight_vpid_to_pid(unsigned long vpid) -{
- struct task_struct *task = NULL;
- unsigned long pid = 0;
- rcu_read_lock();
- task = find_task_by_vpid(vpid);
- if (task)
pid = task_pid_nr(task);
- rcu_read_unlock();
- return pid;
-} -#else -static inline unsigned long -coresight_vpid_to_pid(unsigned long vpid) { return vpid; } -#endif
+extern unsigned long coresight_vpid_to_pid(unsigned long vpid);
#endif
2.16.2
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight