Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On Sat, 9 May 2020 at 18:28, Clément Péron wrote: > > Hi Steven, > > On Thu, 7 May 2020 at 16:30, Steven Price wrote: > > > > On 02/05/2020 23:07, Clément Péron wrote: > > > Hi Steven, > > > > > > On Tue, 14 Apr 2020 at 15:10, Steven Price wrote: > > >> > > >> Hi Clément, > > >> > > >> On 13/04/2020 18:28, Clément Péron wrote: > > >>> Hi Steven, > > >>> > > > > > > > > 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... 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 > > > > > > > - The Cooling map is not probe correctly : > > > [2.545756] panfrost 180.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 ? > > > > 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 > > > > > Steve ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven, On Thu, 7 May 2020 at 16:30, Steven Price wrote: > > On 02/05/2020 23:07, Clément Péron wrote: > > Hi Steven, > > > > On Tue, 14 Apr 2020 at 15:10, Steven Price wrote: > >> > >> Hi Clément, > >> > >> On 13/04/2020 18:28, Clément Péron wrote: > >>> Hi Steven, > >>> > > > > 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... > > > - The Cooling map is not probe correctly : > > [2.545756] panfrost 180.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 ? > > 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 > > Steve ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On 02/05/2020 23:07, Clément Péron wrote: Hi Steven, On Tue, 14 Apr 2020 at 15:10, Steven Price wrote: Hi Clément, On 13/04/2020 18:28, Clément Péron wrote: Hi Steven, Getting a backtrace from the two occurrences, I see one added from: (debugfs_create_dir) from [] (create_regulator+0xe0/0x220) (create_regulator) from [] (_regulator_get+0x168/0x204) (_regulator_get) from [] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [] (devm_regulator_bulk_get+0x40/0x74) (devm_regulator_bulk_get) from [] (panfrost_device_init+0x1b4/0x48c [panfrost]) (panfrost_device_init [panfrost]) from [] (panfrost_probe+0x94/0x184 [panfrost]) (panfrost_probe [panfrost]) from [] (platform_drv_probe+0x48/0x94) And the other: (debugfs_create_dir) from [] (create_regulator+0xe0/0x220) (create_regulator) from [] (_regulator_get+0x168/0x204) (_regulator_get) from [] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [] (panfrost_devfreq_init+0x38/0x1ac [panfrost]) (panfrost_devfreq_init [panfrost]) from [] (panfrost_probe+0xc8/0x184 [panfrost]) (panfrost_probe [panfrost]) from [] (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 I had a look at that branch and gave it a quick spin on my Firefly RK3288 and didn't notice any issues. 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 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? - The Cooling map is not probe correctly : [2.545756] panfrost 180.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 ? 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 dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven, On Tue, 14 Apr 2020 at 15:10, Steven Price wrote: > > Hi Clément, > > On 13/04/2020 18:28, Clément Péron wrote: > > Hi Steven, > > > Getting a backtrace from the two occurrences, I see one added from: > >(debugfs_create_dir) from [] (create_regulator+0xe0/0x220) >(create_regulator) from [] (_regulator_get+0x168/0x204) >(_regulator_get) from [] (regulator_bulk_get+0x64/0xf4) >(regulator_bulk_get) from [] > (devm_regulator_bulk_get+0x40/0x74) >(devm_regulator_bulk_get) from [] > (panfrost_device_init+0x1b4/0x48c [panfrost]) >(panfrost_device_init [panfrost]) from [] > (panfrost_probe+0x94/0x184 [panfrost]) >(panfrost_probe [panfrost]) from [] > (platform_drv_probe+0x48/0x94) > > And the other: > >(debugfs_create_dir) from [] (create_regulator+0xe0/0x220) >(create_regulator) from [] (_regulator_get+0x168/0x204) >(_regulator_get) from [] (dev_pm_opp_set_regulators+0x6c/0x184) >(dev_pm_opp_set_regulators) from [] > (panfrost_devfreq_init+0x38/0x1ac [panfrost]) >(panfrost_devfreq_init [panfrost]) from [] > (panfrost_probe+0xc8/0x184 [panfrost]) >(panfrost_probe [panfrost]) from [] > (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 180.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 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On Tue, Apr 14, 2020 at 09:16:39PM +0200, Clément Péron wrote: > 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? Well, if you have a tasteful way of doing it I guess. signature.asc Description: PGP signature ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Liam and Mark, On Tue, 14 Apr 2020 at 15:10, Steven Price wrote: > > Hi Clément, > > On 13/04/2020 18:28, Clément Péron wrote: > > Hi Steven, > > > > On Mon, 13 Apr 2020 at 18:35, Clément Péron wrote: > >> > >> Hi Steven, > >> > >> On Mon, 13 Apr 2020 at 17:55, Steven Price wrote: > >>> > >>> On 13/04/2020 15:31, Clément Péron wrote: > Hi, > > On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: > > > > Hi Steven, > > > > On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: > >> > >> On 11/04/2020 21:06, Clément Péron wrote: > >>> OPP table can defined both frequency and voltage. > >>> > >>> Register the mali regulator if it exist. > >>> > >>> Signed-off-by: Clément Péron > >>> --- > >>> drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 > >>> ++--- > >>> drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > >>> 2 files changed, 31 insertions(+), 4 deletions(-) > >>> > >>> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > >>> b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > >>> index 62541f4edd81..2dc8e2355358 100644 > >>> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > >>> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > >>> @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device > >>> *pfdev) > >>> struct device *dev = >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, , 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. > > > >> > >>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 'ffa3.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 180.gpu: Features: L2:0x07110206 Shader:0x Tiler:0x0809 Mem:0x1 MMU:0x2821 AS:0xf JS:0x7 [2.913297] sunxi-ir 704.ir: initialized sunXi IR driver [2.919901] panfrost 180.gpu: shader_present=0x3 l2_present=0x1 [2.920497] panfrost 180.gpu: Looking up mali-supply from device tree [3.036568] vdd-gpu: could not add device link 180.gpu err -17 [3.036580] debugfs: Directory '180.gpu-mali' with parent 'vdd-gpu' already present! [3.046312] panfrost 180.gpu: [drm:panfrost_devfreq_init [panfrost]] Failed to register cooling device [3.056322] [drm] Initialized panfrost 1.1.0 20180908 for 180.gpu on minor 0 > > regulator is mount at : > > ./regulator/vdd-gpu > > whereas OPP is mount : > > ./opp/soc-180.gpu/opp:75600/supply-0/ > > Getting a backtrace from the two occurrences, I see one added from: > >(debugfs_create_dir) from [] (create_regulator+0xe0/0x220) >(create_regulator) from [] (_regulator_get+0x168/0x204) >(_regulator_get) from [] (regulator_bulk_get+0x64/0xf4) >(regulator_bulk_get) from [] > (devm_regulator_bulk_get+0x40/0x74) >(devm_regulator_bulk_get) from [] > (panfrost_device_init+0x1b4/0x48c [panfrost]) >(panfrost_device_init [panfrost]) from [] > (panfrost_probe+0x94/0x184 [panfrost]) >(panfrost_probe [panfrost]) from [] > (platform_drv_probe+0x48/0x94) > > And the other: > >(debugfs_create_dir) from [] (create_regulator+0xe0/0x220) >(create_regulator) from [] (_regulator_get+0x168/0x204) >(_regulator_get) from [] (dev_pm_opp_set_regulators+0x6c/0x184) >(dev_pm_opp_set_regulators) from [] > (panfrost_devfreq_init+0x38/0x1ac [panfrost]) >(panfrost_devfreq_init [panfrost]) from [] > (panfrost_probe+0xc8/0x184 [panfrost]) >(panfrost_probe [panfrost]) from [] > (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
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Mark, On Tue, 14 Apr 2020 at 20:55, Mark Brown wrote: > > On Tue, Apr 14, 2020 at 08:20:23PM +0200, Clément Péron wrote: > > 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, > > > 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. > > 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 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On Tue, Apr 14, 2020 at 08:20:23PM +0200, Clément Péron wrote: > 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. > 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. 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? signature.asc Description: PGP signature ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Clément, On 13/04/2020 18:28, Clément Péron wrote: Hi Steven, On Mon, 13 Apr 2020 at 18:35, Clément Péron wrote: Hi Steven, On Mon, 13 Apr 2020 at 17:55, Steven Price wrote: On 13/04/2020 15:31, Clément Péron wrote: Hi, On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: Hi Steven, On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: On 11/04/2020 21:06, Clément Péron wrote: OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = >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, , 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. 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 'ffa3.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-180.gpu/opp:75600/supply-0/ Getting a backtrace from the two occurrences, I see one added from: (debugfs_create_dir) from [] (create_regulator+0xe0/0x220) (create_regulator) from [] (_regulator_get+0x168/0x204) (_regulator_get) from [] (regulator_bulk_get+0x64/0xf4) (regulator_bulk_get) from [] (devm_regulator_bulk_get+0x40/0x74) (devm_regulator_bulk_get) from [] (panfrost_device_init+0x1b4/0x48c [panfrost]) (panfrost_device_init [panfrost]) from [] (panfrost_probe+0x94/0x184 [panfrost]) (panfrost_probe [panfrost]) from [] (platform_drv_probe+0x48/0x94) And the other: (debugfs_create_dir) from [] (create_regulator+0xe0/0x220) (create_regulator) from [] (_regulator_get+0x168/0x204) (_regulator_get) from [] (dev_pm_opp_set_regulators+0x6c/0x184) (dev_pm_opp_set_regulators) from [] (panfrost_devfreq_init+0x38/0x1ac [panfrost]) (panfrost_devfreq_init [panfrost]) from [] (panfrost_probe+0xc8/0x184 [panfrost]) (panfrost_probe [panfrost]) from [] (platform_drv_probe+0x48/0x94) Both are created at /regulator/vdd_gpu 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. 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 Regards, Clement 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 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 Steve ___ dri-devel mailing list dri-devel@lists.freedesktop.org
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On 2020-04-13 3:18 pm, Clément Péron wrote: Hi Steven, On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: On 11/04/2020 21:06, Clément Péron wrote: OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = >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, , 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. 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 dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven, On Mon, 13 Apr 2020 at 17:55, Steven Price wrote: > > On 13/04/2020 15:31, Clément Péron wrote: > > Hi, > > > > On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: > >> > >> Hi Steven, > >> > >> On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: > >>> > >>> On 11/04/2020 21:06, Clément Péron wrote: > OPP table can defined both frequency and voltage. > > Register the mali regulator if it exist. > > Signed-off-by: Clément Péron > --- > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- > drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > 2 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > index 62541f4edd81..2dc8e2355358 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device > *pfdev) > struct device *dev = >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, , 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. > >> > >>> > >>> 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 'ffa3.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? > > > > 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 > > 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 > > Steve ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven, On Mon, 13 Apr 2020 at 18:35, Clément Péron wrote: > > Hi Steven, > > On Mon, 13 Apr 2020 at 17:55, Steven Price wrote: > > > > On 13/04/2020 15:31, Clément Péron wrote: > > > Hi, > > > > > > On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: > > >> > > >> Hi Steven, > > >> > > >> On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: > > >>> > > >>> On 11/04/2020 21:06, Clément Péron wrote: > > OPP table can defined both frequency and voltage. > > > > Register the mali regulator if it exist. > > > > Signed-off-by: Clément Péron > > --- > > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 > > ++--- > > drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > > 2 files changed, 31 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > index 62541f4edd81..2dc8e2355358 100644 > > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device > > *pfdev) > > struct device *dev = >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, , 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. > > >> > > >>> > > >>> 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 'ffa3.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-180.gpu/opp:75600/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 > > >>> > > >>> 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 > > > > 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 > > > > > Steve ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Steven, On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: > > On 11/04/2020 21:06, Clément Péron wrote: > > OPP table can defined both frequency and voltage. > > > > Register the mali regulator if it exist. > > > > Signed-off-by: Clément Péron > > --- > > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- > > drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > > 2 files changed, 31 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > index 62541f4edd81..2dc8e2355358 100644 > > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) > > struct device *dev = >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, , 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. > > 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 'ffa3.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 > > 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/20200112001623.2121227-1-martin.blumensti...@googlemail.com/ > > > > + 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(>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) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h > > b/drivers/gpu/drm/panfrost/panfrost_device.h > > index 06713811b92c..f6b0c779dfe5 100644 > > --- a/drivers/gpu/drm/panfrost/panfrost_device.h > > +++ b/drivers/gpu/drm/panfrost/panfrost_device.h > > @@ -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 dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi, On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: > > Hi Steven, > > On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: > > > > On 11/04/2020 21:06, Clément Péron wrote: > > > OPP table can defined both frequency and voltage. > > > > > > Register the mali regulator if it exist. > > > > > > Signed-off-by: Clément Péron > > > --- > > > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- > > > drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > > > 2 files changed, 31 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > > index 62541f4edd81..2dc8e2355358 100644 > > > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > > > @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device > > > *pfdev) > > > struct device *dev = >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, , 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. > > > > > 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 'ffa3.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? 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 > > Link to original discussion: > https://lore.kernel.org/patchwork/patch/1176717/ > > Thanks, > Clement > > > > > 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/20200112001623.2121227-1-martin.blumensti...@googlemail.com/ > > > > > > > + 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(>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) > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h > > > b/drivers/gpu/drm/panfrost/panfrost_device.h > > > index 06713811b92c..f6b0c779dfe5 100644 > > > --- a/drivers/gpu/drm/panfrost/panfrost_device.h > > > +++ b/drivers/gpu/drm/panfrost/panfrost_device.h > > > @@ -86,6 +86,7 @@ struct panfrost_device { > > > struct { > > >
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
Hi Panfrost and OPP Maintainers, On Sat, 11 Apr 2020 at 22:06, Clément Péron wrote: > > 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 180.gpu: [drm:panfrost_devfreq_init [panfrost]] Failed to register cooling device Do you see what I'm missing? Thanks for your help, Clement > > Signed-off-by: Clément Péron > --- > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- > drivers/gpu/drm/panfrost/panfrost_device.h | 1 + > 2 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > index 62541f4edd81..2dc8e2355358 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) > struct device *dev = >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, , 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(>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) > diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h > b/drivers/gpu/drm/panfrost/panfrost_device.h > index 06713811b92c..f6b0c779dfe5 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_device.h > +++ b/drivers/gpu/drm/panfrost/panfrost_device.h > @@ -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 > ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On 13/04/2020 15:31, Clément Péron wrote: Hi, On Mon, 13 Apr 2020 at 16:18, Clément Péron wrote: Hi Steven, On Mon, 13 Apr 2020 at 15:18, Steven Price wrote: On 11/04/2020 21:06, Clément Péron wrote: OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = >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, , 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. 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 'ffa3.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? 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 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 dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/panfrost: add devfreq regulator support
On 11/04/2020 21:06, Clément Péron wrote: OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = >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, , 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 'ffa3.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 [1] https://lore.kernel.org/dri-devel/20200112001623.2121227-1-martin.blumensti...@googlemail.com/ + 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(>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) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 06713811b92c..f6b0c779dfe5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -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 dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm/panfrost: add devfreq regulator support
OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = >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, , 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(>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) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 06713811b92c..f6b0c779dfe5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -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 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel