drm/panfrost: missing remove opp table in case of failure
Subsystems (3)
PATCH 1/2 drm/panfrost: missing remove opp table in case of failure
In case of failure we need to remove OPP table.
Use Linux classic error handling with goto usage.
--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/panfrost/panfrost_devfreq.c +12 -4
@@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) cur_freq =clk_get_rate (pfdev->clock); opp =devfreq_recommended_opp (dev, &cur_freq,0 ); -if (IS_ERR (opp)) -return PTR_ERR (opp); +if (IS_ERR (opp)) { +DRM_DEV_ERROR (dev,"Failed to set recommended OPP\n" ); + ret =PTR_ERR (opp); + goto err_opp; + } panfrost_devfreq_profile.initial_freq = cur_freq;dev_pm_opp_put (opp);
@@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);if (IS_ERR (devfreq)) {DRM_DEV_ERROR (dev,"Couldn't initialize GPU devfreq\n" ); -dev_pm_opp_of_remove_table (dev); -return PTR_ERR (devfreq); + ret =PTR_ERR (devfreq); + goto err_opp; } pfdev->devfreq.devfreq = devfreq;
@@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdev->devfreq.cooling = cooling;return 0 ; + +err_opp: +dev_pm_opp_of_remove_table (dev); + +return ret; }void panfrost_devfreq_fini (struct panfrost_device *pfdev)
Signature · 1 line
2.20.1
PATCH 2/2 drm/panfrost: add devfreq regulator support
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)
drivers/gpu/drm/panfrost/panfrost_devfreq.c +30 -4
@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ; +struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 ); +if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); +if (ret != -ENODEV ) { +DRM_DEV_ERROR (dev,"Failed to set regulator: %d\n" , ret); +return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret =dev_pm_opp_of_add_table (dev); -if (ret == -ENODEV )/* Optional, continue without devfreq */ -return 0 ; -else if (ret) -return ret; +if (ret) { +if (ret == -ENODEV )/* Optional, continue without devfreq */ + ret =0 ; + goto err_opp_reg; + }panfrost_devfreq_reset (pfdev);
@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp:dev_pm_opp_of_remove_table (dev); +err_opp_reg: +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } +return ret; }
@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) {if (pfdev->devfreq.cooling)devfreq_cooling_unregister (pfdev->devfreq.cooling); +dev_pm_opp_of_remove_table (&pfdev->pdev->dev); + +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } }void panfrost_devfreq_resume (struct panfrost_device *pfdev)
drivers/gpu/drm/panfrost/panfrost_device.h +1 -0
@@ -86,6 +86,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update;
Signature · 1 line
2.20.1
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Panfrost and OPP Maintainers,
Quoted 4 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
After this patch, Panfrost update properly both voltage and frequency. But the GPU is still not properly down-clocked when temperature is high.
I try to add a cooling map like this :
https://github.com/clementperon/linux/commit/955961c7c035abbf44e74f608fe8f059c06a2fbe
But got the following error:
[ 2.712082] panfrost 1800000.gpu: [drm:panfrost_devfreq_init
[panfrost]] Failed to register cooling device
Do you see what I'm missing?
Thanks for your help,
Clement
Quoted 84 lines
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +30
-4@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ; +struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 ); +if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); +if (ret != -ENODEV ) { +DRM_DEV_ERROR (dev,"Failed to set regulator: %d\n" , ret); +return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret =dev_pm_opp_of_add_table (dev); -if (ret == -ENODEV )/* Optional, continue without devfreq */ -return 0 ; -else if (ret) -return ret; +if (ret) { +if (ret == -ENODEV )/* Optional, continue without devfreq */ + ret =0 ; + goto err_opp_reg; + }panfrost_devfreq_reset (pfdev);@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp:dev_pm_opp_of_remove_table (dev); +err_opp_reg: +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } +return ret; }@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) {if (pfdev->devfreq.cooling)devfreq_cooling_unregister (pfdev->devfreq.cooling); +dev_pm_opp_of_remove_table (&pfdev->pdev->dev); + +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } }void panfrost_devfreq_resume (struct panfrost_device *pfdev)drivers/gpu/drm/panfrost/panfrost_device.h +1
-1@@ -86,6 +86,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update; --2.20.1
Steven Price
maintainerRe: [PATCH 2/2] drm/panfrost: add devfreq regulator support
In reply to Clément PéronQuoted 15 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +0
-0
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +5
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ; +struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );
This looks like it applies before 3e1399bccf51 ("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:
opp_table = dev_pm_opp_set_regulators(dev,
pfdev->comp->supply_names,
pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent 'vdd_gpu' already
present!
This is due to the regulator debugfs entries getting created twice (once in panfrost_regulator_init() and once here).
I have been taking a look at doing the same thing (I picked up Martin Blumenstingl's patch series[1]), but haven't had much time to focus on this recently.
Thanks,
Steve
Quoted 55 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +25
-4+if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); +if (ret != -ENODEV ) { +DRM_DEV_ERROR (dev,"Failed to set regulator: %d\n" , ret); +return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret =dev_pm_opp_of_add_table (dev); -if (ret == -ENODEV )/* Optional, continue without devfreq */ -return 0 ; -else if (ret) -return ret; +if (ret) { +if (ret == -ENODEV )/* Optional, continue without devfreq */ + ret =0 ; + goto err_opp_reg; + }panfrost_devfreq_reset (pfdev);@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp:dev_pm_opp_of_remove_table (dev); +err_opp_reg: +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } +return ret; }@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) {if (pfdev->devfreq.cooling)devfreq_cooling_unregister (pfdev->devfreq.cooling); +dev_pm_opp_of_remove_table (&pfdev->pdev->dev); + +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } }void panfrost_devfreq_resume (struct panfrost_device *pfdev)drivers/gpu/drm/panfrost/panfrost_device.h +0
-0
drivers/gpu/drm/panfrost/panfrost_device.h struct panfrost_device { · line 92
Quoted 7 lines
drivers/gpu/drm/panfrost/panfrost_device.h +1
-0@@ -86,6 +86,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;
Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:
Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.
Quoted 7 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Quoted 7 lines
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).
Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Link to original discussion:
https://lore.kernel.org/patchwork/patch/1176717/
Thanks,
Clement
Quoted 76 lines
I have been taking a look at doing the same thing (I picked up Martin Blumenstingl's patch series[1]), but haven't had much time to focus on this recently.
Thanks,
Steve
[1]
https://lore.kernel.org/dri-devel/[email protected]/Quoted 62 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +25
-4+if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); +if (ret != -ENODEV ) { +DRM_DEV_ERROR (dev,"Failed to set regulator: %d\n" , ret); +return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret =dev_pm_opp_of_add_table (dev); -if (ret == -ENODEV )/* Optional, continue without devfreq */ -return 0 ; -else if (ret) -return ret; +if (ret) { +if (ret == -ENODEV )/* Optional, continue without devfreq */ + ret =0 ; + goto err_opp_reg; + }panfrost_devfreq_reset (pfdev);@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp:dev_pm_opp_of_remove_table (dev); +err_opp_reg: +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } +return ret; }@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) {if (pfdev->devfreq.cooling)devfreq_cooling_unregister (pfdev->devfreq.cooling); +dev_pm_opp_of_remove_table (&pfdev->pdev->dev); + +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } }void panfrost_devfreq_resume (struct panfrost_device *pfdev)drivers/gpu/drm/panfrost/panfrost_device.h +1
-0@@ -86,6 +86,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update;
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi,
Quoted 50 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 12 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!
Quoted 6 lines
Quoted 2 lines
This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from vdd_XXX to opp_vdd_XXX ?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45
Quoted 83 lines
Link to original discussion:
https://lore.kernel.org/patchwork/patch/1176717/Thanks,
ClementQuoted 76 lines
I have been taking a look at doing the same thing (I picked up Martin Blumenstingl's patch series[1]), but haven't had much time to focus on this recently.
Thanks,
Steve
[1]
https://lore.kernel.org/dri-devel/[email protected]/Quoted 62 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +25
-4+if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); +if (ret != -ENODEV ) { +DRM_DEV_ERROR (dev,"Failed to set regulator: %d\n" , ret); +return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret =dev_pm_opp_of_add_table (dev); -if (ret == -ENODEV )/* Optional, continue without devfreq */ -return 0 ; -else if (ret) -return ret; +if (ret) { +if (ret == -ENODEV )/* Optional, continue without devfreq */ + ret =0 ; + goto err_opp_reg; + }panfrost_devfreq_reset (pfdev);@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp:dev_pm_opp_of_remove_table (dev); +err_opp_reg: +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } +return ret; }@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) {if (pfdev->devfreq.cooling)devfreq_cooling_unregister (pfdev->devfreq.cooling); +dev_pm_opp_of_remove_table (&pfdev->pdev->dev); + +if (pfdev->devfreq.opp_table) { +dev_pm_opp_put_regulators (pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table =NULL ; + } }void panfrost_devfreq_resume (struct panfrost_device *pfdev)drivers/gpu/drm/panfrost/panfrost_device.h +1
-0@@ -86,6 +86,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update;
Steven Price
maintainerRe: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Quoted 56 lines · Clément Péron
Hi,
Quoted 53 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 14 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).
Quoted 6 lines
Quoted 3 lines
Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from
vdd_XXXtoopp_vdd_XXX?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45
Yes, I'm not sure that it's actually a problem in practice. And it may well be correct to change this in the generic code rather than try to work around it in Panfrost. But we shouldn't spam the user with warnings as that makes real issues harder to see.
Your suggestion to change the name seems reasonable to me, but I don't fully understand the opp code, so we'd need some review from the OPP maintainers. Hopefully Viresh, Nishanth or Stephen can provide some insight.
Steve
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven,
Quoted 65 lines · Steven Price
Quoted 56 lines · Clément Péron
Hi,
Quoted 53 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 14 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).Quoted 6 lines
Quoted 3 lines
Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from
vdd_XXXtoopp_vdd_XXX?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45
Quoted 8 lines
Yes, I'm not sure that it's actually a problem in practice. And it may well be correct to change this in the generic code rather than try to work around it in Panfrost. But we shouldn't spam the user with warnings as that makes real issues harder to see.
Your suggestion to change the name seems reasonable to me, but I don't fully understand the opp code, so we'd need some review from the OPP maintainers. Hopefully Viresh, Nishanth or Stephen can provide some insight.
Agree, I will send a v2 with the rename and see if OPP Maintainers agree.
Regards,
Clement
Quoted 2 lines
Steve
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven,
Quoted 58 lines · Clément Péron
Hi Steven,
Quoted 54 lines · Steven Price
Quoted 52 lines · Clément Péron
Hi,
Quoted 49 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 11 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!
I try to reproduce but it can't
regulator is mount at :
./regulator/vdd-gpu
whereas OPP is mount :
./opp/soc-1800000.gpu/opp:756000000/supply-0/
I see that firefly as 2 regulators with the same name :vdd_gpu from syr828
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L453)vdd_gpu from rk808_dcdc2_reg
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L841)
So i think the issue is from the firefly device-tree.
Regards,
Clement
Quoted 27 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from
vdd_XXXtoopp_vdd_XXX?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45Quoted 8 lines
Yes, I'm not sure that it's actually a problem in practice. And it may well be correct to change this in the generic code rather than try to work around it in Panfrost. But we shouldn't spam the user with warnings as that makes real issues harder to see.
Your suggestion to change the name seems reasonable to me, but I don't fully understand the opp code, so we'd need some review from the OPP maintainers. Hopefully Viresh, Nishanth or Stephen can provide some insight.
Agree, I will send a v2 with the rename and see if OPP Maintainers agree.
Regards,
ClementQuoted 2 lines
Steve
Steven Price
maintainerRe: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Clément,
Quoted 59 lines · Clément Péron
Hi Steven,
Quoted 56 lines · Clément Péron
Hi Steven,
Quoted 52 lines · Steven Price
Quoted 50 lines · Clément Péron
Hi,
Quoted 47 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 9 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!I try to reproduce but it can't
regulator is mount at :
./regulator/vdd-gpu
whereas OPP is mount :
./opp/soc-1800000.gpu/opp:756000000/supply-0/
Getting a backtrace from the two occurrences, I see one added from:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c04682e0>] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [<c04696f0>]
(devm_regulator_bulk_get+0x40/0x74)
(devm_regulator_bulk_get) from [<bf00af44>]
(panfrost_device_init+0x1b4/0x48c [panfrost])
(panfrost_device_init [panfrost]) from [<bf00a4d4>]
(panfrost_probe+0x94/0x184 [panfrost])
(panfrost_probe [panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)
And the other:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c05c1280>] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [<bf00b4ac>]
(panfrost_devfreq_init+0x38/0x1ac [panfrost])
(panfrost_devfreq_init [panfrost]) from [<bf00a508>]
(panfrost_probe+0xc8/0x184 [panfrost])
(panfrost_probe [panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)
Both are created at /regulator/vdd_gpu
Quoted 8 lines
I see that firefly as 2 regulators with the same name :
vdd_gpufrom syr828
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L453)vdd_gpufromrk808_dcdc2_reg
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L841)So i think the issue is from the firefly device-tree.
I'm using the DTB from the kernel tree (/arch/arm/boot/dts/rk3288-firefly.dts) which as far as I can see doesn't contain this problem. Certainly decompiling the DTB I can see only one mention of vdd_gpu (in syr828).
Steve
Quoted 31 lines
Regards,
ClementQuoted 27 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from
vdd_XXXtoopp_vdd_XXX?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45Quoted 8 lines
Yes, I'm not sure that it's actually a problem in practice. And it may well be correct to change this in the generic code rather than try to work around it in Panfrost. But we shouldn't spam the user with warnings as that makes real issues harder to see.
Your suggestion to change the name seems reasonable to me, but I don't fully understand the opp code, so we'd need some review from the OPP maintainers. Hopefully Viresh, Nishanth or Stephen can provide some insight.
Agree, I will send a v2 with the rename and see if OPP Maintainers agree.
Regards,
ClementQuoted 2 lines
Steve
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Liam and Mark,
Quoted 67 lines · Steven Price
Hi Clément,
Quoted 63 lines · Clément Péron
Hi Steven,
Quoted 58 lines · Clément Péron
Hi Steven,
Quoted 54 lines · Steven Price
Quoted 52 lines · Clément Péron
Hi,
Quoted 49 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.Quoted 11 lines
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies);Otherwise a platform with multiple regulators won't work correctly.
Also running on my firefly (RK3288) board I get the following warning:
debugfs: Directory 'ffa30000.gpu-mali' with parent '
vdd_gpu' already
present!I try to reproduce but it can't
Sorry, you're right I have indeed the same issue:
[ 2.903406] panfrost 1800000.gpu: Features: L2:0x07110206 Shader:0x00000000 Tiler:0x00000809 Mem:0x1 MMU:0x00002821 AS:0xf JS:0x7 [ 2.913297] sunxi-ir 7040000.ir: initialized sunXi IR driver [ 2.919901] panfrost 1800000.gpu: shader_present=0x3 l2_present=0x1 [ 2.920497] panfrost 1800000.gpu: Looking up mali-supply from device tree [ 3.036568] vdd-gpu: could not add device link 1800000.gpu err -17 [ 3.036580] debugfs: Directory '1800000.gpu-mali' with parent 'vdd-gpu' already present! [ 3.046312] panfrost 1800000.gpu: [drm:panfrost_devfreq_init [panfrost]] Failed to register cooling device [ 3.056322] [drm] Initialized panfrost 1.1.0 20180908 for
1800000.gpu on minor 0
Quoted 25 lines
Quoted 4 lines
regulator is mount at :
./regulator/vdd-gpu
whereas OPP is mount :
./opp/soc-1800000.gpu/opp:756000000/supply-0/Getting a backtrace from the two occurrences, I see one added from:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c04682e0>] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [<c04696f0>](
devm_regulator_bulk_get+0x40/0x74)
(devm_regulator_bulk_get) from [<bf00af44>]
(panfrost_device_init+0x1b4/0x48c[panfrost])
(panfrost_device_init[panfrost]) from [<bf00a4d4>]
(panfrost_probe+0x94/0x184[panfrost])
(panfrost_probe[panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)And the other:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c05c1280>] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [<bf00b4ac>]
Quoted 7 lines
(
panfrost_devfreq_init+0x38/0x1ac[panfrost])
(panfrost_devfreq_init[panfrost]) from [<bf00a508>]
(panfrost_probe+0xc8/0x184[panfrost])
(panfrost_probe[panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)Both are created at /regulator/vdd_gpu
We are having an issue with Panfrost driver registering two times the same regulator and giving an error when trying to create the debugfs folder.
Could you clarify if it is allowed for a device to register two times the same regulator?
I check Documentation/power/regulator/regulator.rst but this point is not specified.
Thanks,
Clement
Quoted 49 lines
Quoted 9 lines
I see that firefly as 2 regulators with the same name :
vdd_gpufrom syr828
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L453)vdd_gpufromrk808_dcdc2_reg
(https://github.com/mopplayer/Firefly-RK3288-Kernel-With-Mali764/blob/master/arch/arm/boot/dts/firefly-rk3288.dts#L841)So i think the issue is from the firefly device-tree.
I'm using the DTB from the kernel tree (/arch/arm/boot/dts/rk3288-firefly.dts) which as far as I can see doesn't contain this problem. Certainly decompiling the DTB I can see only one mention of
vdd_gpu(in syr828).Steve
Quoted 31 lines
Regards,
ClementQuoted 27 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
This is due to the regulator debugfs entries getting created twice (once in
panfrost_regulator_init()and once here).Is it a warning that should be consider as an error? Look's more an info no? What should be the correct behavior if a device want to register two times the same regulator?
Or we can change the name from
vdd_XXXtoopp_vdd_XXX?
https://elixir.bootlin.com/linux/latest/source/drivers/opp/debugfs.c#L45Quoted 8 lines
Yes, I'm not sure that it's actually a problem in practice. And it may well be correct to change this in the generic code rather than try to work around it in Panfrost. But we shouldn't spam the user with warnings as that makes real issues harder to see.
Your suggestion to change the name seems reasonable to me, but I don't fully understand the opp code, so we'd need some review from the OPP maintainers. Hopefully Viresh, Nishanth or Stephen can provide some insight.
Agree, I will send a v2 with the rename and see if OPP Maintainers agree.
Regards,
ClementQuoted 2 lines
Steve
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Quoted 1 line · Clément Péron
Hi Liam and Mark,
You might want to flag stuff like this in the subject line, I very nearly deleted this without opening it since most of the email I get about panfrost appears to be coming from me having sent patches rather than being relevant.
Quoted 9 lines
We are having an issue with Panfrost driver registering two times the same regulator and giving an error when trying to create the debugfs folder.
Could you clarify if it is allowed for a device to register two times the same regulator?
I check
Documentation/power/regulator/regulator.rstbut this point is not specified.
We don't actively prevent it and I can't think what other than debugfs might run into problems (and that's just a warning) but it does seem like a weird thing to want to do and like it's pointing to some confusion in your code with two different parts of the device controlling the same supply independently. What's the use case here?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Mark,
Quoted 8 lines · Mark Brown
Quoted 1 line · Clément Péron
Hi Liam and Mark,
You might want to flag stuff like this in the subject line, I very nearly deleted this without opening it since most of the email I get about panfrost appears to be coming from me having sent patches rather than being relevant.
Ok will do next time,
Quoted 8 lines
Quoted 7 lines
We are having an issue with Panfrost driver registering two times the same regulator and giving an error when trying to create the debugfs folder.
Could you clarify if it is allowed for a device to register two times the same regulator?
Quoted 8 lines
Quoted 2 lines
I check
Documentation/power/regulator/regulator.rstbut this point is not specified.We don't actively prevent it and I can't think what other than debugfs might run into problems (and that's just a warning) but it does seem like a weird thing to want to do and like it's pointing to some confusion in your code with two different parts of the device controlling the same supply independently. What's the use case here?
Panfrost first probe clock, reset and regulator in device_init:
https://elixir.bootlin.com/linux/v5.7-rc1/source/drivers/gpu/drm/panfrost/panfrost_drv.c#L602
Then it probe for optional devfreq, devfreq will get opp tables and also get regulator again.
https://elixir.bootlin.com/linux/v5.7-rc1/source/drivers/gpu/drm/panfrost/panfrost_drv.c#L609
That's can be reworked and Panfrost can only probe regulator if there is no opp-table.
But if multiple regulator is not an issue and as each request is logic. The first in device_init assure to enable the regulator and the second in OPP assure the voltage level.
Maybe we can just fix this warning?
Thanks,
Clement
Steven Price
maintainerRe: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
Quoted 31 lines · Clément Péron
Hi Mark,
Quoted 8 lines · Mark Brown
Quoted 1 line · Clément Péron
Hi Liam and Mark,
You might want to flag stuff like this in the subject line, I very nearly deleted this without opening it since most of the email I get about panfrost appears to be coming from me having sent patches rather than being relevant.
Ok will do next time,
Quoted 8 lines
Quoted 7 lines
We are having an issue with Panfrost driver registering two times the same regulator and giving an error when trying to create the debugfs folder.
Could you clarify if it is allowed for a device to register two times the same regulator?
Quoted 8 lines
Quoted 2 lines
I check
Documentation/power/regulator/regulator.rstbut this point is not specified.We don't actively prevent it and I can't think what other than debugfs might run into problems (and that's just a warning) but it does seem like a weird thing to want to do and like it's pointing to some confusion in your code with two different parts of the device controlling the same supply independently. What's the use case here?
Quoted 8 lines
Panfrost first probe clock, reset and regulator in
device_init:
https://elixir.bootlin.com/linux/v5.7-rc1/source/drivers/gpu/drm/panfrost/panfrost_drv.c#L602
Then it probe for optional devfreq, devfreq will get opp tables and also get regulator again.
https://elixir.bootlin.com/linux/v5.7-rc1/source/drivers/gpu/drm/panfrost/panfrost_drv.c#L609That's can be reworked and Panfrost can only probe regulator if there is no opp-table.
This is what I was thinking about looking at. But it may make sense instead to extend the regulator API to allow multiple regualtor_get() calls for a single device. I haven't had time to dig into how difficult this would be.
Quoted 5 lines
But if multiple regulator is not an issue and as each request is logic. The first in
device_initassure to enable the regulator and the second in OPP assure the voltage level.Maybe we can just fix this warning?
From what I can see in the code, just silencing the warning would lead to 'odd' behaviour with debugfs. The first struct regulator Panfrost acquires is the one that is used purely for turning the GPU on (no voltage scaling). The second struct regulator is the one which is obtained by the OPP framework. However the debugfs entries point into the actual struct regulator, so it would be far more logical/useful if those were pointing into the second struct regulator.
Ideally calling regulator_get a second time for the same device would simply return the same struct regulator object (with a reference count increment).
Perhaps a better approach would be for Panfrost to hand over the struct regulator objects it has already got to the OPP framework. I.e. open code dev_pm_opp_set_regulators(), but instead of calling regulator_get_optional() simply populate the regulators we already have?
The other benefit of that is it would provide a clear hand-over of responsibility between Panfrost handling it's own regulators and the OPP framework picking up the work. The disadvantage is that Panfrost would have to track whether the regulators have been handed over or not.
Steve
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
Quoted 8 lines · Steven Price
Quoted 2 lines · Clément Péron
That's can be reworked and Panfrost can only probe regulator if there is no opp-table.
This is what I was thinking about looking at. But it may make sense instead to extend the regulator API to allow multiple
regualtor_get()calls for a single device. I haven't had time to dig into how difficult this would be.
To repeat what I said before we don't actively stop this, it's just not something that seems particularly tasteful and the warning does find actual errors. I definitely don't think it's a good idea to extend the API for this.
Quoted 2 lines
Ideally calling
regulator_geta second time for the same device would simply return the same struct regulator object (with a reference count increment).
One of the goals with the distinct struct regulator is to make sure that we track all the user's activity together - if we mix multiple users in there it becomes harder to tell if something is going wrong.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
In reply to Steven PriceOn 2020-04-16 2:42 pm, Steven Price wrote:
[...]
Quoted 3 lines
Perhaps a better approach would be for Panfrost to hand over the struct regulator objects it has already got to the OPP framework. I.e. open code
dev_pm_opp_set_regulators(), but instead of callingregulator_get_optional()simply populate the regulators we already have?The other benefit of that is it would provide a clear hand-over of responsibility between Panfrost handling it's own regulators and the OPP framework picking up the work. The disadvantage is that Panfrost would have to track whether the regulators have been handed over or not.
Sounds like the most logical thing to do is to shuffle things around so we start by trying to set up an OPP table, then fall back to explicitly claiming clocks and regulators if necessary. Then we can easily make the devfreq decision later in probe based on how that turned out.
Robin.
Re: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
Hi Robin,
Quoted 13 lines · Robin Murphy
On 2020-04-16 2:42 pm, Steven Price wrote:
[...]Quoted 9 lines
Perhaps a better approach would be for Panfrost to hand over the struct regulator objects it has already got to the OPP framework. I.e. open code
dev_pm_opp_set_regulators(), but instead of callingregulator_get_optional()simply populate the regulators we already have?The other benefit of that is it would provide a clear hand-over of responsibility between Panfrost handling it's own regulators and the OPP framework picking up the work. The disadvantage is that Panfrost would have to track whether the regulators have been handed over or not.
Quoted 4 lines
Sounds like the most logical thing to do is to shuffle things around so we start by trying to set up an OPP table, then fall back to explicitly claiming clocks and regulators if necessary. Then we can easily make the devfreq decision later in probe based on how that turned out.
Ok I will propose a new serie with this behavior,
Thanks
Clement
Quoted 2 lines
Robin.
Re: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
Hi,
Quoted 11 lines · Clément Péron
Hi Robin,
Quoted 7 lines · Robin Murphy
On 2020-04-16 2:42 pm, Steven Price wrote:
[...]Quoted 4 lines
Perhaps a better approach would be for Panfrost to hand over the struct regulator objects it has already got to the OPP framework. I.e. open code
dev_pm_opp_set_regulators(), but instead of callingregulator_get_optional()simply populate the regulators we already have?
Just saw that a Lima devfreq[0] has been also introduced with I think exactly the same logic.
Is this something that hasn't been triggered by Maintainer or I am missing something?
I will backport some remarks made on the lima devfreq to improve panfrost one. They are almost identical.
Regards,
Clement
0: https://cgit.freedesktop.org/drm-misc/commit/?id=1996970773a323533e1cc1b6b97f00a95d675f32
Quoted 18 lines
Quoted 10 lines
Quoted 5 lines
The other benefit of that is it would provide a clear hand-over of responsibility between Panfrost handling it's own regulators and the OPP framework picking up the work. The disadvantage is that Panfrost would have to track whether the regulators have been handed over or not.
Sounds like the most logical thing to do is to shuffle things around so we start by trying to set up an OPP table, then fall back to explicitly claiming clocks and regulators if necessary. Then we can easily make the devfreq decision later in probe based on how that turned out.
Ok I will propose a new serie with this behavior,
Thanks
ClementQuoted 2 lines
Robin.
Re: Multiple regulators for one device [was drm/panfrost: add devfreq regulator support]
Quoted 5 lines · Clément Péron
Just saw that a Lima devfreq[0] has been also introduced with I think exactly the same logic.
Is this something that hasn't been triggered by Maintainer or I am missing something?
My understanding is that there is very little use of any of this upstream since it's all pretty new, some platforms have OPPs but use a firmware interface rather than the OS to control clocks and regulators while most other platforms don't have OPPs defined and it's only platforms with both regulators and OPPs that are affected.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
In reply to Clément PéronQuoted 5 lines · Clément Péron
But if multiple regulator is not an issue and as each request is logic. The first in
device_initassure to enable the regulator and the second in OPP assure the voltage level.Maybe we can just fix this warning?
Well, if you have a tasteful way of doing it I guess.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
In reply to Steven PriceHi Steven,
Quoted 6 lines · Steven Price
Hi Clément,
Quoted 2 lines · Clément Péron
Hi Steven,
<snip>
Quoted 20 lines
Getting a backtrace from the two occurrences, I see one added from:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c04682e0>] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [<c04696f0>](
devm_regulator_bulk_get+0x40/0x74)
(devm_regulator_bulk_get) from [<bf00af44>]
(panfrost_device_init+0x1b4/0x48c[panfrost])
(panfrost_device_init[panfrost]) from [<bf00a4d4>]
(panfrost_probe+0x94/0x184[panfrost])
(panfrost_probe[panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)And the other:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c05c1280>] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [<bf00b4ac>]
Quoted 7 lines
(
panfrost_devfreq_init+0x38/0x1ac[panfrost])
(panfrost_devfreq_init[panfrost]) from [<bf00a508>]
(panfrost_probe+0xc8/0x184[panfrost])
(panfrost_probe[panfrost]) from [<c04ee694>]
(platform_drv_probe+0x48/0x94)Both are created at /regulator/vdd_gpu
I'm preparing a new version with some clean from lima devfreq. My working branch :
https://github.com/clementperon/linux/commits/panfrost_devfreq
Two strange things I observe:
- After 30sec the regulator is released by OPP ???
[ 33.757627] vdd-gpu: disabling
Introduce the regulator support in this commit:
https://github.com/clementperon/linux/commit/be310c37b82010e293b7f129ccdcb711a2abb2ce
- The Cooling map is not probe correctly :
[ 2.545756] panfrost 1800000.gpu: [drm:panfrost_devfreq_init
[panfrost]] Failed to register cooling device
Introduce in this commit :
https://github.com/clementperon/linux/commit/0252c38fd55ad78366ac4b1714e285c88db34557
Do you have an hint about what I'm missing ?
Thanks for your help,
Clement
Steven Price
maintainerRe: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Quoted 38 lines · Clément Péron
Hi Steven,
Quoted 6 lines · Steven Price
Hi Clément,
Quoted 2 lines · Clément Péron
Hi Steven,
<snip>
Quoted 26 lines
Getting a backtrace from the two occurrences, I see one added from:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c04682e0>] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [<c04696f0>] (devm_regulator_bulk_get+0x40/0x74) (devm_regulator_bulk_get) from [<bf00af44>] (panfrost_device_init+0x1b4/0x48c [panfrost]) (panfrost_device_init [panfrost]) from [<bf00a4d4>] (panfrost_probe+0x94/0x184 [panfrost]) (panfrost_probe [panfrost]) from [<c04ee694>](
platform_drv_probe+0x48/0x94)And the other:
(debugfs_create_dir) from [<c04633f8>] (create_regulator+0xe0/0x220) (create_regulator) from [<c04681d8>] (_regulator_get+0x168/0x204) (_regulator_get) from [<c05c1280>] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [<bf00b4ac>] (panfrost_devfreq_init+0x38/0x1ac [panfrost]) (panfrost_devfreq_init [panfrost]) from [<bf00a508>] (panfrost_probe+0xc8/0x184 [panfrost]) (panfrost_probe [panfrost]) from [<c04ee694>](
platform_drv_probe+0x48/0x94)
Quoted 5 lines
Quoted 1 line
Both are created at /regulator/vdd_gpu
I'm preparing a new version with some clean from lima devfreq. My working branch :
https://github.com/clementperon/linux/commits/panfrost_devfreq
I had a look at that branch and gave it a quick spin on my Firefly RK3288 and didn't notice any issues.
Quoted 5 lines
Two strange things I observe:
- After 30sec the regulator is released by OPP ???[ 33.757627] vdd-gpu: disablingIntroduce the regulator support in this commit:
https://github.com/clementperon/linux/commit/be310c37b82010e293b7f129ccdcb711a2abb2ce
I can't see anything wrong with this commit, but equally in my DTS I have a "regulator-always-on" for vdd_gpu. My initial thought was that this could be runtime PM of the GPU - but I can't see how panfrost_device_suspend() would end up turning off the regulator. So unless there's some way that the regulator itself suspends (but it should know it's in use) I've no clue why this would be happening.
Since you've got a reproduction - can you get a backtrace where the regulator is getting disabled?
Quoted 7 lines
- The Cooling map is not probe correctly :
[ 2.545756] panfrost 1800000.gpu: [drm:panfrost_devfreq_init[panfrost]] Failed to register cooling device
Introduce in this commit :
https://github.com/clementperon/linux/commit/0252c38fd55ad78366ac4b1714e285c88db34557Do you have an hint about what I'm missing ?
Sorry, my knowledge of the cooling framework is very limited. What you've got looks plausible, but I'm afraid I can't really help beyond that! As before - can you try adding some printk()s in e.g. of_devfreq_cooling_register_power() and find out where it is bailing out?
Steve
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven,
Quoted 12 lines · Steven Price
Quoted 10 lines · Clément Péron
Hi Steven,
Quoted 6 lines · Steven Price
Hi Clément,
Quoted 2 lines · Clément Péron
Hi Steven,
<snip>
Quoted 3 lines
Since you've got a reproduction - can you get a backtrace where the regulator is getting disabled?
Regulator is disabled from regulator_late_cleanup()
[ 33.757650] vdd-gpu: disabling [ 33.760718] CPU: 2 PID: 31 Comm: kworker/2:1 Not tainted 5.7.0-rc2-next-20200424 #8 [ 33.768362] Hardware name: Beelink GS1 (DT) [ 33.772553] Workqueue: events regulator_init_complete_work_function [ 33.778813] Call trace: [ 33.781261] dump_backtrace+0x0/0x1a0 [ 33.784922] show_stack+0x18/0x30 [ 33.788238] dump_stack+0xc0/0x114 [ 33.791638] regulator_late_cleanup+0x164/0x1f0 [ 33.796165] class_for_each_device+0x64/0xe0 [ 33.800431] regulator_init_complete_work_function+0x4c/0x60 [ 33.806084] process_one_work+0x19c/0x330 [ 33.810090] worker_thread+0x4c/0x430 [ 33.813748] kthread+0x138/0x160 [ 33.816973] ret_from_fork+0x10/0x24
the use_count is at 0...
I have check and the regulator_get is called and regulator_put is never called for vdd-gpu.
Not sure what is happening here...
Quoted 7 lines
Quoted 7 lines
- The Cooling map is not probe correctly :
[ 2.545756] panfrost 1800000.gpu: [drm:panfrost_devfreq_init[panfrost]] Failed to register cooling device
Introduce in this commit :
https://github.com/clementperon/linux/commit/0252c38fd55ad78366ac4b1714e285c88db34557
Quoted 6 lines
Quoted 1 line
Do you have an hint about what I'm missing ?
Sorry, my knowledge of the cooling framework is very limited. What you've got looks plausible, but I'm afraid I can't really help beyond that! As before - can you try adding some printk()s in e.g.
of_devfreq_cooling_register_power()and find out where it is bailing out?
Dumb issue, I was missing the CONFIG_DEVFREQ_THERMAL -_-, I will make a patch to enable it in arm64 defconfig.
Regards,
Clement
Quoted 2 lines
Steve
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Quoted 40 lines · Clément Péron
Hi Steven,
Quoted 12 lines · Steven Price
Quoted 10 lines · Clément Péron
Hi Steven,
Quoted 6 lines · Steven Price
Hi Clément,
Quoted 2 lines · Clément Péron
Hi Steven,
<snip>
Quoted 3 lines
Since you've got a reproduction - can you get a backtrace where the regulator is getting disabled?
Regulator is disabled from
regulator_late_cleanup()[ 33.757650] vdd-gpu: disabling [ 33.760718] CPU: 2 PID: 31 Comm: kworker/2:1 Not tainted 5.7.0-rc2-next-20200424 #8 [ 33.768362] Hardware name: Beelink GS1 (DT) [ 33.772553] Workqueue: events regulator_init_complete_work_function [ 33.778813] Call trace: [ 33.781261] dump_backtrace+0x0/0x1a0 [ 33.784922] show_stack+0x18/0x30 [ 33.788238] dump_stack+0xc0/0x114 [ 33.791638] regulator_late_cleanup+0x164/0x1f0 [ 33.796165] class_for_each_device+0x64/0xe0 [ 33.800431] regulator_init_complete_work_function+0x4c/0x60 [ 33.806084] process_one_work+0x19c/0x330 [ 33.810090] worker_thread+0x4c/0x430 [ 33.813748] kthread+0x138/0x160 [ 33.816973] ret_from_fork+0x10/0x24
Quoted 5 lines
the
use_countis at 0...I have check and the
regulator_getis called andregulator_putis never called for vdd-gpu.
Not sure what is happening here...
Looks like the OPP framework only get the regulator but never enable it...
I will send a question to OPP Maintainer about this.
Regards,
CLement
Quoted 24 lines
Quoted 9 lines
Quoted 9 lines
- The Cooling map is not probe correctly :
[ 2.545756] panfrost 1800000.gpu: [drm:panfrost_devfreq_init[panfrost]] Failed to register cooling device
Introduce in this commit :
https://github.com/clementperon/linux/commit/0252c38fd55ad78366ac4b1714e285c88db34557Quoted 6 lines
Quoted 1 line
Do you have an hint about what I'm missing ?
Sorry, my knowledge of the cooling framework is very limited. What you've got looks plausible, but I'm afraid I can't really help beyond that! As before - can you try adding some printk()s in e.g.
of_devfreq_cooling_register_power()and find out where it is bailing out?Dumb issue, I was missing the
CONFIG_DEVFREQ_THERMAL-_-, I will make a patch to enable it in arm64 defconfig.Regards,
ClementQuoted 2 lines
Steve
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
In reply to Clément PéronQuoted 33 lines · Clément Péron
Hi Steven,
Quoted 21 lines · Steven Price
Quoted 19 lines · Clément Péron
OPP table can defined both frequency and voltage.
Register the mali regulator if it exist.
Signed-off-by Clément Péron <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +1
-0@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct device *dev = &pfdev->pdev->dev;struct devfreq *devfreq;struct thermal_cooling_device *cooling; +const char *mali ="mali" ;Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 85
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +4
-0+struct opp_table *opp_table =NULL ; + +/* Regulator is optional */ + opp_table =dev_pm_opp_set_regulators (dev, &mali,1 );This looks like it applies before
3e1399bccf51("drm/panfrost: Add support for multiple regulators") which is currently in drm-misc-next (and linux-next). You want something more like:
Quoted 3 lines
Thanks for you review, indeed I didn't see that multiple regulators support has been added.
Will update in v2.
Although note that we probably also want a version that can be backported to stable without that dependency, since this behaviour is arguably a regression since 221bc77914cb ("drm/panfrost: Use generic code for devfreq"), and does appear to have been causing subtle problems for users.
Robin.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Clément Péron
In case of failure we need to remove OPP table.
Use Linux classic error handling with goto usage.
Signed-off-by Clément Péron <[email protected]>
Quoted 36 lines
--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)drivers/gpu/drm/panfrost/panfrost_devfreq.c +7
-4@@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) cur_freq =clk_get_rate (pfdev->clock); opp =devfreq_recommended_opp (dev, &cur_freq,0 ); -if (IS_ERR (opp)) -return PTR_ERR (opp); +if (IS_ERR (opp)) { +DRM_DEV_ERROR (dev,"Failed to set recommended OPP\n" ); + ret =PTR_ERR (opp); + goto err_opp; + } panfrost_devfreq_profile.initial_freq = cur_freq;dev_pm_opp_put (opp);@@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);if (IS_ERR (devfreq)) {DRM_DEV_ERROR (dev,"Couldn't initialize GPU devfreq\n" ); -dev_pm_opp_of_remove_table (dev); -return PTR_ERR (devfreq); + ret =PTR_ERR (devfreq); + goto err_opp; } pfdev->devfreq.devfreq = devfreq;@@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdev->devfreq.cooling = cooling;
drivers/gpu/drm/panfrost/panfrost_devfreq.c int panfrost_devfreq_init(struct panfrost_device *pfdev) · line 125
Quoted 10 lines
drivers/gpu/drm/panfrost/panfrost_devfreq.c +5
-0return 0 ; + +err_opp: +dev_pm_opp_of_remove_table (dev); + +return ret; }void panfrost_devfreq_fini (struct panfrost_device *pfdev)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel