[PATCH v1] coresight: Check runtime PM resume result

Yuho Choi posted 1 patch 2 months ago
There is a newer version of this series
drivers/hwtracing/coresight/coresight-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH v1] coresight: Check runtime PM resume result
Posted by Yuho Choi 2 months ago
coresight_get_ref() ignores the return value of pm_runtime_get_sync()
and reports success even when runtime resume fails. A path is then built
and the CoreSight device may be accessed while it remains powered off.

Use pm_runtime_resume_and_get() so a failed resume is reported and its
runtime PM usage reference is rolled back. Drop the module and device
references acquired before the resume attempt when it fails.

Fixes: 5da5325fa856 ("coresight: moving PM runtime operations to core framework")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/hwtracing/coresight/coresight-core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 6d65c43d574f..77d05b360484 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -843,7 +843,11 @@ static bool coresight_get_ref(struct coresight_device *csdev)
 		goto err_module;
 
 	/* Make sure the device is powered on */
-	pm_runtime_get_sync(parent);
+	if (pm_runtime_resume_and_get(parent) < 0) {
+		module_put(drv->owner);
+		goto err_module;
+	}
+
 	return true;
 
 err_module:
-- 
2.43.0
Re: [PATCH v1] coresight: Check runtime PM resume result
Posted by Anshuman Khandual 2 months ago

On 03/08/26 4:55 AM, Yuho Choi wrote:
> coresight_get_ref() ignores the return value of pm_runtime_get_sync()
> and reports success even when runtime resume fails. A path is then built
> and the CoreSight device may be accessed while it remains powered off.
> 
> Use pm_runtime_resume_and_get() so a failed resume is reported and its
> runtime PM usage reference is rolled back. Drop the module and device
> references acquired before the resume attempt when it fails.
> 
> Fixes: 5da5325fa856 ("coresight: moving PM runtime operations to core framework")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---

Should 'Fixes:' be tagging the following commit - which had introduced
coresight_get_ref() unconditionally calling pm_runtime_get_sync() ?

32b0707a4182 ("coresight: Add try_get_module() in coresight_grab_device()")

>  drivers/hwtracing/coresight/coresight-core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 6d65c43d574f..77d05b360484 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -843,7 +843,11 @@ static bool coresight_get_ref(struct coresight_device *csdev)
>  		goto err_module;
>  
>  	/* Make sure the device is powered on */
> -	pm_runtime_get_sync(parent);
> +	if (pm_runtime_resume_and_get(parent) < 0) {
> +		module_put(drv->owner);
> +		goto err_module;
> +	}
> +
>  	return true;
>  
>  err_module: