* [PATCH v2 0/2] Add CPU power management for CPU bound CTI devices.
@ 2020-05-04 16:15 Mike Leach
2020-05-04 16:15 ` [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver Mike Leach
2020-05-04 16:15 ` [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices Mike Leach
0 siblings, 2 replies; 5+ messages in thread
From: Mike Leach @ 2020-05-04 16:15 UTC (permalink / raw)
To: linux-arm-kernel, coresight, mathieu.poirier; +Cc: Mike Leach, suzuki.poulose
Adds in power management for CPU bound CTI devices:
i) CPU Hotplug - registers a new notifier for CPU start and stop events.
ii) CPU idle PM event notifier to handle PM_ENTER, PM_ENTER_FAILED and
PM_EXIT events.
Tested with DB410c on Linux 5.7-rc3.
Rebased onto coresight/next
Changes since V1: (requested by Mathieu).
1) Split into separate patches for CPU pm and CPU hotplug handling.
2) Enable on hotplug has a specific function to enable the hardware,
while leaving the enable reference counts unchanged.
Mike Leach (2):
coresight: cti: Add CPU Hotplug handling to CTI driver.
coresight: cti: Add CPU idle pm notifer to CTI devices.
drivers/hwtracing/coresight/coresight-cti.c | 173 ++++++++++++++++++++
include/linux/cpuhotplug.h | 1 +
2 files changed, 174 insertions(+)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver.
2020-05-04 16:15 [PATCH v2 0/2] Add CPU power management for CPU bound CTI devices Mike Leach
@ 2020-05-04 16:15 ` Mike Leach
2020-05-06 17:39 ` Mathieu Poirier
2020-05-04 16:15 ` [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices Mike Leach
1 sibling, 1 reply; 5+ messages in thread
From: Mike Leach @ 2020-05-04 16:15 UTC (permalink / raw)
To: linux-arm-kernel, coresight, mathieu.poirier; +Cc: Mike Leach, suzuki.poulose
Adds registration of CPU start and stop functions to CPU hotplug
mechanisms - for any CPU bound CTI.
Sets CTI powered flag according to state.
Will enable CTI on CPU start if there are existing enable requests.
Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
drivers/hwtracing/coresight/coresight-cti.c | 91 +++++++++++++++++++++
include/linux/cpuhotplug.h | 1 +
2 files changed, 92 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
index be61c1705916..9af66719ae5b 100644
--- a/drivers/hwtracing/coresight/coresight-cti.c
+++ b/drivers/hwtracing/coresight/coresight-cti.c
@@ -40,6 +40,12 @@ static DEFINE_MUTEX(ect_mutex);
#define csdev_to_cti_drvdata(csdev) \
dev_get_drvdata(csdev->dev.parent)
+/* power management handling */
+static int nr_cti_cpu;
+
+/* quick lookup list for CPU bound CTIs when power handling */
+static struct cti_drvdata *cti_cpu_drvdata[NR_CPUS];
+
/*
* CTI naming. CTI bound to cores will have the name cti_cpu<N> where
* N is the CPU ID. System CTIs will have the name cti_sys<I> where I
@@ -129,6 +135,35 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
return rc;
}
+/* re-enable CTI on CPU when using CPU hotplug */
+static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
+{
+ struct cti_config *config = &drvdata->config;
+ struct device *dev = &drvdata->csdev->dev;
+
+ pm_runtime_get_sync(dev->parent);
+ spin_lock(&drvdata->spinlock);
+ config->hw_powered = true;
+
+ /* no need to do anything if no enable request */
+ if (!atomic_read(&drvdata->config.enable_req_count))
+ goto cti_hp_not_enabled;
+
+ /* try to claim the device */
+ if (coresight_claim_device(drvdata->base))
+ goto cti_hp_not_enabled;
+
+ cti_write_all_hw_regs(drvdata);
+ config->hw_enabled = true;
+ spin_unlock(&drvdata->spinlock);
+ return;
+
+ /* did not re-enable due to no claim / no request */
+cti_hp_not_enabled:
+ spin_unlock(&drvdata->spinlock);
+ pm_runtime_put(dev->parent);
+}
+
/* disable hardware */
static int cti_disable_hw(struct cti_drvdata *drvdata)
{
@@ -620,6 +655,44 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
}
}
+/* CPU HP handlers */
+static int cti_starting_cpu(unsigned int cpu)
+{
+ struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
+
+ if (!drvdata)
+ return 0;
+
+ cti_cpuhp_enable_hw(drvdata);
+ return 0;
+}
+
+static int cti_dying_cpu(unsigned int cpu)
+{
+ struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
+
+ if (!drvdata)
+ return 0;
+
+ spin_lock(&drvdata->spinlock);
+ drvdata->config.hw_powered = false;
+ coresight_disclaim_device(drvdata->base);
+ spin_unlock(&drvdata->spinlock);
+ return 0;
+}
+
+/* release PM registrations */
+static void cti_pm_release(struct cti_drvdata *drvdata)
+{
+ if (drvdata->ctidev.cpu >= 0) {
+ if (--nr_cti_cpu == 0) {
+ cpuhp_remove_state_nocalls(
+ CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
+ }
+ cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;
+ }
+}
+
/** cti ect operations **/
int cti_enable(struct coresight_device *csdev)
{
@@ -655,6 +728,7 @@ static void cti_device_release(struct device *dev)
mutex_lock(&ect_mutex);
cti_remove_conn_xrefs(drvdata);
+ cti_pm_release(drvdata);
/* remove from the list */
list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) {
@@ -730,6 +804,22 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
goto err_out;
}
+ /* setup CPU power management handling for CPU bound CTI devices. */
+ if (drvdata->ctidev.cpu >= 0) {
+ cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;
+ if (!nr_cti_cpu++) {
+ cpus_read_lock();
+ cpuhp_setup_state_nocalls_cpuslocked(
+ CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
+ "arm/coresight_cti:starting",
+ cti_starting_cpu, cti_dying_cpu);
+
+ cpus_read_unlock();
+ if (ret)
+ goto err_out;
+ }
+ }
+
/* create dynamic attributes for connections */
ret = cti_create_cons_sysfs(dev, drvdata);
if (ret) {
@@ -768,6 +858,7 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
return 0;
err_out:
+ cti_pm_release(drvdata);
return ret;
}
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 77d70b633531..6dc7332307ca 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -142,6 +142,7 @@ enum cpuhp_state {
CPUHP_AP_ARM_XEN_STARTING,
CPUHP_AP_ARM_KVMPV_STARTING,
CPUHP_AP_ARM_CORESIGHT_STARTING,
+ CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
CPUHP_AP_ARM64_ISNDEP_STARTING,
CPUHP_AP_SMPCFD_DYING,
CPUHP_AP_X86_TBOOT_DYING,
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices.
2020-05-04 16:15 [PATCH v2 0/2] Add CPU power management for CPU bound CTI devices Mike Leach
2020-05-04 16:15 ` [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver Mike Leach
@ 2020-05-04 16:15 ` Mike Leach
2020-05-06 18:02 ` Mathieu Poirier
1 sibling, 1 reply; 5+ messages in thread
From: Mike Leach @ 2020-05-04 16:15 UTC (permalink / raw)
To: linux-arm-kernel, coresight, mathieu.poirier; +Cc: Mike Leach, suzuki.poulose
Adds a notify callback for CPU PM events to the CTI driver - for
CPU bound CTI devices.
Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
drivers/hwtracing/coresight/coresight-cti.c | 82 +++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
index 9af66719ae5b..0f0c14528701 100644
--- a/drivers/hwtracing/coresight/coresight-cti.c
+++ b/drivers/hwtracing/coresight/coresight-cti.c
@@ -8,6 +8,7 @@
#include <linux/atomic.h>
#include <linux/bits.h>
#include <linux/coresight.h>
+#include <linux/cpu_pm.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/kernel.h>
@@ -655,6 +656,84 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
}
}
+/** cti PM callbacks **/
+static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
+ void *v)
+{
+ struct cti_drvdata *drvdata;
+ unsigned int cpu = smp_processor_id();
+ int notify_res = NOTIFY_OK;
+
+ if (!cti_cpu_drvdata[cpu])
+ return NOTIFY_OK;
+
+ drvdata = cti_cpu_drvdata[cpu];
+
+ if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
+ return NOTIFY_BAD;
+
+ spin_lock(&drvdata->spinlock);
+
+ switch (cmd) {
+ case CPU_PM_ENTER:
+ /* CTI regs all static - we have a copy & nothing to save */
+ drvdata->config.hw_powered = false;
+ if (drvdata->config.hw_enabled)
+ coresight_disclaim_device(drvdata->base);
+ break;
+
+ case CPU_PM_ENTER_FAILED:
+ drvdata->config.hw_powered = true;
+ if (drvdata->config.hw_enabled) {
+ if (coresight_claim_device(drvdata->base))
+ drvdata->config.hw_enabled = false;
+ }
+ break;
+
+ case CPU_PM_EXIT:
+ /* write hardware registers to re-enable. */
+ drvdata->config.hw_powered = true;
+ drvdata->config.hw_enabled = false;
+
+ /* check enable reference count to enable HW */
+ if (atomic_read(&drvdata->config.enable_req_count)) {
+ /* check we can claim the device as we re-power */
+ if (coresight_claim_device(drvdata->base))
+ goto cti_notify_exit;
+
+ drvdata->config.hw_enabled = true;
+ cti_write_all_hw_regs(drvdata);
+ }
+ break;
+
+ default:
+ notify_res = NOTIFY_DONE;
+ break;
+ }
+
+cti_notify_exit:
+ spin_unlock(&drvdata->spinlock);
+ return notify_res;
+}
+
+static struct notifier_block cti_cpu_pm_nb = {
+ .notifier_call = cti_cpu_pm_notify,
+};
+
+static int cti_cpu_pm_register(void)
+{
+ if (IS_ENABLED(CONFIG_CPU_PM))
+ return cpu_pm_register_notifier(&cti_cpu_pm_nb);
+
+ return 0;
+}
+
+static void cti_cpu_pm_unregister(void)
+{
+ if (IS_ENABLED(CONFIG_CPU_PM))
+ cpu_pm_unregister_notifier(&cti_cpu_pm_nb);
+}
+
/* CPU HP handlers */
static int cti_starting_cpu(unsigned int cpu)
{
@@ -686,6 +765,8 @@ static void cti_pm_release(struct cti_drvdata *drvdata)
{
if (drvdata->ctidev.cpu >= 0) {
if (--nr_cti_cpu == 0) {
+ cti_cpu_pm_unregister();
+
cpuhp_remove_state_nocalls(
CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
}
@@ -814,6 +895,7 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
"arm/coresight_cti:starting",
cti_starting_cpu, cti_dying_cpu);
+ ret = cti_cpu_pm_register();
cpus_read_unlock();
if (ret)
goto err_out;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver.
2020-05-04 16:15 ` [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver Mike Leach
@ 2020-05-06 17:39 ` Mathieu Poirier
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Poirier @ 2020-05-06 17:39 UTC (permalink / raw)
To: Mike Leach; +Cc: coresight, linux-arm-kernel, suzuki.poulose
Hi Mike,
On Mon, May 04, 2020 at 05:15:29PM +0100, Mike Leach wrote:
> Adds registration of CPU start and stop functions to CPU hotplug
> mechanisms - for any CPU bound CTI.
>
> Sets CTI powered flag according to state.
> Will enable CTI on CPU start if there are existing enable requests.
>
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
> drivers/hwtracing/coresight/coresight-cti.c | 91 +++++++++++++++++++++
> include/linux/cpuhotplug.h | 1 +
> 2 files changed, 92 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
> index be61c1705916..9af66719ae5b 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.c
> +++ b/drivers/hwtracing/coresight/coresight-cti.c
> @@ -40,6 +40,12 @@ static DEFINE_MUTEX(ect_mutex);
> #define csdev_to_cti_drvdata(csdev) \
> dev_get_drvdata(csdev->dev.parent)
>
> +/* power management handling */
> +static int nr_cti_cpu;
> +
> +/* quick lookup list for CPU bound CTIs when power handling */
> +static struct cti_drvdata *cti_cpu_drvdata[NR_CPUS];
> +
> /*
> * CTI naming. CTI bound to cores will have the name cti_cpu<N> where
> * N is the CPU ID. System CTIs will have the name cti_sys<I> where I
> @@ -129,6 +135,35 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
> return rc;
> }
>
> +/* re-enable CTI on CPU when using CPU hotplug */
> +static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
> +{
> + struct cti_config *config = &drvdata->config;
> + struct device *dev = &drvdata->csdev->dev;
> +
> + pm_runtime_get_sync(dev->parent);
> + spin_lock(&drvdata->spinlock);
> + config->hw_powered = true;
> +
> + /* no need to do anything if no enable request */
> + if (!atomic_read(&drvdata->config.enable_req_count))
> + goto cti_hp_not_enabled;
> +
> + /* try to claim the device */
> + if (coresight_claim_device(drvdata->base))
> + goto cti_hp_not_enabled;
> +
> + cti_write_all_hw_regs(drvdata);
> + config->hw_enabled = true;
> + spin_unlock(&drvdata->spinlock);
> + return;
> +
> + /* did not re-enable due to no claim / no request */
> +cti_hp_not_enabled:
> + spin_unlock(&drvdata->spinlock);
> + pm_runtime_put(dev->parent);
> +}
> +
> /* disable hardware */
> static int cti_disable_hw(struct cti_drvdata *drvdata)
> {
> @@ -620,6 +655,44 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
> }
> }
>
> +/* CPU HP handlers */
> +static int cti_starting_cpu(unsigned int cpu)
> +{
> + struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
> +
> + if (!drvdata)
> + return 0;
> +
> + cti_cpuhp_enable_hw(drvdata);
> + return 0;
> +}
> +
> +static int cti_dying_cpu(unsigned int cpu)
> +{
> + struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
> +
> + if (!drvdata)
> + return 0;
> +
> + spin_lock(&drvdata->spinlock);
> + drvdata->config.hw_powered = false;
> + coresight_disclaim_device(drvdata->base);
> + spin_unlock(&drvdata->spinlock);
> + return 0;
> +}
> +
> +/* release PM registrations */
> +static void cti_pm_release(struct cti_drvdata *drvdata)
> +{
> + if (drvdata->ctidev.cpu >= 0) {
> + if (--nr_cti_cpu == 0) {
> + cpuhp_remove_state_nocalls(
> + CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
> + }
> + cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;
> + }
> +}
> +
> /** cti ect operations **/
> int cti_enable(struct coresight_device *csdev)
> {
> @@ -655,6 +728,7 @@ static void cti_device_release(struct device *dev)
>
> mutex_lock(&ect_mutex);
> cti_remove_conn_xrefs(drvdata);
> + cti_pm_release(drvdata);
>
> /* remove from the list */
> list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) {
> @@ -730,6 +804,22 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
> goto err_out;
> }
>
> + /* setup CPU power management handling for CPU bound CTI devices. */
> + if (drvdata->ctidev.cpu >= 0) {
> + cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;
> + if (!nr_cti_cpu++) {
> + cpus_read_lock();
> + cpuhp_setup_state_nocalls_cpuslocked(
ret = cpuhp_setup_state_nocalls_cpuslocked(
Otherwise this patch looks good to me (many thanks for splitting). On your next
revision please CC Thomas Gleixner as suggested by the get_maintainer.pl script.
Mathieu
> + CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
> + "arm/coresight_cti:starting",
> + cti_starting_cpu, cti_dying_cpu);
> +
> + cpus_read_unlock();
> + if (ret)
> + goto err_out;
> + }
> + }
> +
> /* create dynamic attributes for connections */
> ret = cti_create_cons_sysfs(dev, drvdata);
> if (ret) {
> @@ -768,6 +858,7 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
> return 0;
>
> err_out:
> + cti_pm_release(drvdata);
> return ret;
> }
>
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 77d70b633531..6dc7332307ca 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -142,6 +142,7 @@ enum cpuhp_state {
> CPUHP_AP_ARM_XEN_STARTING,
> CPUHP_AP_ARM_KVMPV_STARTING,
> CPUHP_AP_ARM_CORESIGHT_STARTING,
> + CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
> CPUHP_AP_ARM64_ISNDEP_STARTING,
> CPUHP_AP_SMPCFD_DYING,
> CPUHP_AP_X86_TBOOT_DYING,
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices.
2020-05-04 16:15 ` [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices Mike Leach
@ 2020-05-06 18:02 ` Mathieu Poirier
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Poirier @ 2020-05-06 18:02 UTC (permalink / raw)
To: Mike Leach; +Cc: coresight, linux-arm-kernel, suzuki.poulose
On Mon, May 04, 2020 at 05:15:30PM +0100, Mike Leach wrote:
> Adds a notify callback for CPU PM events to the CTI driver - for
> CPU bound CTI devices.
>
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
> drivers/hwtracing/coresight/coresight-cti.c | 82 +++++++++++++++++++++
> 1 file changed, 82 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
> index 9af66719ae5b..0f0c14528701 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.c
> +++ b/drivers/hwtracing/coresight/coresight-cti.c
> @@ -8,6 +8,7 @@
> #include <linux/atomic.h>
> #include <linux/bits.h>
> #include <linux/coresight.h>
> +#include <linux/cpu_pm.h>
> #include <linux/device.h>
> #include <linux/io.h>
> #include <linux/kernel.h>
> @@ -655,6 +656,84 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
> }
> }
>
> +/** cti PM callbacks **/
> +static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
> + void *v)
> +{
> + struct cti_drvdata *drvdata;
> + unsigned int cpu = smp_processor_id();
> + int notify_res = NOTIFY_OK;
> +
> + if (!cti_cpu_drvdata[cpu])
> + return NOTIFY_OK;
> +
> + drvdata = cti_cpu_drvdata[cpu];
> +
> + if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
> + return NOTIFY_BAD;
> +
> + spin_lock(&drvdata->spinlock);
> +
> + switch (cmd) {
> + case CPU_PM_ENTER:
> + /* CTI regs all static - we have a copy & nothing to save */
> + drvdata->config.hw_powered = false;
> + if (drvdata->config.hw_enabled)
> + coresight_disclaim_device(drvdata->base);
> + break;
> +
> + case CPU_PM_ENTER_FAILED:
> + drvdata->config.hw_powered = true;
> + if (drvdata->config.hw_enabled) {
> + if (coresight_claim_device(drvdata->base))
> + drvdata->config.hw_enabled = false;
> + }
> + break;
> +
> + case CPU_PM_EXIT:
> + /* write hardware registers to re-enable. */
> + drvdata->config.hw_powered = true;
> + drvdata->config.hw_enabled = false;
> +
> + /* check enable reference count to enable HW */
> + if (atomic_read(&drvdata->config.enable_req_count)) {
> + /* check we can claim the device as we re-power */
> + if (coresight_claim_device(drvdata->base))
> + goto cti_notify_exit;
> +
> + drvdata->config.hw_enabled = true;
> + cti_write_all_hw_regs(drvdata);
> + }
> + break;
> +
> + default:
> + notify_res = NOTIFY_DONE;
> + break;
> + }
> +
> +cti_notify_exit:
> + spin_unlock(&drvdata->spinlock);
> + return notify_res;
> +}
> +
> +static struct notifier_block cti_cpu_pm_nb = {
> + .notifier_call = cti_cpu_pm_notify,
> +};
> +
> +static int cti_cpu_pm_register(void)
> +{
> + if (IS_ENABLED(CONFIG_CPU_PM))
> + return cpu_pm_register_notifier(&cti_cpu_pm_nb);
Looking further into function cpu_pm_register_notifier(), it simply returns '0'
if CONFIG_CPU_PM is not defined. As such cpu_pm_register_notifier() can be
called directly from cti_probe(). The same applies to
cpu_pm_unregister_notifier().
> +
> + return 0;
> +}
> +
> +static void cti_cpu_pm_unregister(void)
> +{
> + if (IS_ENABLED(CONFIG_CPU_PM))
> + cpu_pm_unregister_notifier(&cti_cpu_pm_nb);
> +}
> +
> /* CPU HP handlers */
> static int cti_starting_cpu(unsigned int cpu)
> {
> @@ -686,6 +765,8 @@ static void cti_pm_release(struct cti_drvdata *drvdata)
> {
> if (drvdata->ctidev.cpu >= 0) {
> if (--nr_cti_cpu == 0) {
> + cti_cpu_pm_unregister();
> +
> cpuhp_remove_state_nocalls(
> CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
> }
> @@ -814,6 +895,7 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
> "arm/coresight_cti:starting",
> cti_starting_cpu, cti_dying_cpu);
>
> + ret = cti_cpu_pm_register();
This should be one only if cpuhp_remove_state_nocalls() hasn't returned an
error.
Otherwise this looks good.
Thanks,
Mathieu
> cpus_read_unlock();
> if (ret)
> goto err_out;
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-06 18:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 16:15 [PATCH v2 0/2] Add CPU power management for CPU bound CTI devices Mike Leach
2020-05-04 16:15 ` [PATCH v2 1/2] coresight: cti: Add CPU Hotplug handling to CTI driver Mike Leach
2020-05-06 17:39 ` Mathieu Poirier
2020-05-04 16:15 ` [PATCH v2 2/2] coresight: cti: Add CPU idle pm notifer to CTI devices Mike Leach
2020-05-06 18:02 ` Mathieu Poirier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).