* [PATCH] PM: EM: Force device drivers to provide power in uW
@ 2024-03-08 12:32 Lukasz Luba
2024-03-13 19:49 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Luba @ 2024-03-08 12:32 UTC (permalink / raw)
To: linux-kernel, linux-pm, rafael; +Cc: lukasz.luba, poshao.chen
The EM only supports power in uW. Make sure that it is not possible to
register some downstream driver which doesn't provide power in uW.
The only exception is artificial EM, but that EM is ignored by the rest of
kernel frameworks (thermal, powercap, etc).
Reported-by: PoShao Chen <poshao.chen@mediatek.com>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
Hi all,
The was an issue reported recently that the EM could be used with
not aligned drivers which provide milli-Watts. This patch prevents such
drivers to register EM (although there are no such in upstream).
Regards,
Lukasz
kernel/power/energy_model.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index b686ac0345bd9..9e1c9aa399ea9 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
else if (cb->get_cost)
flags |= EM_PERF_DOMAIN_ARTIFICIAL;
+ /*
+ * EM only supports uW (exception is artificial EM).
+ * Therefore, check and force the drivers to provide
+ * power in uW.
+ */
+ if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
+ dev_err(dev, "EM: only supports uW power values\n");
+ ret = -EINVAL;
+ goto unlock;
+ }
+
ret = em_create_pd(dev, nr_states, cb, cpus, flags);
if (ret)
goto unlock;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] PM: EM: Force device drivers to provide power in uW
2024-03-08 12:32 [PATCH] PM: EM: Force device drivers to provide power in uW Lukasz Luba
@ 2024-03-13 19:49 ` Rafael J. Wysocki
2024-03-14 11:57 ` Lukasz Luba
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2024-03-13 19:49 UTC (permalink / raw)
To: Lukasz Luba; +Cc: linux-kernel, linux-pm, rafael, poshao.chen
On Fri, Mar 8, 2024 at 1:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
> The EM only supports power in uW. Make sure that it is not possible to
> register some downstream driver which doesn't provide power in uW.
> The only exception is artificial EM, but that EM is ignored by the rest of
> kernel frameworks (thermal, powercap, etc).
>
> Reported-by: PoShao Chen <poshao.chen@mediatek.com>
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>
> Hi all,
>
> The was an issue reported recently that the EM could be used with
> not aligned drivers which provide milli-Watts. This patch prevents such
> drivers to register EM (although there are no such in upstream).
>
> Regards,
> Lukasz
>
> kernel/power/energy_model.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index b686ac0345bd9..9e1c9aa399ea9 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
> else if (cb->get_cost)
> flags |= EM_PERF_DOMAIN_ARTIFICIAL;
>
> + /*
> + * EM only supports uW (exception is artificial EM).
> + * Therefore, check and force the drivers to provide
> + * power in uW.
> + */
> + if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
> + dev_err(dev, "EM: only supports uW power values\n");
> + ret = -EINVAL;
> + goto unlock;
> + }
> +
> ret = em_create_pd(dev, nr_states, cb, cpus, flags);
> if (ret)
> goto unlock;
> --
Applied as 6.9-rc material, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] PM: EM: Force device drivers to provide power in uW
2024-03-13 19:49 ` Rafael J. Wysocki
@ 2024-03-14 11:57 ` Lukasz Luba
0 siblings, 0 replies; 3+ messages in thread
From: Lukasz Luba @ 2024-03-14 11:57 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-kernel, linux-pm, poshao.chen
On 3/13/24 19:49, Rafael J. Wysocki wrote:
> On Fri, Mar 8, 2024 at 1:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote:
>>
>> The EM only supports power in uW. Make sure that it is not possible to
>> register some downstream driver which doesn't provide power in uW.
>> The only exception is artificial EM, but that EM is ignored by the rest of
>> kernel frameworks (thermal, powercap, etc).
>>
>> Reported-by: PoShao Chen <poshao.chen@mediatek.com>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>
>> Hi all,
>>
>> The was an issue reported recently that the EM could be used with
>> not aligned drivers which provide milli-Watts. This patch prevents such
>> drivers to register EM (although there are no such in upstream).
>>
>> Regards,
>> Lukasz
>>
>> kernel/power/energy_model.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
>> index b686ac0345bd9..9e1c9aa399ea9 100644
>> --- a/kernel/power/energy_model.c
>> +++ b/kernel/power/energy_model.c
>> @@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
>> else if (cb->get_cost)
>> flags |= EM_PERF_DOMAIN_ARTIFICIAL;
>>
>> + /*
>> + * EM only supports uW (exception is artificial EM).
>> + * Therefore, check and force the drivers to provide
>> + * power in uW.
>> + */
>> + if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
>> + dev_err(dev, "EM: only supports uW power values\n");
>> + ret = -EINVAL;
>> + goto unlock;
>> + }
>> +
>> ret = em_create_pd(dev, nr_states, cb, cpus, flags);
>> if (ret)
>> goto unlock;
>> --
>
> Applied as 6.9-rc material, thanks!
Thank you Rafael!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-14 11:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 12:32 [PATCH] PM: EM: Force device drivers to provide power in uW Lukasz Luba
2024-03-13 19:49 ` Rafael J. Wysocki
2024-03-14 11:57 ` Lukasz Luba
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®