etm4_count keeps track of number of ETMv4 registered and on some systems,
a race is observed on etm4_count variable which can lead to multiple calls
to cpuhp_setup_state_nocalls_cpuslocked(). This function internally calls
cpuhp_store_callbacks() which prevents multiple registrations of callbacks
for a given state and due to this race, it returns -EBUSY leading to ETM
probe failures like below.
coresight-etm4x: probe of 7040000.etm failed with error -16
This race can easily be triggered with async probe by setting probe type
as PROBE_PREFER_ASYNCHRONOUS and with ETM power management property
"arm,coresight-loses-context-with-cpu".
Prevent this race by moving cpuhp callbacks to etm driver init since the
cpuhp callbacks doesn't have to depend on the etm4_count and can be once
setup during driver init. Similarly we move cpu_pm notifier registration
to driver init and completely remove etm4_count usage.
Fixes: 9b6a3f3633a5 ("coresight: etmv4: Fix CPU power management setup in probe() function")
Fixes: 58eb457be028 ("hwtracing/coresight-etm4x: Convert to hotplug state machine")
Suggested-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan(a)codeaurora.org>
---
Changes in v2:
* Rearrange cpuhp callbacks and move them to driver init (Suzuki K Poulose)
---
drivers/hwtracing/coresight/coresight-etm4x.c | 51 ++++++++++---------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index 6d7d2169bfb2..adb71987a1e3 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -48,8 +48,6 @@ module_param(pm_save_enable, int, 0444);
MODULE_PARM_DESC(pm_save_enable,
"Save/restore state on power down: 1 = never, 2 = self-hosted");
-/* The number of ETMv4 currently registered */
-static int etm4_count;
static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
static void etm4_set_default_config(struct etmv4_config *config);
static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
@@ -1403,12 +1401,9 @@ static int etm4_pm_setup_cpuslocked(void)
{
int ret;
- if (etm4_count++)
- return 0;
-
ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
if (ret)
- goto reduce_count;
+ return ret;
ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,
"arm/coresight4:starting",
@@ -1432,17 +1427,11 @@ static int etm4_pm_setup_cpuslocked(void)
unregister_notifier:
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
-
-reduce_count:
- --etm4_count;
return ret;
}
static void etm4_pm_clear(void)
{
- if (--etm4_count != 0)
- return;
-
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
if (hp_online) {
@@ -1498,22 +1487,12 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
if (!desc.name)
return -ENOMEM;
- cpus_read_lock();
etmdrvdata[drvdata->cpu] = drvdata;
if (smp_call_function_single(drvdata->cpu,
etm4_init_arch_data, drvdata, 1))
dev_err(dev, "ETM arch init failed\n");
- ret = etm4_pm_setup_cpuslocked();
- cpus_read_unlock();
-
- /* etm4_pm_setup_cpuslocked() does its own cleanup - exit on error */
- if (ret) {
- etmdrvdata[drvdata->cpu] = NULL;
- return ret;
- }
-
if (etm4_arch_supported(drvdata->arch) == false) {
ret = -EINVAL;
goto err_arch_supported;
@@ -1560,7 +1539,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
err_arch_supported:
etmdrvdata[drvdata->cpu] = NULL;
- etm4_pm_clear();
return ret;
}
@@ -1598,4 +1576,29 @@ static struct amba_driver etm4x_driver = {
.probe = etm4_probe,
.id_table = etm4_ids,
};
-builtin_amba_driver(etm4x_driver);
+
+static int __init etm4x_init(void)
+{
+ int ret;
+
+ cpus_read_lock();
+ ret = etm4_pm_setup_cpuslocked();
+ cpus_read_unlock();
+
+ /* etm4_pm_setup_cpuslocked() does its own cleanup - exit on error */
+ if (ret)
+ return ret;
+
+ ret = amba_driver_register(&etm4x_driver);
+ if (ret) {
+ pr_info("Error registering etm4x driver\n");
+ goto err_init;
+ }
+
+ return ret;
+
+err_init:
+ etm4_pm_clear();
+ return ret;
+}
+module_init(etm4x_init);
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
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 v3:
Rebase to coresight-next (Mike and Mathieu)
Reorder try_get_module() (Suzuki)
Clean up etmdrvdata[] in device remote path (Mike)
Move cti_remove_conn_xrefs to cti_remove (Mike)
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
coresight: add try_get_module() in coresight_grab_device()
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: 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} | 51 ++++++++-
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} | 26 ++++-
.../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, 520 insertions(+), 77 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (95%)
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%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Hello,
PPE stock we can ship today from Los Angeles, CA. You can also send someone
to inspect the stock or pick it up from Beverly Hills California.
* Nitrile Gloves
* KN95 (CDC EUI List FDA approved)
* KN95 (FDA approved)
* 3Ply Disposable Masks (Level 1, 2, 3 - Medical grade)
* Contactless Thermometer
* Hand Sanitizers
For production run:
* Isolation Gowns
* Disposable Shoe Cover
* Disposable Head Cover
* Rapid Antibody Test Kits (FOB China)
* Cotton Masks
Let me know if we can get on a call, you can call us directly on 310 596
5555.
We are FDA approved company (FDA number 3016649392) and PPAI.
Thanks and stay safe,
Rod Saif
310 596 5555
ppekits.net
<http://ec2-52-26-194-35.us-west-2.compute.amazonaws.com/x/d?c=8128568&l=c97…>
PPE Kits by Dioz Group of Companies, Beverly Hills CA (PPAI/ FDA)
Regards,
--
Rod Saif | Director of Marketing
Dioz Group | Oasis Apparel | Alanic | PPE KITS | Clean Health USA
HQ: Beverly Hills, CA 90211, USA
Web: www.diozgroup.com
<http://ec2-52-26-194-35.us-west-2.compute.amazonaws.com/x/d?c=8128568&l=e93…>
Web: https://cleanhealthusa.com
You may unsubscribe
<http://ec2-52-26-194-35.us-west-2.compute.amazonaws.com/x/u?u=2e22cc71-539b…>
to stop receiving our emails.
Hi Mike,
Since commit 9b6a3f3633a5cc9("coresight: etmv4: Fix CPU power management
setup in probe() function"),
ETM probe fails consistently like below:
localhost ~ # dmesg | grep -i etm
[ 6.460602] coresight-etm4x: probe of 7040000.etm failed with error
-16
[ 6.524756] coresight etm1: CPU1: ETM v4.2 initialized
[ 6.531152] coresight etm2: CPU2: ETM v4.2 initialized
[ 6.538495] coresight etm3: CPU3: ETM v4.2 initialized
[ 6.545124] coresight etm4: CPU4: ETM v4.2 initialized
[ 6.552904] coresight etm5: CPU5: ETM v4.2 initialized
[ 6.559714] coresight etm6: CPU6: ETM v4.2 initialized
[ 6.569596] coresight etm7: CPU7: ETM v4.2 initialized
localhost ~ #
Most of the time its for ETM0 but I occasionally see ETM1 and other ETMs
failing to probe,
but the some ETM probe failure is always there. I'm using SC7180 based
platform on 5.4 kernel
which has all the coresight patches backported.
If I revert that commit, I don't see the issue at all. In case you can
identify something which
might be causing this, please let me know. I'm planning to look into
this as well in the meantime.
Thanks,
Sai
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member
of Code Aurora Forum, hosted by The Linux Foundation
etm4_count keeps track of number of ETMv4 registered and on some
systems, a race is observed on etm4_count variable which can
lead to multiple calls to cpuhp_setup_state_nocalls_cpuslocked().
This function internally calls cpuhp_store_callbacks() which
prevents multiple registrations of callbacks for a given state
and due to this race, it returns -EBUSY leading to ETM probe
failures like below.
coresight-etm4x: probe of 7040000.etm failed with error -16
This race can easily be triggered with async probe by setting
probe type as PROBE_PREFER_ASYNCHRONOUS and with ETM power
management property "arm,coresight-loses-context-with-cpu".
Prevent this race by converting etm4_count variable to atomic.
Fixes: 9b6a3f3633a5 ("coresight: etmv4: Fix CPU power management setup in probe() function")
Fixes: 58eb457be028 ("hwtracing/coresight-etm4x: Convert to hotplug state machine")
Suggested-by: Mike Leach <mike.leach(a)linaro.org>
(Mike: Rootcause and context for commit message)
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan(a)codeaurora.org>
---
drivers/hwtracing/coresight/coresight-etm4x.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index 6d7d2169bfb2..f256ea744c51 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(pm_save_enable,
"Save/restore state on power down: 1 = never, 2 = self-hosted");
/* The number of ETMv4 currently registered */
-static int etm4_count;
+static atomic_t etm4_count;
static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
static void etm4_set_default_config(struct etmv4_config *config);
static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
@@ -1403,7 +1403,7 @@ static int etm4_pm_setup_cpuslocked(void)
{
int ret;
- if (etm4_count++)
+ if (atomic_inc_return(&etm4_count))
return 0;
ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
@@ -1434,13 +1434,13 @@ static int etm4_pm_setup_cpuslocked(void)
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
reduce_count:
- --etm4_count;
+ atomic_dec(&etm4_count);
return ret;
}
static void etm4_pm_clear(void)
{
- if (--etm4_count != 0)
+ if (atomic_dec_return(&etm4_count) != 0)
return;
cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
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 v4:
Fix error handling in coresight_grab_devicei() (Greg)
Add coresight: cti: Fix remove sysfs link error from Mike
-https://lists.linaro.org/pipermail/coresight/2020-July/004275.html
Move cti_remove_conn_xrefs() into cti_remove() (Mike)
Align patch subject to coresight: <component>: <description> (Mike)
Change from v3:
Rebase to coresight-next (Mike and Mathieu)
Reorder try_get_module() (Suzuki)
Clean up etmdrvdata[] in device remote path (Mike)
Move cti_remove_conn_xrefs to cti_remove (Mike)
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: etm3x: allow etm3x to be built as a module
coresight: etm4x: allow etm4x to be built as a module
coresight: etb: allow etb to be built as a module
coresight: tpiu: allow tpiu to be built as a module
coresight: tmc: 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: funnel: remove multiple init calls from funnel driver
coresight: replicator: remove multiple init calls
coresight: tmc-etr: add function to register catu ops
Mike Leach (1):
coresight: cti: Fix remove sysfs link error
Tingwei Zhang (10):
coresight: cpu_debug: add module name in Kconfig
coresight: cpu_debug: define MODULE_DEVICE_TABLE
coresight: add coresight prefix to barrier_pkt
coresight: add try_get_module() in coresight_grab_device()
coresight: stm: allow to build coresight-stm as a module
coresight: etm: perf: Fix warning caused by etm_setup_aux failure
coresight: cti: add function to register cti associate ops
coresight: cti: allow cti to be built as a module
coresight: catu: allow catu drivers to be built as modules
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} | 114 +++++++++++++++---
.../hwtracing/coresight/coresight-cpu-debug.c | 2 +
.../{coresight-cti.c => coresight-cti-core.c} | 60 +++++++--
drivers/hwtracing/coresight/coresight-etb10.c | 22 +++-
.../hwtracing/coresight/coresight-etm-perf.c | 13 +-
.../hwtracing/coresight/coresight-etm-perf.h | 5 +-
...resight-etm3x.c => coresight-etm3x-core.c} | 27 ++++-
...resight-etm4x.c => coresight-etm4x-core.c} | 26 +++-
.../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, 539 insertions(+), 83 deletions(-)
rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (94%)
rename drivers/hwtracing/coresight/{coresight-cti.c => coresight-cti-core.c} (95%)
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%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
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%)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project