mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power()
@ 2024-11-04 11:36 Jinjie Ruan
  2024-11-04 12:58 ` Lukasz Luba
  2024-11-07  1:50 ` Jinjie Ruan
  0 siblings, 2 replies; 5+ messages in thread
From: Jinjie Ruan @ 2024-11-04 11:36 UTC (permalink / raw)
  To: rafael, viresh.kumar, matthias.bgg, angelogioacchino.delregno,
	hector.yuan, lukasz.luba, qperret, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek
  Cc: ruanjinjie

mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in
em_create_perf_table(), the later zero check for power is not invalid
as power is uninitialized. As Lukasz suggested, it must return -EINVAL when
the 'policy' is not found. So return -EINVAL to fix it.

Cc: stable@vger.kernel.org
Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
Suggested-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Fix the driver instead of em_create_perf_table() as suggested.
- Update the commit message.
- Add Suggested-by.
---
 drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
index 8925e096d5b9..aeb5e6304542 100644
--- a/drivers/cpufreq/mediatek-cpufreq-hw.c
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW,
 
 	policy = cpufreq_cpu_get_raw(cpu_dev->id);
 	if (!policy)
-		return 0;
+		return -EINVAL;
 
 	data = policy->driver_data;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power()
  2024-11-04 11:36 [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power() Jinjie Ruan
@ 2024-11-04 12:58 ` Lukasz Luba
  2024-11-07  1:50 ` Jinjie Ruan
  1 sibling, 0 replies; 5+ messages in thread
From: Lukasz Luba @ 2024-11-04 12:58 UTC (permalink / raw)
  To: Jinjie Ruan, rafael, viresh.kumar, matthias.bgg,
	angelogioacchino.delregno, hector.yuan, qperret, linux-pm,
	linux-kernel, linux-arm-kernel, linux-mediatek



On 11/4/24 11:36, Jinjie Ruan wrote:
> mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in
> em_create_perf_table(), the later zero check for power is not invalid
> as power is uninitialized. As Lukasz suggested, it must return -EINVAL when
> the 'policy' is not found. So return -EINVAL to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> Suggested-by: Lukasz Luba <lukasz.luba@arm.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Fix the driver instead of em_create_perf_table() as suggested.
> - Update the commit message.
> - Add Suggested-by.
> ---
>   drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> index 8925e096d5b9..aeb5e6304542 100644
> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> @@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW,
>   
>   	policy = cpufreq_cpu_get_raw(cpu_dev->id);
>   	if (!policy)
> -		return 0;
> +		return -EINVAL;
>   
>   	data = policy->driver_data;
>   

LGTM,

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power()
  2024-11-04 11:36 [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power() Jinjie Ruan
  2024-11-04 12:58 ` Lukasz Luba
@ 2024-11-07  1:50 ` Jinjie Ruan
  2024-11-07 10:58   ` Rafael J. Wysocki
  1 sibling, 1 reply; 5+ messages in thread
From: Jinjie Ruan @ 2024-11-07  1:50 UTC (permalink / raw)
  To: rafael, viresh.kumar, matthias.bgg, angelogioacchino.delregno,
	hector.yuan, lukasz.luba, qperret, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek



On 2024/11/4 19:36, Jinjie Ruan wrote:
> mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in
> em_create_perf_table(), the later zero check for power is not invalid
> as power is uninitialized. As Lukasz suggested, it must return -EINVAL when
> the 'policy' is not found. So return -EINVAL to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> Suggested-by: Lukasz Luba <lukasz.luba@arm.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

Hi, could this be merged.

> ---
> v2:
> - Fix the driver instead of em_create_perf_table() as suggested.
> - Update the commit message.
> - Add Suggested-by.
> ---
>  drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> index 8925e096d5b9..aeb5e6304542 100644
> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> @@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW,
>  
>  	policy = cpufreq_cpu_get_raw(cpu_dev->id);
>  	if (!policy)
> -		return 0;
> +		return -EINVAL;
>  
>  	data = policy->driver_data;
>  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power()
  2024-11-07  1:50 ` Jinjie Ruan
@ 2024-11-07 10:58   ` Rafael J. Wysocki
  2024-11-07 11:14     ` Jinjie Ruan
  0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2024-11-07 10:58 UTC (permalink / raw)
  To: Jinjie Ruan, viresh.kumar
  Cc: rafael, matthias.bgg, angelogioacchino.delregno, hector.yuan,
	lukasz.luba, qperret, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek

On Thu, Nov 7, 2024 at 2:50 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>
>
>
> On 2024/11/4 19:36, Jinjie Ruan wrote:
> > mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in
> > em_create_perf_table(), the later zero check for power is not invalid
> > as power is uninitialized. As Lukasz suggested, it must return -EINVAL when
> > the 'policy' is not found. So return -EINVAL to fix it.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> > Suggested-by: Lukasz Luba <lukasz.luba@arm.com>
> > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> Hi, could this be merged.

It's for Viresh to take care of and please replace the "PM: EM:"
prefix in the subject with the proper cpufreq driver one.

Thanks!

> > ---
> > v2:
> > - Fix the driver instead of em_create_perf_table() as suggested.
> > - Update the commit message.
> > - Add Suggested-by.
> > ---
> >  drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> > index 8925e096d5b9..aeb5e6304542 100644
> > --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> > +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> > @@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW,
> >
> >       policy = cpufreq_cpu_get_raw(cpu_dev->id);
> >       if (!policy)
> > -             return 0;
> > +             return -EINVAL;
> >
> >       data = policy->driver_data;
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power()
  2024-11-07 10:58   ` Rafael J. Wysocki
@ 2024-11-07 11:14     ` Jinjie Ruan
  0 siblings, 0 replies; 5+ messages in thread
From: Jinjie Ruan @ 2024-11-07 11:14 UTC (permalink / raw)
  To: Rafael J. Wysocki, viresh.kumar
  Cc: matthias.bgg, angelogioacchino.delregno, hector.yuan,
	lukasz.luba, qperret, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek



On 2024/11/7 18:58, Rafael J. Wysocki wrote:
> On Thu, Nov 7, 2024 at 2:50 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>>
>>
>>
>> On 2024/11/4 19:36, Jinjie Ruan wrote:
>>> mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in
>>> em_create_perf_table(), the later zero check for power is not invalid
>>> as power is uninitialized. As Lukasz suggested, it must return -EINVAL when
>>> the 'policy' is not found. So return -EINVAL to fix it.
>>>
>>> Cc: stable@vger.kernel.org
>>> Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
>>> Suggested-by: Lukasz Luba <lukasz.luba@arm.com>
>>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>>
>> Hi, could this be merged.
> 
> It's for Viresh to take care of and please replace the "PM: EM:"
> prefix in the subject with the proper cpufreq driver one.

Thank you for your kind reminder.

> 
> Thanks!
> 
>>> ---
>>> v2:
>>> - Fix the driver instead of em_create_perf_table() as suggested.
>>> - Update the commit message.
>>> - Add Suggested-by.
>>> ---
>>>  drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
>>> index 8925e096d5b9..aeb5e6304542 100644
>>> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
>>> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
>>> @@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW,
>>>
>>>       policy = cpufreq_cpu_get_raw(cpu_dev->id);
>>>       if (!policy)
>>> -             return 0;
>>> +             return -EINVAL;
>>>
>>>       data = policy->driver_data;
>>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-07 11:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-04 11:36 [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power() Jinjie Ruan
2024-11-04 12:58 ` Lukasz Luba
2024-11-07  1:50 ` Jinjie Ruan
2024-11-07 10:58   ` Rafael J. Wysocki
2024-11-07 11:14     ` Jinjie Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®