Re: [PATCH] thermal: sysfs: fall back to vzalloc for cooling device's statistics

From: Yue Hu
Date: Thu Aug 27 2020 - 02:40:17 EST


On Thu, 27 Aug 2020 11:56:46 +0530
Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:

> On 27-08-20, 14:20, Yue Hu wrote:
> > Currenly, drivers/video/backlight does not call thermal_of_cooling_device_register()
> > to register thermal cooling device. The issue happened in msm-4.19 kernel for
> > QCOM/Android platform. Backlight in msm-4.19 kernel will register thermal cooling
> > device as below:
> >
> > +static int bd_cdev_get_max_brightness(struct thermal_cooling_device *cdev,
> > + unsigned long *state)
> > +{
> > + struct backlight_device *bd = (struct backlight_device *)cdev->devdata;
> > +
> > + *state = bd->props.max_brightness;
> > +
> > + return 0;
> > +}
> >
> >
> > +static struct thermal_cooling_device_ops bd_cdev_ops = {
> > + .get_max_state = bd_cdev_get_max_brightness,
> >
> > +static void backlight_cdev_register(struct device *parent,
> > + struct backlight_device *bd)
> > +{
> > + if (of_find_property(parent->of_node, "#cooling-cells", NULL)) {
> > + bd->cdev = thermal_of_cooling_device_register(parent->of_node,
> > + (char *)dev_name(&bd->dev), bd, &bd_cdev_ops);
> >
> > And the bd->props.max_brightness is getting from video/backlight/qcom-wled.c. Maybe
> > the driver should not assign 1024 to states/max_brightness. I'm not sure about it.
> > So i consider to change memory allocation methord. That's the origin of the patch.
>
> Thanks for the details. So this is not about upstream tree, as a rule
> we aren't going to make changes here for any downstream tree.

I at first thought it's a possible issue in upstream tree.

>
> Now coming back to the downstream driver, I also don't see a point in
> returning bd->props.max_brightness as the max number of states there.
> Maybe have 10 states, each occupying bd->props.max_brightness/10
> brightness and so you will end up with 10 states only. But yeah,
> whatever downstream decides on that.
>

Got it.

Thx.