Add dts for mt8183 GPU (and misc panfrost patches)
Subsystems (5)
v3 cover Add dts for mt8183 GPU (and misc panfrost patches)
Hi!
Follow-up on the v2: https://patchwork.kernel.org/cover/11322801/ .
The main purpose of this series is to upstream the dts change and the binding document, but I wanted to see how far I could probe the GPU, to check that the binding is indeed correct. The rest of the patches are RFC/work-in-progress, but I think some of them could already be picked up.
So this is tested on MT8183 with a chromeos-4.19 kernel, and a ton of backports to get the latest panfrost driver (I should probably try on linux-next at some point but this was the path of least resistance).
I tested it as a module as it's more challenging (originally probing would work built-in, on boot, but not as a module, as I didn't have the power domain changes, and all power domains are on by default during boot).
Probing logs looks like this, currently. They look sane.
[ 501.319728] panfrost 13040000.gpu: clock rate = 511999970 [ 501.320041] panfrost 13040000.gpu: Linked as a consumer to regulator.14 [ 501.320102] panfrost 13040000.gpu: Linked as a consumer to regulator.31 [ 501.320651] panfrost 13040000.gpu: Linked as a consumer to genpd:0:13040000.gpu [ 501.320954] panfrost 13040000.gpu: Linked as a consumer to genpd:1:13040000.gpu [ 501.321062] panfrost 13040000.gpu: Linked as a consumer to genpd:2:13040000.gpu [ 501.321734] panfrost 13040000.gpu: mali-g72 id 0x6221 major 0x0 minor 0x3 status 0x0 [ 501.321741] panfrost 13040000.gpu: features: 00000000,13de77ff, issues: 00000000,00000400 [ 501.321747] panfrost 13040000.gpu: Features: L2:0x07120206 Shader:0x00000000 Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7 [ 501.321752] panfrost 13040000.gpu: shader_present=0x7 l2_present=0x1 [ 501.324951] [drm] Initialized panfrost 1.1.0 20180908 for 13040000.gpu on minor 2
Some more changes are still required to get devfreq working, and of course I do not have a userspace driver to test this with.
Thanks!
Nicolas
v3 (see individual patches, too):
- Match a specific mediatek,mt8183-mali instead of the generic bifrost, as this instance requires 2 special cases:
- 2 regulators
- 3 power domains
v2:
- Use sram instead of mali_sram as SRAM supply name.
- Rename mali@ to gpu@.
- Add dt-bindings changes
- Stacking patches after the device tree change that allow basic probing (still incomplete and broken).
Nicolas Boichat (7):
dt-bindings: gpu: mali-bifrost: Add Mediatek MT8183
arm64: dts: mt8183: Add node for the Mali GPU drm/panfrost: Improve error reporting in panfrost_gpu_power_on drm/panfrost: Add support for multiple regulators drm/panfrost: Add support for multiple power domains
RFC: drm/panfrost: Add mt8183-mali compatible string
RFC: drm/panfrost: devfreq: Add support for 2 regulators
.../bindings/gpu/arm,mali-bifrost.yaml | 18 +++ arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 7 + arch/arm64/boot/dts/mediatek/mt8183.dtsi | 104 +++++++++++++++ drivers/gpu/drm/panfrost/panfrost_devfreq.c | 17 +++ drivers/gpu/drm/panfrost/panfrost_device.c | 120 +++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 25 +++- drivers/gpu/drm/panfrost/panfrost_drv.c | 38 ++++-- drivers/gpu/drm/panfrost/panfrost_gpu.c | 11 +- 8 files changed, 310 insertions(+), 30 deletions(-)
Signature · 1 line
2.25.0.rc1.283.g88dfdc4193-goog
PATCH v3 1/7 dt-bindings: gpu: mali-bifrost: Add Mediatek MT8183
Define a compatible string for the Mali Bifrost GPU found in Mediatek's MT8183 SoCs.
---
v3:
- No change
.../bindings/gpu/arm,mali-bifrost.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml +18 -0
@@ -17,6 +17,7 @@ properties: items: - enum: - amlogic,meson-g12a-mali + - mediatek,mt8183-mali - realtek,rtd1619-mali - rockchip,px30-mali - const: arm,mali-bifrost # Mali Bifrost GPU model/revision is fully discoverable
@@ -62,6 +63,23 @@ allOf: minItems: 2 required: - resets + - if: + properties: + compatible: + contains: + const: mediatek,mt8183-mali + then: + properties: + sram-supply: true + power-domains: + description: + List of phandle and PM domain specifier as documented in + Documentation/devicetree/bindings/power/power_domain.txt + minItems: 3 + maxItems: 3 + required: + - sram-supply + - power-domains examples: - |
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/7 arm64: dts: mt8183: Add node for the Mali GPU
In reply to Nicolas BoichatAdd a basic GPU node for mt8183.
---
Upstreaming what matches existing bindings from our Chromium OS tree:
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-4.19/arch/arm64/boot/dts/mediatek/mt8183.dtsi#1348
The evb part of this change depends on this patch to add PMIC dtsi:
https://patchwork.kernel.org/patch/10928161/
The binding we use with out-of-tree Mali drivers includes more
clocks, this is used for devfreq: the out-of-tree driver switchesclk_mux to clk_sub_parent (26Mhz), adjusts clk_main_parent, then
switches clk_mux back to clk_main_parent:
(see https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-4.19/drivers/gpu/arm/midgard/platform/mediatek/mali_kbase_runtime_pm.c#423)
clocks =
<&topckgen CLK_TOP_MFGPLL_CK>,
<&topckgen CLK_TOP_MUX_MFG>,
<&clk26m>,
<&mfgcfg CLK_MFG_BG3D>;
clock-names =
"clk_main_parent",
"clk_mux",
"clk_sub_parent",
"subsys_mfg_cg";v3:
- No changes
v2:
- Use sram instead of mali_sram as SRAM supply name.
- Rename mali@ to gpu@.
arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 7 ++ arch/arm64/boot/dts/mediatek/mt8183.dtsi | 104 ++++++++++++++++++++ 2 files changed, 111 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183-evb.dts +7 -0
@@ -7,6 +7,7 @@ /dts-v1/; #include "mt8183.dtsi" +#include "mt6358.dtsi" / { model = "MediaTek MT8183 evaluation board";
@@ -30,6 +31,12 @@ &auxadc { status = "okay"; }; +&gpu { + supply-names = "mali", "sram"; + mali-supply = <&mt6358_vgpu_reg>; + sram-supply = <&mt6358_vsram_gpu_reg>; +}; + &i2c0 { pinctrl-names = "default"; pinctrl-0 = <&i2c_pins_0>;
arch/arm64/boot/dts/mediatek/mt8183.dtsi +104 -0
110 lines not on this page · raw message
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 3/7 drm/panfrost: Improve error reporting in panfrost_gpu_power_on
In reply to Nicolas BoichatIt is useful to know which component cannot be powered on.
---
Was useful when trying to probe Bifrost GPU, to understand what issue we are facing.
v3:
- Rebased on https://patchwork.kernel.org/patch/11325689/
drivers/gpu/drm/panfrost/panfrost_gpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/panfrost/panfrost_gpu.c +7 -4
@@ -308,17 +308,20 @@ void panfrost_gpu_power_on(struct panfrost_device *pfdev)gpu_write (pfdev,L2_PWRON_LO , pfdev->features.l2_present); ret =readl_relaxed_poll_timeout (pfdev->iomem +L2_READY_LO , val, val == pfdev->features.l2_present,100 ,1000 ); +if (ret) +dev_err (pfdev->dev,"error powering up gpu L2" );gpu_write (pfdev,SHADER_PWRON_LO , pfdev->features.shader_present); - ret |=readl_relaxed_poll_timeout (pfdev->iomem +SHADER_READY_LO , + ret =readl_relaxed_poll_timeout (pfdev->iomem +SHADER_READY_LO , val, val == pfdev->features.shader_present,100 ,1000 ); +if (ret) +dev_err (pfdev->dev,"error powering up gpu shader" );gpu_write (pfdev,TILER_PWRON_LO , pfdev->features.tiler_present); - ret |=readl_relaxed_poll_timeout (pfdev->iomem +TILER_READY_LO , + ret =readl_relaxed_poll_timeout (pfdev->iomem +TILER_READY_LO , val, val == pfdev->features.tiler_present,100 ,1000 ); -if (ret) -dev_err (pfdev->dev,"error powering up gpu" ); +dev_err (pfdev->dev,"error powering up gpu tiler" ); }void panfrost_gpu_power_off (struct panfrost_device *pfdev)
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 4/7 drm/panfrost: Add support for multiple regulators
In reply to Nicolas BoichatSome GPUs, namely, the bifrost/g72 part on MT8183, have a second regulator for their SRAM, let's add support for that.
We extend the framework in a generic manner so that we could support more than 2 regulators, if required.
---
v3:
- Make this more generic, by allowing any number of regulators (in practice we fix the maximum number of regulators to 2, but this could be increased easily).
- We only probe the second regulator if the device tree matching data asks for it.
- I couldn't find a way to detect the number of regulators in the device tree, if we wanted to refuse to probe the device if there are too many regulators, which might be required for safety, see the thread on v2 [1].
- The discussion also included the idea of a separate device tree entry for a "soft PDC", or at least a separate driver. I'm not sure to understand the full picture, and how different vendors implement this, so I'm still integrating everything in the main driver. I'd be happy to try to make mt8183 fit into such a framework after it's created, but I don't think I'm best placed to implement (and again, the main purpose of this was to test if the binding is correct).
[1] https://patchwork.kernel.org/patch/11322839/
drivers/gpu/drm/panfrost/panfrost_device.c | 25 ++++++++++++------- drivers/gpu/drm/panfrost/panfrost_device.h | 15 +++++++++++- drivers/gpu/drm/panfrost/panfrost_drv.c | 28 +++++++++++++++------- 3 files changed, 50 insertions(+), 18 deletions(-)
drivers/gpu/drm/panfrost/panfrost_device.c +17 -8
@@ -87,18 +87,26 @@ static void panfrost_clk_fini(struct panfrost_device *pfdev)static int panfrost_regulator_init (struct panfrost_device *pfdev) { -int ret; +int ret, i; - pfdev->regulator =devm_regulator_get (pfdev->dev,"mali" ); -if (IS_ERR (pfdev->regulator)) { - ret =PTR_ERR (pfdev->regulator); -dev_err (pfdev->dev,"failed to get regulator: %d\n" , ret); +BUG_ON (pfdev->comp->num_supplies >ARRAY_SIZE (pfdev->regulators)); + +for (i =0 ; i < pfdev->comp->num_supplies; i++) { + pfdev->regulators[i].supply = pfdev->comp->supply_names[i]; + } + + ret =devm_regulator_bulk_get (pfdev->dev, + pfdev->comp->num_supplies, + pfdev->regulators); +if (ret <0 ) { +dev_err (pfdev->dev,"failed to get regulators: %d\n" , ret);return ret; } - ret =regulator_enable (pfdev->regulator); + ret =regulator_bulk_enable (pfdev->comp->num_supplies, + pfdev->regulators);if (ret <0 ) { -dev_err (pfdev->dev,"failed to enable regulator: %d\n" , ret); +dev_err (pfdev->dev,"failed to enable regulators: %d\n" , ret);return ret; }
@@ -107,7 +115,8 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev)static void panfrost_regulator_fini (struct panfrost_device *pfdev) { -regulator_disable (pfdev->regulator); +regulator_bulk_disable (pfdev->comp->num_supplies, + pfdev->regulators); }int panfrost_device_init (struct panfrost_device *pfdev)
drivers/gpu/drm/panfrost/panfrost_device.h +14 -1
@@ -7,6 +7,7 @@#include <linux/atomic.h> #include <linux/io-pgtable.h> +#include <linux/regulator/consumer.h> #include <linux/spinlock.h> #include <drm/drm_device.h> #include <drm/drm_mm.h>
@@ -19,6 +20,7 @@ struct panfrost_job;struct panfrost_perfcnt ;#define NUM_JOB_SLOTS 3 +#define MAX_REGULATORS 2struct panfrost_features {u16 id;
@@ -51,6 +53,16 @@ struct panfrost_features {unsigned long hw_issues[64 /BITS_PER_LONG ]; }; +/* +* Features that cannot be automatically detected and need matching using the +* compatible string, typically SoC-specific. +*/ +struct panfrost_compatible { +/* Supplies count and names. */ +int num_supplies; +const char *const *supply_names; +}; +struct panfrost_device {struct device *dev;struct drm_device *ddev;
@@ -59,10 +71,11 @@ struct panfrost_device {void __iomem *iomem;struct clk *clock;struct clk *bus_clock; -struct regulator *regulator; +struct regulator_bulk_data regulators[MAX_REGULATORS ];struct reset_control *rstc;struct panfrost_features features; +const struct panfrost_compatible * comp;spinlock_t as_lock;unsigned long as_in_use_mask;
drivers/gpu/drm/panfrost/panfrost_drv.c +19 -9
@@ -510,6 +510,10 @@ static int panfrost_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pfdev); + pfdev->comp =of_device_get_match_data (&pdev->dev); +if (!pfdev->comp) +return -ENODEV ; +/* Allocate and initialze the DRM device. */ ddev =drm_dev_alloc (&panfrost_drm_driver, &pdev->dev);if (IS_ERR (ddev))
@@ -581,16 +585,22 @@ static int panfrost_remove(struct platform_device *pdev)return 0 ; } +const char *const default_supplies[] = {"mali" }; +static const struct panfrost_compatible default_data = { + .num_supplies =ARRAY_SIZE (default_supplies), + .supply_names = default_supplies, +}; +static const struct of_device_id dt_match[] = { - { .compatible ="arm,mali-t604" }, - { .compatible ="arm,mali-t624" }, - { .compatible ="arm,mali-t628" }, - { .compatible ="arm,mali-t720" }, - { .compatible ="arm,mali-t760" }, - { .compatible ="arm,mali-t820" }, - { .compatible ="arm,mali-t830" }, - { .compatible ="arm,mali-t860" }, - { .compatible ="arm,mali-t880" }, + { .compatible ="arm,mali-t604" , .data = &default_data, }, + { .compatible ="arm,mali-t624" , .data = &default_data, }, + { .compatible ="arm,mali-t628" , .data = &default_data, }, + { .compatible ="arm,mali-t720" , .data = &default_data, }, + { .compatible ="arm,mali-t760" , .data = &default_data, }, + { .compatible ="arm,mali-t820" , .data = &default_data, }, + { .compatible ="arm,mali-t830" , .data = &default_data, }, + { .compatible ="arm,mali-t860" , .data = &default_data, }, + { .compatible ="arm,mali-t880" , .data = &default_data, }, {} };MODULE_DEVICE_TABLE (of, dt_match);
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
Quoted 4 lines · Nicolas Boichat
- I couldn't find a way to detect the number of regulators in the device tree, if we wanted to refuse to probe the device if there are too many regulators, which might be required for safety, see the thread on v2 [1].
You'd need to enumerate all the properties of the device and look for things matching *-supply.
Re: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
Quoted 10 lines · Mark Brown
Quoted 4 lines · Nicolas Boichat
- I couldn't find a way to detect the number of regulators in the device tree, if we wanted to refuse to probe the device if there are too many regulators, which might be required for safety, see the thread on v2 [1].
You'd need to enumerate all the properties of the device and look for things matching *-supply.
I see ,-) I was hoping for something slightly cleaner, or maybe an existing function in the core.
Steven: How strongly do you feel about this? If so I can add that check in the next revision.
Also, just a heads-up, I'm out for the next 2 weeks, I'll send v4 after that.
Quoted 2 lines
Reviewed-by Mark Brown <[email protected]>
Steven Price
maintainerRe: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
Quoted 9 lines · Nicolas Boichat
Quoted 8 lines · Mark Brown
Quoted 4 lines · Nicolas Boichat
- I couldn't find a way to detect the number of regulators in the device tree, if we wanted to refuse to probe the device if there are too many regulators, which might be required for safety, see the thread on v2 [1].
Quoted 8 lines
Quoted 2 lines
You'd need to enumerate all the properties of the device and look for things matching *-supply.
I see ,-) I was hoping for something slightly cleaner, or maybe an existing function in the core.
Steven: How strongly do you feel about this? If so I can add that check in the next revision.
I'm not that strongly bothered about it - my only worry is that there may be hardware out there that might be broken by not activating a regulator. But I don't know how common this multi-regulator design is in practise.
Thanks,
Steve
Quoted 9 lines
Also, just a heads-up, I'm out for the next 2 weeks, I'll send v4 after that.
Quoted 2 lines
Reviewed-by Mark Brown <[email protected]>_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Steven Price
maintainerRe: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
In reply to Nicolas BoichatQuoted 20 lines · Nicolas Boichat
Some GPUs, namely, the bifrost/g72 part on MT8183, have a second regulator for their SRAM, let's add support for that.
We extend the framework in a generic manner so that we could support more than 2 regulators, if required.
Signed-off-by Nicolas Boichat <[email protected]>---
v3:
- Make this more generic, by allowing any number of regulators (in practice we fix the maximum number of regulators to 2, but this could be increased easily).
- We only probe the second regulator if the device tree matching data asks for it.
- I couldn't find a way to detect the number of regulators in the device tree, if we wanted to refuse to probe the device if there are too many regulators, which might be required for safety, see the thread on v2 [1].
Quoted 8 lines
- The discussion also included the idea of a separate device tree entry for a "soft PDC", or at least a separate driver. I'm not sure to understand the full picture, and how different vendors implement this, so I'm still integrating everything in the main driver. I'd be happy to try to make mt8183 fit into such a framework after it's created, but I don't think I'm best placed to implement (and again, the main purpose of this was to test if the binding is correct).
From discussions offline, I think I've come round to the view that having a "soft PDC" in device tree isn't the right solution. Device tree should be describing the hardware and that isn't actually a hardware component.
I guess we'll have to wait to see how many devices have a similar 'quirk' and whether it's worth representing this is software in a more generic manner, or if matching on compatible strings will be sufficient for the devices that need multiple regulators.
One (minor) comment below, but otherwise LGTM.
Quoted 122 lines
[1] https://patchwork.kernel.org/patch/11322839/
drivers/gpu/drm/panfrost/panfrost_device.c | 25 ++++++++++++------- drivers/gpu/drm/panfrost/panfrost_device.h | 15 +++++++++++- drivers/gpu/drm/panfrost/panfrost_drv.c | 28 +++++++++++++++------- 3 files changed, 50 insertions(+), 18 deletions(-)drivers/gpu/drm/panfrost/panfrost_device.c +17
-8@@ -87,18 +87,26 @@ static void panfrost_clk_fini(struct panfrost_device *pfdev)static int panfrost_regulator_init (struct panfrost_device *pfdev) { -int ret; +int ret, i; - pfdev->regulator =devm_regulator_get (pfdev->dev,"mali" ); -if (IS_ERR (pfdev->regulator)) { - ret =PTR_ERR (pfdev->regulator); -dev_err (pfdev->dev,"failed to get regulator: %d\n" , ret); +BUG_ON (pfdev->comp->num_supplies >ARRAY_SIZE (pfdev->regulators)); + +for (i =0 ; i < pfdev->comp->num_supplies; i++) { + pfdev->regulators[i].supply = pfdev->comp->supply_names[i]; + } + + ret =devm_regulator_bulk_get (pfdev->dev, + pfdev->comp->num_supplies, + pfdev->regulators); +if (ret <0 ) { +dev_err (pfdev->dev,"failed to get regulators: %d\n" , ret);return ret; } - ret =regulator_enable (pfdev->regulator); + ret =regulator_bulk_enable (pfdev->comp->num_supplies, + pfdev->regulators);if (ret <0 ) { -dev_err (pfdev->dev,"failed to enable regulator: %d\n" , ret); +dev_err (pfdev->dev,"failed to enable regulators: %d\n" , ret);return ret; }@@ -107,7 +115,8 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev)static void panfrost_regulator_fini (struct panfrost_device *pfdev) { -regulator_disable (pfdev->regulator); +regulator_bulk_disable (pfdev->comp->num_supplies, + pfdev->regulators); }int panfrost_device_init (struct panfrost_device *pfdev)drivers/gpu/drm/panfrost/panfrost_device.h +14
-1@@ -7,6 +7,7 @@#include <linux/atomic.h> #include <linux/io-pgtable.h> +#include <linux/regulator/consumer.h> #include <linux/spinlock.h> #include <drm/drm_device.h> #include <drm/drm_mm.h> @@ -19,6 +20,7 @@ struct panfrost_job;struct panfrost_perfcnt ;#define NUM_JOB_SLOTS 3 +#define MAX_REGULATORS 2struct panfrost_features {u16 id;@@ -51,6 +53,16 @@ struct panfrost_features {unsigned long hw_issues[64 /BITS_PER_LONG ]; }; +/* +* Features that cannot be automatically detected and need matching using the +* compatible string, typically SoC-specific. +*/ +struct panfrost_compatible { +/* Supplies count and names. */ +int num_supplies; +const char *const *supply_names; +}; +struct panfrost_device {struct device *dev;struct drm_device *ddev;@@ -59,10 +71,11 @@ struct panfrost_device {void __iomem *iomem;struct clk *clock;struct clk *bus_clock; -struct regulator *regulator; +struct regulator_bulk_data regulators[MAX_REGULATORS ];struct reset_control *rstc;struct panfrost_features features; +const struct panfrost_compatible * comp;spinlock_t as_lock;unsigned long as_in_use_mask;drivers/gpu/drm/panfrost/panfrost_drv.c +4
-0@@ -510,6 +510,10 @@ static int panfrost_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pfdev); + pfdev->comp =of_device_get_match_data (&pdev->dev); +if (!pfdev->comp) +return -ENODEV ; +/* Allocate and initialze the DRM device. */ ddev =drm_dev_alloc (&panfrost_drm_driver, &pdev->dev);if (IS_ERR (ddev))
drivers/gpu/drm/panfrost/panfrost_drv.c static int panfrost_remove(struct platform_device *pdev) · line 588
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +1
-0@@ -581,16 +585,22 @@ static int panfrost_remove(struct platform_device *pdev)return 0 ; } +const char *const default_supplies[] = {"mali" };
This should be static.
Steve
Quoted 28 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +14
-9+static const struct panfrost_compatible default_data = { + .num_supplies =ARRAY_SIZE (default_supplies), + .supply_names = default_supplies, +}; +static const struct of_device_id dt_match[] = { - { .compatible ="arm,mali-t604" }, - { .compatible ="arm,mali-t624" }, - { .compatible ="arm,mali-t628" }, - { .compatible ="arm,mali-t720" }, - { .compatible ="arm,mali-t760" }, - { .compatible ="arm,mali-t820" }, - { .compatible ="arm,mali-t830" }, - { .compatible ="arm,mali-t860" }, - { .compatible ="arm,mali-t880" }, + { .compatible ="arm,mali-t604" , .data = &default_data, }, + { .compatible ="arm,mali-t624" , .data = &default_data, }, + { .compatible ="arm,mali-t628" , .data = &default_data, }, + { .compatible ="arm,mali-t720" , .data = &default_data, }, + { .compatible ="arm,mali-t760" , .data = &default_data, }, + { .compatible ="arm,mali-t820" , .data = &default_data, }, + { .compatible ="arm,mali-t830" , .data = &default_data, }, + { .compatible ="arm,mali-t860" , .data = &default_data, }, + { .compatible ="arm,mali-t880" , .data = &default_data, }, {} };MODULE_DEVICE_TABLE (of, dt_match);
Re: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
Quoted 4 lines · Steven Price
From discussions offline, I think I've come round to the view that having a "soft PDC" in device tree isn't the right solution. Device tree should be describing the hardware and that isn't actually a hardware component.
You can use an implementation like that separately to it being in the device tree, it is perfectly possible to instantiate devices that have no representation at all in device tree based on other things that are there like board or SoC information, or as subdevices of things that are there.
Steven Price
maintainerRe: [PATCH v3 4/7] drm/panfrost: Add support for multiple regulators
Quoted 7 lines · Mark Brown
Quoted 4 lines · Steven Price
From discussions offline, I think I've come round to the view that having a "soft PDC" in device tree isn't the right solution. Device tree should be describing the hardware and that isn't actually a hardware component.
Quoted 5 lines
You can use an implementation like that separately to it being in the device tree, it is perfectly possible to instantiate devices that have no representation at all in device tree based on other things that are there like board or SoC information, or as subdevices of things that are there.
Yes - and I may yet implement a "soft PDC" device if this turns out to be more than a 'quirk' for a very small number of device. But like you say - it doesn't need to be (and shouldn't be) in the actual device tree.
For now though I think the code Nicolas has written works well enough and it's only really worth 'fixing' if we end up with too many 'quirky' devices.
Steve
PATCH v3 5/7 drm/panfrost: Add support for multiple power domains
In reply to Nicolas BoichatWhen there is a single power domain per device, the core will ensure the power domain is switched on (so it is technically equivalent to having not power domain specified at all).
However, when there are multiple domains, as in MT8183 Bifrost GPU, we need to handle them in driver code.
---
The downstream driver we use on chromeos-4.19 currently uses 2 additional devices in device tree to accomodate for this [1], but I believe this solution is cleaner.
v3:
- Use the compatible matching data to specify the number of power domains. Note that setting 0 or 1 in num_pm_domains is equivalent as the core will handle these 2 cases in the exact same way (automatically, without driver intervention), and there should be no adverse consequence in this case (the concern is about switching on only some power domains and not others).
drivers/gpu/drm/panfrost/panfrost_device.c | 95 ++++++++++++++++++++-- drivers/gpu/drm/panfrost/panfrost_device.h | 9 ++ drivers/gpu/drm/panfrost/panfrost_drv.c | 1 + 3 files changed, 97 insertions(+), 8 deletions(-)
drivers/gpu/drm/panfrost/panfrost_device.c +87 -8
@@ -5,6 +5,7 @@#include <linux/clk.h> #include <linux/reset.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regulator/consumer.h> #include "panfrost_device.h"
@@ -119,6 +120,75 @@ static void panfrost_regulator_fini(struct panfrost_device *pfdev) pfdev->regulators); } +static void panfrost_pm_domain_fini (struct panfrost_device *pfdev) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (pfdev->pm_domain_devs); i++) { +if (!pfdev->pm_domain_devs[i]) +break ; + +if (pfdev->pm_domain_links[i]) +device_link_del (pfdev->pm_domain_links[i]); + +dev_pm_domain_detach (pfdev->pm_domain_devs[i], true); + } +} + +static int panfrost_pm_domain_init (struct panfrost_device *pfdev) +{ +int err; +int i, num_domains; + + num_domains =of_count_phandle_with_args (pfdev->dev->of_node, +"power-domains" , +"#power-domain-cells" ); + +/* +* Single domain is handled by the core, and, if only a single power +* the power domain is requested, the property is optional. +*/ +if (num_domains <2 && pfdev->comp->num_pm_domains <2 ) +return 0 ; + +if (num_domains != pfdev->comp->num_pm_domains) { +dev_err (pfdev->dev, +"Incorrect number of power domains: %d provided, %d needed\n" , + num_domains, pfdev->comp->num_pm_domains); +return -EINVAL ; + } + +BUG_ON (num_domains >ARRAY_SIZE (pfdev->pm_domain_devs)); + +for (i =0 ; i < num_domains; i++) { + pfdev->pm_domain_devs[i] = +dev_pm_domain_attach_by_id (pfdev->dev, i); +if (IS_ERR (pfdev->pm_domain_devs[i])) { + err =PTR_ERR (pfdev->pm_domain_devs[i]); + pfdev->pm_domain_devs[i] =NULL ; +dev_err (pfdev->dev, +"failed to get pm-domain %d: %d\n" , i, err); + goto err; + } + + pfdev->pm_domain_links[i] =device_link_add (pfdev->dev, + pfdev->pm_domain_devs[i],DL_FLAG_PM_RUNTIME | +DL_FLAG_STATELESS |DL_FLAG_RPM_ACTIVE ); +if (!pfdev->pm_domain_links[i]) { +dev_err (pfdev->pm_domain_devs[i], +"adding device link failed!\n" ); + err = -ENODEV ; + goto err; + } + } + +return 0 ; + +err: +panfrost_pm_domain_fini (pfdev); +return err; +} +int panfrost_device_init (struct panfrost_device *pfdev) {int err;
@@ -149,37 +219,45 @@ int panfrost_device_init(struct panfrost_device *pfdev) goto err_out1; } + err =panfrost_pm_domain_init (pfdev); +if (err) { +dev_err (pfdev->dev,"pm_domain init failed %d\n" , err); + goto err_out2; + } + res =platform_get_resource (pfdev->pdev,IORESOURCE_MEM ,0 ); pfdev->iomem =devm_ioremap_resource (pfdev->dev, res);if (IS_ERR (pfdev->iomem)) {dev_err (pfdev->dev,"failed to ioremap iomem\n" ); err =PTR_ERR (pfdev->iomem); - goto err_out2; + goto err_out3; } err =panfrost_gpu_init (pfdev);if (err) - goto err_out2; + goto err_out3; err =panfrost_mmu_init (pfdev);if (err) - goto err_out3; + goto err_out4; err =panfrost_job_init (pfdev);if (err) - goto err_out4; + goto err_out5; err =panfrost_perfcnt_init (pfdev);if (err) - goto err_out5; + goto err_out6;return 0 ; -err_out5: +err_out6:panfrost_job_fini (pfdev); -err_out4: +err_out5:panfrost_mmu_fini (pfdev); -err_out3: +err_out4:panfrost_gpu_fini (pfdev); +err_out3: +panfrost_pm_domain_fini (pfdev); err_out2:panfrost_reset_fini (pfdev); err_out1:
@@ -196,6 +274,7 @@ void panfrost_device_fini(struct panfrost_device *pfdev)panfrost_mmu_fini (pfdev);panfrost_gpu_fini (pfdev);panfrost_reset_fini (pfdev); +panfrost_pm_domain_fini (pfdev);panfrost_regulator_fini (pfdev);panfrost_clk_fini (pfdev); }
drivers/gpu/drm/panfrost/panfrost_device.h +9 -0
@@ -21,6 +21,7 @@ struct panfrost_perfcnt;#define NUM_JOB_SLOTS 3#define MAX_REGULATORS 2 +#define MAX_PM_DOMAINS 3struct panfrost_features {u16 id;
@@ -61,6 +62,11 @@ struct panfrost_compatible {/* Supplies count and names. */ int num_supplies;const char *const *supply_names; +/* +* Number of power domains required, note that values 0 and 1 are +* handled identically, as only values > 1 need special handling. +*/ +int num_pm_domains; };struct panfrost_device {
@@ -73,6 +79,9 @@ struct panfrost_device {struct clk *bus_clock;struct regulator_bulk_data regulators[MAX_REGULATORS ];struct reset_control *rstc; +/* pm_domains for devices with more than one. */ +struct device *pm_domain_devs[MAX_PM_DOMAINS ]; +struct device_link *pm_domain_links[MAX_PM_DOMAINS ];struct panfrost_features features;const struct panfrost_compatible * comp;
drivers/gpu/drm/panfrost/panfrost_drv.c +1 -0
@@ -589,6 +589,7 @@ const char * const default_supplies[] = { "mali" };static const struct panfrost_compatible default_data = { .num_supplies =ARRAY_SIZE (default_supplies), .supply_names = default_supplies, + .num_pm_domains =1 ,/* optional */ };static const struct of_device_id dt_match[] = {
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Steven Price
maintainerRe: [PATCH v3 5/7] drm/panfrost: Add support for multiple power domains
Quoted 119 lines · Nicolas Boichat
When there is a single power domain per device, the core will ensure the power domain is switched on (so it is technically equivalent to having not power domain specified at all).
However, when there are multiple domains, as in MT8183 Bifrost GPU, we need to handle them in driver code.
Signed-off-by Nicolas Boichat <[email protected]>---
The downstream driver we use on chromeos-4.19 currently uses 2 additional devices in device tree to accomodate for this [1], but I believe this solution is cleaner.
v3:
- Use the compatible matching data to specify the number of power domains. Note that setting 0 or 1 innum_pm_domainsis equivalent as the core will handle these 2 cases in the exact same way (automatically, without driver intervention), and there should be no adverse consequence in this case (the concern is about switching on only some power domains and not others).drivers/gpu/drm/panfrost/panfrost_device.c | 95 ++++++++++++++++++++-- drivers/gpu/drm/panfrost/panfrost_device.h | 9 ++ drivers/gpu/drm/panfrost/panfrost_drv.c | 1 + 3 files changed, 97 insertions(+), 8 deletions(-)drivers/gpu/drm/panfrost/panfrost_device.c +70
-0@@ -5,6 +5,7 @@#include <linux/clk.h> #include <linux/reset.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regulator/consumer.h> #include "panfrost_device.h" @@ -119,6 +120,75 @@ static void panfrost_regulator_fini(struct panfrost_device *pfdev) pfdev->regulators); } +static void panfrost_pm_domain_fini (struct panfrost_device *pfdev) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (pfdev->pm_domain_devs); i++) { +if (!pfdev->pm_domain_devs[i]) +break ; + +if (pfdev->pm_domain_links[i]) +device_link_del (pfdev->pm_domain_links[i]); + +dev_pm_domain_detach (pfdev->pm_domain_devs[i], true); + } +} + +static int panfrost_pm_domain_init (struct panfrost_device *pfdev) +{ +int err; +int i, num_domains; + + num_domains =of_count_phandle_with_args (pfdev->dev->of_node, +"power-domains" , +"#power-domain-cells" ); + +/* +* Single domain is handled by the core, and, if only a single power +* the power domain is requested, the property is optional. +*/ +if (num_domains <2 && pfdev->comp->num_pm_domains <2 ) +return 0 ; + +if (num_domains != pfdev->comp->num_pm_domains) { +dev_err (pfdev->dev, +"Incorrect number of power domains: %d provided, %d needed\n" , + num_domains, pfdev->comp->num_pm_domains); +return -EINVAL ; + } + +BUG_ON (num_domains >ARRAY_SIZE (pfdev->pm_domain_devs)); + +for (i =0 ; i < num_domains; i++) { + pfdev->pm_domain_devs[i] = +dev_pm_domain_attach_by_id (pfdev->dev, i); +if (IS_ERR (pfdev->pm_domain_devs[i])) { + err =PTR_ERR (pfdev->pm_domain_devs[i]); + pfdev->pm_domain_devs[i] =NULL ; +dev_err (pfdev->dev, +"failed to get pm-domain %d: %d\n" , i, err); + goto err; + } + + pfdev->pm_domain_links[i] =device_link_add (pfdev->dev, + pfdev->pm_domain_devs[i],DL_FLAG_PM_RUNTIME | +DL_FLAG_STATELESS |DL_FLAG_RPM_ACTIVE ); +if (!pfdev->pm_domain_links[i]) { +dev_err (pfdev->pm_domain_devs[i], +"adding device link failed!\n" ); + err = -ENODEV ; + goto err; + } + } + +return 0 ; + +err: +panfrost_pm_domain_fini (pfdev); +return err; +} +int panfrost_device_init (struct panfrost_device *pfdev) {int err;
drivers/gpu/drm/panfrost/panfrost_device.c int panfrost_device_init(struct panfrost_device *pfdev) · line 224
Quoted 6 lines
drivers/gpu/drm/panfrost/panfrost_device.c +3
-0@@ -149,37 +219,45 @@ int panfrost_device_init(struct panfrost_device *pfdev) goto err_out1; } + err =panfrost_pm_domain_init (pfdev); +if (err) { +dev_err (pfdev->dev,"pm_domain init failed %d\n" , err);
No need for this print - panfrost_pm_domain_init() will output a (more appropriate) error message on failure.
Quoted 48 lines
drivers/gpu/drm/panfrost/panfrost_device.c +13
-8+ goto err_out2; + } + res =platform_get_resource (pfdev->pdev,IORESOURCE_MEM ,0 ); pfdev->iomem =devm_ioremap_resource (pfdev->dev, res);if (IS_ERR (pfdev->iomem)) {dev_err (pfdev->dev,"failed to ioremap iomem\n" ); err =PTR_ERR (pfdev->iomem); - goto err_out2; + goto err_out3; } err =panfrost_gpu_init (pfdev);if (err) - goto err_out2; + goto err_out3; err =panfrost_mmu_init (pfdev);if (err) - goto err_out3; + goto err_out4; err =panfrost_job_init (pfdev);if (err) - goto err_out4; + goto err_out5; err =panfrost_perfcnt_init (pfdev);if (err) - goto err_out5; + goto err_out6;return 0 ; -err_out5: +err_out6:panfrost_job_fini (pfdev); -err_out4: +err_out5:panfrost_mmu_fini (pfdev); -err_out3: +err_out4:panfrost_gpu_fini (pfdev); +err_out3: +panfrost_pm_domain_fini (pfdev); err_out2:panfrost_reset_fini (pfdev); err_out1:
drivers/gpu/drm/panfrost/panfrost_device.c void panfrost_device_fini(struct panfrost_device *pfdev) · line 277
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_device.c +1
-0@@ -196,6 +274,7 @@ void panfrost_device_fini(struct panfrost_device *pfdev)panfrost_mmu_fini (pfdev);panfrost_gpu_fini (pfdev);panfrost_reset_fini (pfdev); +panfrost_pm_domain_fini (pfdev);
NIT: The reverse of the construction order would be to do this before panfrost_reset_fini().
Otherwise this LGTM.
Thanks,
Steve
Quoted 43 lines
drivers/gpu/drm/panfrost/panfrost_device.c +0
-0panfrost_regulator_fini (pfdev);panfrost_clk_fini (pfdev); }drivers/gpu/drm/panfrost/panfrost_device.h +9
-0@@ -21,6 +21,7 @@ struct panfrost_perfcnt;#define NUM_JOB_SLOTS 3#define MAX_REGULATORS 2 +#define MAX_PM_DOMAINS 3struct panfrost_features {u16 id;@@ -61,6 +62,11 @@ struct panfrost_compatible {/* Supplies count and names. */ int num_supplies;const char *const *supply_names; +/* +* Number of power domains required, note that values 0 and 1 are +* handled identically, as only values > 1 need special handling. +*/ +int num_pm_domains; };struct panfrost_device {@@ -73,6 +79,9 @@ struct panfrost_device {struct clk *bus_clock;struct regulator_bulk_data regulators[MAX_REGULATORS ];struct reset_control *rstc; +/* pm_domains for devices with more than one. */ +struct device *pm_domain_devs[MAX_PM_DOMAINS ]; +struct device_link *pm_domain_links[MAX_PM_DOMAINS ];struct panfrost_features features;const struct panfrost_compatible * comp;drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0
drivers/gpu/drm/panfrost/panfrost_drv.c const char * const default_supplies[] = { "mali" }; · line 595
Quoted 7 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +1
-0@@ -589,6 +589,7 @@ const char * const default_supplies[] = { "mali" };static const struct panfrost_compatible default_data = { .num_supplies =ARRAY_SIZE (default_supplies), .supply_names = default_supplies, + .num_pm_domains =1 ,/* optional */ };static const struct of_device_id dt_match[] = {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/7] drm/panfrost: Add support for multiple power domains
Quoted 10 lines · Steven Price
On 14/01/2020 07:16, Nicolas Boichat wrote:
[snip]drivers/gpu/drm/panfrost/panfrost_device.c int panfrost_device_init(struct panfrost_device *pfdev) · line 224
Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_device.c +3
-0+ err =panfrost_pm_domain_init (pfdev); +if (err) { +dev_err (pfdev->dev,"pm_domain init failed %d\n" , err);No need for this print -
panfrost_pm_domain_init()will output a (more appropriate) error message on failure.
Dropped.
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/panfrost/panfrost_device.c +3
-0+ goto err_out2; + } +[snip]
Quoted 8 lines
drivers/gpu/drm/panfrost/panfrost_device.c void panfrost_device_fini(struct panfrost_device *pfdev) · line 277
Quoted 5 lines
drivers/gpu/drm/panfrost/panfrost_device.c +1
-0@@ -196,6 +274,7 @@ void panfrost_device_fini(struct panfrost_device *pfdev)panfrost_mmu_fini (pfdev);panfrost_gpu_fini (pfdev);panfrost_reset_fini (pfdev); +panfrost_pm_domain_fini (pfdev);NIT: The reverse of the construction order would be to do this before
panfrost_reset_fini().
Oh right, fixed.
Thanks.
Quoted 1 line
[snip]
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v3 6/7 drm/panfrost: Add mt8183-mali compatible string
In reply to Nicolas BoichatFor testing only, the driver doesn't really work yet, AFAICT.
---
v3:
- Match mt8183-mali instead of bifrost, as we require special handling for the 2 regulators and 3 power domains.
drivers/gpu/drm/panfrost/panfrost_drv.c | 9 +++++++++
1 file changed, 9 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +9 -0
@@ -592,6 +592,13 @@ static const struct panfrost_compatible default_data = { .num_pm_domains = 1, /* optional */ }; +const char *const mediatek_mt8183_supplies[] = {"mali" ,"sram" }; +static const struct panfrost_compatible mediatek_mt8183_data = { + .num_supplies =ARRAY_SIZE (mediatek_mt8183_supplies), + .supply_names = mediatek_mt8183_supplies, + .num_pm_domains =3 , +}; +static const struct of_device_id dt_match[] = { { .compatible ="arm,mali-t604" , .data = &default_data, }, { .compatible ="arm,mali-t624" , .data = &default_data, },
@@ -602,6 +609,8 @@ static const struct of_device_id dt_match[] = { { .compatible = "arm,mali-t830", .data = &default_data, }, { .compatible = "arm,mali-t860", .data = &default_data, }, { .compatible = "arm,mali-t880", .data = &default_data, }, + { .compatible = "mediatek,mt8183-mali", + .data = &mediatek_mt8183_data }, {} }; MODULE_DEVICE_TABLE(of, dt_match);
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v3 7/7 drm/panfrost: devfreq: Add support for 2 regulators
In reply to Nicolas BoichatThe Bifrost GPU on MT8183 uses 2 regulators (core and SRAM) for devfreq, and provides OPP table with 2 sets of voltages.
TODO: This is incomplete as we'll need add support for setting a pair of voltages as well.
--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 17 +++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 18 insertions(+)
drivers/gpu/drm/panfrost/panfrost_devfreq.c +17 -0
@@ -79,6 +79,21 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct devfreq *devfreq;struct thermal_cooling_device *cooling; +/* If we have 2 regulator, we need an OPP table with 2 voltages. */ +if (pfdev->comp->num_supplies >1 ) { + pfdev->devfreq.dev_opp_table = +dev_pm_opp_set_regulators (dev, + pfdev->comp->supply_names, + pfdev->comp->num_supplies); +if (IS_ERR (pfdev->devfreq.dev_opp_table)) { + ret =PTR_ERR (pfdev->devfreq.dev_opp_table); + pfdev->devfreq.dev_opp_table =NULL ; +dev_err (dev, +"Failed to init devfreq opp table: %d\n" , ret); +return ret; + } + } + ret =dev_pm_opp_of_add_table (dev);if (ret == -ENODEV )/* Optional, continue without devfreq */ return 0 ;
@@ -119,6 +134,8 @@ 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.dev_opp_table) +dev_pm_opp_put_regulators (pfdev->devfreq.dev_opp_table); }void panfrost_devfreq_resume (struct panfrost_device *pfdev)
drivers/gpu/drm/panfrost/panfrost_device.h +1 -0
@@ -108,6 +108,7 @@ struct panfrost_device {struct {struct devfreq *devfreq;struct thermal_cooling_device *cooling; +struct opp_table *dev_opp_table;ktime_t busy_time;ktime_t idle_time;ktime_t time_last_update;
Signature · 6 lines
2.25.0.rc1.283.g88dfdc4193-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel