[PATCH] devfreq: Register devfreq as a cooling device

Daniel Lezcano daniel.lezcano at linaro.org
Thu Mar 4 16:54:26 UTC 2021


On 04/03/2021 16:06, Chanwoo Choi wrote:
> Hi Daniel,
> 
> As Lukasz's comment, actually some devfreq devices like memory bus
> might not affect the thermal critically. In the mainline,
> there are four types devfreq as following:
> 1. GPU
> 2. UFS Storage
> 3. DMC (Memory Controller)
> 4. Memory bus like AMBA AXI
> 
> I think that you can specify this devfreq device will be used
> for cooling device by editing the devfreq_dev_profile structure.

Thanks for the suggestion, it makes sense.

I will do the change following your example below.

  -- Daniel

> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index bf3047896e41..77966a17d03f 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -935,6 +935,13 @@ struct devfreq *devfreq_add_device(struct device *dev,
> 
>         mutex_unlock(&devfreq_list_lock);
> 
> +       if (devfreq->profile->is_cooling_device) {
> +               devfreq->cdev = devfreq_cooling_em_register(devfreq, NULL);
> +               if (IS_ERR(devfreq->cdev))
> +                       dev_info(dev,
> +                               "Failed to register devfreq cooling
> device\n");
> +       }
> +
>         return devfreq;
> 
>  err_init:
> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
> index 26ea0850be9b..26dc69f1047b 100644
> --- a/include/linux/devfreq.h
> +++ b/include/linux/devfreq.h
> @@ -103,6 +103,7 @@ struct devfreq_dev_profile {
>         unsigned long initial_freq;
>         unsigned int polling_ms;
>         enum devfreq_timer timer;
> +       bool is_cooling_device;
> 
>         int (*target)(struct device *dev, unsigned long *freq, u32 flags);
>         int (*get_dev_status)(struct device *dev,
> 



-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


More information about the dri-devel mailing list