diff mbox series

[07/15] drm/panfrost: use device_property_present to check for OPP

Message ID 20200510165538.19720-8-peron.clem@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add regulator devfreq support to Panfrost | expand

Commit Message

Clément Péron May 10, 2020, 4:55 p.m. UTC
Instead of expecting an error from dev_pm_opp_of_add_table()
do a simple device_property_present() check.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Steven Price May 28, 2020, 1:22 p.m. UTC | #1
On 10/05/2020 17:55, Clément Péron wrote:
> Instead of expecting an error from dev_pm_opp_of_add_table()
> do a simple device_property_present() check.
> 
> Signed-off-by: Clément Péron <peron.clem@gmail.com>

I'm not sure I understand why this is better. We seem to have more code 
to do roughly the same thing just with the hard-coded 
"operating-points-v2" name (if there's ever a 'v3' we'll then have to 
update this).

Is the desire just to get an error on probe if the table is malformed? 
Have you hit this situation? If so this sounds like something which 
would be better fixed in the generic OPP code rather than Panfrost itself.

Steve

> ---
>   drivers/gpu/drm/panfrost/panfrost_devfreq.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index d9007f44b772..fce21c682414 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -96,15 +96,19 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>   	struct thermal_cooling_device *cooling;
>   	struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
>   
> -	ret = dev_pm_opp_of_add_table(dev);
> -	if (ret == -ENODEV) /* Optional, continue without devfreq */
> +	if (!device_property_present(dev, "operating-points-v2"))
> +		/* Optional, continue without devfreq */
>   		return 0;
> -	else if (ret)
> -		return ret;
> -	pfdevfreq->opp_of_table_added = true;
>   
>   	spin_lock_init(&pfdevfreq->lock);
>   
> +	ret = dev_pm_opp_of_add_table(dev);
> +	if (ret) {
> +		DRM_DEV_ERROR(dev, "Couldn't add OPP table\n");
> +		goto err_fini;
> +	}
> +	pfdevfreq->opp_of_table_added = true;
> +
>   	panfrost_devfreq_reset(pfdevfreq);
>   
>   	cur_freq = clk_get_rate(pfdev->clock);
>
Clément Péron May 29, 2020, 12:45 p.m. UTC | #2
Hi Steven,

On Thu, 28 May 2020 at 15:22, Steven Price <steven.price@arm.com> wrote:
>
> On 10/05/2020 17:55, Clément Péron wrote:
> > Instead of expecting an error from dev_pm_opp_of_add_table()
> > do a simple device_property_present() check.
> >
> > Signed-off-by: Clément Péron <peron.clem@gmail.com>
>
> I'm not sure I understand why this is better. We seem to have more code
> to do roughly the same thing just with the hard-coded
> "operating-points-v2" name (if there's ever a 'v3' we'll then have to
> update this).
>
> Is the desire just to get an error on probe if the table is malformed?
> Have you hit this situation? If so this sounds like something which
> would be better fixed in the generic OPP code rather than Panfrost itself.

The idea was to avoid calling devfreq if there is no opp table.
But I think you're right we don't have to check for malformed
device-tree in the driver.

I will drop this patch,

Regards,
Clement


>
> Steve
>
> > ---
> >   drivers/gpu/drm/panfrost/panfrost_devfreq.c | 14 +++++++++-----
> >   1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > index d9007f44b772..fce21c682414 100644
> > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > @@ -96,15 +96,19 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
> >       struct thermal_cooling_device *cooling;
> >       struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
> >
> > -     ret = dev_pm_opp_of_add_table(dev);
> > -     if (ret == -ENODEV) /* Optional, continue without devfreq */
> > +     if (!device_property_present(dev, "operating-points-v2"))
> > +             /* Optional, continue without devfreq */
> >               return 0;
> > -     else if (ret)
> > -             return ret;
> > -     pfdevfreq->opp_of_table_added = true;
> >
> >       spin_lock_init(&pfdevfreq->lock);
> >
> > +     ret = dev_pm_opp_of_add_table(dev);
> > +     if (ret) {
> > +             DRM_DEV_ERROR(dev, "Couldn't add OPP table\n");
> > +             goto err_fini;
> > +     }
> > +     pfdevfreq->opp_of_table_added = true;
> > +
> >       panfrost_devfreq_reset(pfdevfreq);
> >
> >       cur_freq = clk_get_rate(pfdev->clock);
> >
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index d9007f44b772..fce21c682414 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -96,15 +96,19 @@  int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	struct thermal_cooling_device *cooling;
 	struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
 
-	ret = dev_pm_opp_of_add_table(dev);
-	if (ret == -ENODEV) /* Optional, continue without devfreq */
+	if (!device_property_present(dev, "operating-points-v2"))
+		/* Optional, continue without devfreq */
 		return 0;
-	else if (ret)
-		return ret;
-	pfdevfreq->opp_of_table_added = true;
 
 	spin_lock_init(&pfdevfreq->lock);
 
+	ret = dev_pm_opp_of_add_table(dev);
+	if (ret) {
+		DRM_DEV_ERROR(dev, "Couldn't add OPP table\n");
+		goto err_fini;
+	}
+	pfdevfreq->opp_of_table_added = true;
+
 	panfrost_devfreq_reset(pfdevfreq);
 
 	cur_freq = clk_get_rate(pfdev->clock);