Skip to contentSkip to conversation

drm/vc4: Turn the V3D clock on at runtime.

PATCH Superseded Eric Anholt 5 participants 18 messages Apr 18, 2017 – May 2, 2017

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/vc4: Turn the V3D clock on at runtime.

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  3 ++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 33 ++++++++++++++++++++++
 3 files changed, 37 insertions(+)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +3 -0
index ca02d3e4db91..bc1756f4f791 100644
@@ -59,6 +59,9 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+
 Required properties for DSI:
 - compatible:	Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
 - reg:		Physical base address and length of the DSI block's registers
drivers/gpu/drm/vc4/vc4_drv.h +1 -0
index 81d2bc08e766..08d5c2213c80 100644
@@ -189,6 +189,7 @@ struct vc4_v3d {
 	struct vc4_dev *vc4;
 	struct platform_device *pdev;
 	void __iomem *regs;
+	struct clk *clk;
 };
 
 struct vc4_hvs {
drivers/gpu/drm/vc4/vc4_v3d.c +33 -0
index 7cc346ad9b0b..2442622e6bff 100644
@@ -16,6 +16,7 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "linux/clk.h"
 #include "linux/component.h"
 #include "linux/pm_runtime.h"
 #include "vc4_drv.h"
@@ -164,6 +165,9 @@ static int vc4_v3d_runtime_suspend(struct device *dev)
 
 	vc4_irq_uninstall(vc4->dev);
 
+	if (v3d->clk)
+		clk_disable_unprepare(v3d->clk);
+
 	return 0;
 }
 
@@ -172,6 +176,13 @@ static int vc4_v3d_runtime_resume(struct device *dev)
 	struct vc4_v3d *v3d = dev_get_drvdata(dev);
 	struct vc4_dev *vc4 = v3d->vc4;
 
+	if (v3d->clk) {
+		int ret = clk_prepare_enable(v3d->clk);
+
+		if (ret != 0)
+			return ret;
+	}
+
 	vc4_v3d_init_hw(vc4->dev);
 	vc4_irq_postinstall(vc4->dev);
 
@@ -202,12 +213,34 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 	vc4->v3d = v3d;
 	v3d->vc4 = vc4;
 
+	v3d->clk = devm_clk_get(dev, "v3d_clk");
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENODEV) {
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
+
 	if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
 		DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
 			  V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
 		return -EINVAL;
 	}
 
+	if (v3d->clk) {
+		ret = clk_prepare_enable(v3d->clk);
+		if (ret != 0)
+			return ret;
+	}
+
 	/* Reset the binner overflow address/size at setup, to be sure
 	 * we don't reuse an old one.
 	 */
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/3 drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

---
 drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +6 -4
index ad7925a9e0ea..237a504f11f0 100644
@@ -230,10 +230,12 @@ int vc4_kms_load(struct drm_device *dev)
 
 	drm_mode_config_reset(dev);
 
-	vc4->fbdev = drm_fbdev_cma_init(dev, 32,
-					dev->mode_config.num_connector);
-	if (IS_ERR(vc4->fbdev))
-		vc4->fbdev = NULL;
+	if (dev->mode_config.num_connector) {
+		vc4->fbdev = drm_fbdev_cma_init(dev, 32,
+						dev->mode_config.num_connector);
+		if (IS_ERR(vc4->fbdev))
+			vc4->fbdev = NULL;
+	}
 
 	drm_kms_helper_poll_init(dev);
 
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH 3/3 drm/vc4: Add specific compatible strings for Cygnus.

In reply to Eric Anholt

Cygnus has V3D 2.6 instead of 2.1, and doesn't use the VC4 display modules. The V3D can be uniquely identified by the IDENT[01] registers, and there's nothing to key off of for the display change other than the lack of DT nodes for the display components, but it's convention to have new compatible strings anyway.

---
 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 4 ++--
 drivers/gpu/drm/vc4/vc4_drv.c                              | 1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                              | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +2 -2
index bc1756f4f791..284e2b14cfbe 100644
@@ -5,7 +5,7 @@ with HDMI output and the HVS (Hardware Video Scaler) for compositing
 display planes.
 
 Required properties for VC4:
-- compatible:	Should be "brcm,bcm2835-vc4"
+- compatible:	Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4"
 
 Required properties for Pixel Valve:
 - compatible:	Should be one of "brcm,bcm2835-pixelvalve0",
@@ -54,7 +54,7 @@ Required properties for VEC:
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
 Required properties for V3D:
-- compatible:	Should be "brcm,bcm2835-v3d"
+- compatible:	Should be "brcm,bcm2835-v3d" or "brcm,cygnus-v3d"
 - reg:		Physical base address and length of the V3D's registers
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
index 92fb9a41fe7c..754ce76d4b98 100644
@@ -335,6 +335,7 @@ static int vc4_platform_drm_remove(struct platform_device *pdev)
 
 static const struct of_device_id vc4_of_match[] = {
 	{ .compatible = "brcm,bcm2835-vc4", },
+	{ .compatible = "brcm,cygnus-vc4", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, vc4_of_match);
drivers/gpu/drm/vc4/vc4_v3d.c +1 -0
index 2442622e6bff..3abcd27aa46f 100644
@@ -304,6 +304,7 @@ static int vc4_v3d_dev_remove(struct platform_device *pdev)
 
 static const struct of_device_id vc4_v3d_dt_match[] = {
 	{ .compatible = "brcm,bcm2835-v3d" },
+	{ .compatible = "brcm,cygnus-v3d" },
 	{ .compatible = "brcm,vc4-v3d" },
 	{}
 };
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw
In reply to Eric Anholt

drivers/gpu/drm/vc4/vc4_v3d.c static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) · line 220

Quoted 9 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

drivers/gpu/drm/vc4/vc4_v3d.c +5 -0
+	v3d->clk = devm_clk_get(dev, "v3d_clk");
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENODEV) {

Apparently I hadn't booted this on RPi yet. This is supposed to be -ENOENT.

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_v3d.c +10 -0
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
#11 lore raw

PATCH v2 1/3 drm/vc4: Turn the V3D clock on at runtime.

In reply to Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  4 +++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 38 +++++++++++++++++++++-
 3 files changed, 42 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +4 -0
index ca02d3e4db91..2318266f6481 100644
@@ -59,6 +59,10 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+- clock-names:	Must be "v3d_clk"
+
 Required properties for DSI:
 - compatible:	Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
 - reg:		Physical base address and length of the DSI block's registers
drivers/gpu/drm/vc4/vc4_drv.h +1 -0
index b0967e2f7e88..92eb7d811bf2 100644
@@ -200,6 +200,7 @@ struct vc4_v3d {
 	struct vc4_dev *vc4;
 	struct platform_device *pdev;
 	void __iomem *regs;
+	struct clk *clk;
 };
 
 struct vc4_hvs {
drivers/gpu/drm/vc4/vc4_v3d.c +37 -1
index a88078d7c9d1..ca987d2800c6 100644
@@ -16,6 +16,7 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "linux/clk.h"
 #include "linux/component.h"
 #include "linux/pm_runtime.h"
 #include "vc4_drv.h"
@@ -305,6 +306,9 @@ static int vc4_v3d_runtime_suspend(struct device *dev)
 	drm_gem_object_put_unlocked(&vc4->bin_bo->base.base);
 	vc4->bin_bo = NULL;
 
+	if (v3d->clk)
+		clk_disable_unprepare(v3d->clk);
+
 	return 0;
 }
 
@@ -318,6 +322,13 @@ static int vc4_v3d_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	if (v3d->clk) {
+		int ret = clk_prepare_enable(v3d->clk);
+
+		if (ret != 0)
+			return ret;
+	}
+
 	vc4_v3d_init_hw(vc4->dev);
 	vc4_irq_postinstall(vc4->dev);
 
@@ -348,15 +359,40 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 	vc4->v3d = v3d;
 	v3d->vc4 = vc4;
 
+	v3d->clk = devm_clk_get(dev, "v3d_clk");
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENOENT) {
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
+
 	if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
 		DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
 			  V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
 		return -EINVAL;
 	}
 
+	if (v3d->clk) {
+		ret = clk_prepare_enable(v3d->clk);
+		if (ret != 0)
+			return ret;
+	}
+
 	ret = vc4_allocate_bin_bo(drm);
-	if (ret)
+	if (ret) {
+		if (v3d->clk)
+			clk_disable_unprepare(v3d->clk);
 		return ret;
+	}
 
 	/* Reset the binner overflow address/size at setup, to be sure
 	 * we don't reuse an old one.
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

Review

Quoted 12 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.

---

(quoted diff) +2 -0
+	if (v3d->clk)
+		clk_disable_unprepare(v3d->clk);

The clock API allows you to pass a NULL clk and do nothing in these cases which is what you seem to have done a few lines below, you could simplify these checks?

Quoted 61 lines
drivers/gpu/drm/vc4/vc4_v3d.c +34 -1
+
 	return 0;
 }
@@ -318,6 +322,13 @@ static int vc4_v3d_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	if (v3d->clk) {
+		int ret = clk_prepare_enable(v3d->clk);
+
+		if (ret != 0)
+			return ret;
+	}
+
 	vc4_v3d_init_hw(vc4->dev);
 	vc4_irq_postinstall(vc4->dev);
 
@@ -348,15 +359,40 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 	vc4->v3d = v3d;
 	v3d->vc4 = vc4;
 
+	v3d->clk = devm_clk_get(dev, "v3d_clk");
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENOENT) {
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
+
 	if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
 		DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
 			  V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
 		return -EINVAL;
 	}
 
+	if (v3d->clk) {
+		ret = clk_prepare_enable(v3d->clk);
+		if (ret != 0)
+			return ret;
+	}
+
 	ret = vc4_allocate_bin_bo(drm);
-	if (ret)
+	if (ret) {
+		if (v3d->clk)
+			clk_disable_unprepare(v3d->clk);
 		return ret;
+	}
 
 	/* Reset the binner overflow address/size at setup, to be sure
 	 * we don't reuse an old one.
Signature · 5 lines
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw
Quoted 11 lines · Florian Fainelli
Quoted 9 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.

---

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (v3d->clk)
+		clk_disable_unprepare(v3d->clk);

The clock API allows you to pass a NULL clk and do nothing in these cases which is what you seem to have done a few lines below, you could simplify these checks?

Sounds good.

#14 lore raw
In reply to Florian Fainelli
Quoted 11 lines · Florian Fainelli
Quoted 9 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.

---

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (v3d->clk)
+		clk_disable_unprepare(v3d->clk);

The clock API allows you to pass a NULL clk and do nothing in these cases which is what you seem to have done a few lines below, you could simplify these checks?

Sounds good.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

In reply to Eric Anholt
Quoted 4 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?
-Daniel

Quoted 32 lines
---
 drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +6 -5
index ad7925a9e0ea..237a504f11f0 100644
@@ -230,10 +230,12 @@ int vc4_kms_load(struct drm_device *dev)
 
        drm_mode_config_reset(dev);
 
-       vc4->fbdev = drm_fbdev_cma_init(dev, 32,
-                                       dev->mode_config.num_connector);
-       if (IS_ERR(vc4->fbdev))
-               vc4->fbdev = NULL;
+       if (dev->mode_config.num_connector) {
+               vc4->fbdev = drm_fbdev_cma_init(dev, 32,
+                                               dev->mode_config.num_connector);
+               if (IS_ERR(vc4->fbdev))
+                       vc4->fbdev = NULL;
+       }
 
        drm_kms_helper_poll_init(dev);
 
--

2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

Quoted 8 lines · Daniel Vetter
Quoted 4 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?

drm_fb_helper_init() throws an error if the passed in connector count is 0, so drm_fb_cma_helper() printks an error.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

Quoted 5 lines · Eric Anholt
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?

drm_fb_helper_init() throws an error if the passed in connector count is 0, so drm_fb_cma_helper() printks an error.

Oh, _that_ thing. The error in there is correct, but (almost) everyone gets this parameter wrong. This isn't the max number of connectors the fb helper will light up, but just the max number of connectors _per_ crtc when driving in hw clone mode. There's two problems with that:
- fb helpers don't support hw clone mode, we select 1:1 crtcs for each active connector
- I mentioned that everyone gets this wrong?

If you're moderately bored it'd be great to nuke the max_connector argument from drm_fb_helper_init, and hard-code it to 1 (with a big comment explaining that this needs to be changed, probably with dynamic reallocation, once someone gets around to implementing hw clone mode).

If you're less bored, just hardcode this to 1 in vc4 and done. Plus a TODO.rst entry would be great in that case.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by on v1 3/3
#9 lore raw

Re: [PATCH 3/3] drm/vc4: Add specific compatible strings for Cygnus.

In reply to Eric Anholt
Quoted 6 lines · Eric Anholt

Cygnus has V3D 2.6 instead of 2.1, and doesn't use the VC4 display modules. The V3D can be uniquely identified by the IDENT[01] registers, and there's nothing to key off of for the display change other than the lack of DT nodes for the display components, but it's convention to have new compatible strings anyway.

Quoted 6 lines
---
 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 4 ++--
 drivers/gpu/drm/vc4/vc4_drv.c                              | 1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                              | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

In reply to Daniel Vetter
Quoted 22 lines · Daniel Vetter
Quoted 5 lines · Eric Anholt
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?

drm_fb_helper_init() throws an error if the passed in connector count is 0, so drm_fb_cma_helper() printks an error.

Oh, _that_ thing. The error in there is correct, but (almost) everyone gets this parameter wrong. This isn't the max number of connectors the fb helper will light up, but just the max number of connectors _per_ crtc when driving in hw clone mode. There's two problems with that:
- fb helpers don't support hw clone mode, we select 1:1 crtcs for each active connector
- I mentioned that everyone gets this wrong?

Quoted 8 lines

If you're moderately bored it'd be great to nuke the max_connector argument from drm_fb_helper_init, and hard-code it to 1 (with a big comment explaining that this needs to be changed, probably with dynamic reallocation, once someone gets around to implementing hw clone mode).

If you're less bored, just hardcode this to 1 in vc4 and done. Plus a TODO.rst entry would be great in that case.

If I'm driving a GPU with no display subsystem at all, it seems like I shouldn't initialize fbdev for it, right?

#6 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

Quoted 30 lines · Eric Anholt
Quoted 28 lines · Daniel Vetter
Quoted 5 lines · Eric Anholt
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?

drm_fb_helper_init() throws an error if the passed in connector count is 0, so drm_fb_cma_helper() printks an error.

Oh, _that_ thing. The error in there is correct, but (almost) everyone gets this parameter wrong. This isn't the max number of connectors the fb helper will light up, but just the max number of connectors _per_ crtc when driving in hw clone mode. There's two problems with that:
- fb helpers don't support hw clone mode, we select 1:1 crtcs for each active connector
- I mentioned that everyone gets this wrong?

If you're moderately bored it'd be great to nuke the max_connector argument from drm_fb_helper_init, and hard-code it to 1 (with a big comment explaining that this needs to be changed, probably with dynamic reallocation, once someone gets around to implementing hw clone mode).

Quoted 5 lines
Quoted 2 lines

If you're less bored, just hardcode this to 1 in vc4 and done. Plus a TODO.rst entry would be great in that case.

If I'm driving a GPU with no display subsystem at all, it seems like I shouldn't initialize fbdev for it, right?

That's what we do for radeon/amdgpu on hw without display blocks.

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

PATCH v3 1/3 drm/vc4: Turn the V3D clock on at runtime.

In reply to Florian Fainelli

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.
v3: Drop NULL checks around clk calls which embed NULL checks.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  4 +++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 31 +++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +4 -0
index ca02d3e4db91..2318266f6481 100644
@@ -59,6 +59,10 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+- clock-names:	Must be "v3d_clk"
+
 Required properties for DSI:
 - compatible:	Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
 - reg:		Physical base address and length of the DSI block's registers
drivers/gpu/drm/vc4/vc4_drv.h +1 -0
index b0967e2f7e88..92eb7d811bf2 100644
@@ -200,6 +200,7 @@ struct vc4_v3d {
 	struct vc4_dev *vc4;
 	struct platform_device *pdev;
 	void __iomem *regs;
+	struct clk *clk;
 };
 
 struct vc4_hvs {
drivers/gpu/drm/vc4/vc4_v3d.c +30 -1
index a88078d7c9d1..465405586591 100644
@@ -16,6 +16,7 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "linux/clk.h"
 #include "linux/component.h"
 #include "linux/pm_runtime.h"
 #include "vc4_drv.h"
@@ -305,6 +306,8 @@ static int vc4_v3d_runtime_suspend(struct device *dev)
 	drm_gem_object_put_unlocked(&vc4->bin_bo->base.base);
 	vc4->bin_bo = NULL;
 
+	clk_disable_unprepare(v3d->clk);
+
 	return 0;
 }
 
@@ -318,6 +321,10 @@ static int vc4_v3d_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	ret = clk_prepare_enable(v3d->clk);
+	if (ret != 0)
+		return ret;
+
 	vc4_v3d_init_hw(vc4->dev);
 	vc4_irq_postinstall(vc4->dev);
 
@@ -348,15 +355,37 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 	vc4->v3d = v3d;
 	v3d->vc4 = vc4;
 
+	v3d->clk = devm_clk_get(dev, "v3d_clk");
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENOENT) {
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
+
 	if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
 		DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
 			  V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
 		return -EINVAL;
 	}
 
+	ret = clk_prepare_enable(v3d->clk);
+	if (ret != 0)
+		return ret;
+
 	ret = vc4_allocate_bin_bo(drm);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(v3d->clk);
 		return ret;
+	}
 
 	/* Reset the binner overflow address/size at setup, to be sure
 	 * we don't reuse an old one.
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#16 lore raw
Quoted 20 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.
v3: Drop NULL checks around clk calls which embed NULL checks.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  4 +++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 31 +++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +0 -0
index ca02d3e4db91..2318266f6481 100644

Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt Required properties for V3D: · line 64

Quoted 6 lines
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +3 -0
@@ -59,6 +59,10 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+- clock-names:	Must be "v3d_clk"

clock-names is pointless for a single clock.

Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt Required properties for V3D: · line 68

Quoted 4 lines
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +1 -0
+
 Required properties for DSI:
 - compatible:	Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
 - reg:		Physical base address and length of the DSI block's registers

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw
Quoted 24 lines · Rob Herring
Quoted 23 lines · Eric Anholt

For the Raspberry Pi's bindings, the power domain also implicitly turns on the clock and deasserts reset, but for the new Cygnus port we start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
in DT.
v3: Drop NULL checks around clk calls which embed NULL checks.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  4 +++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 31 +++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +0 -0
index ca02d3e4db91..2318266f6481 100644
@@ -59,6 +59,10 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
Quoted 5 lines

Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt Required properties for V3D: · line 64

Quoted 3 lines
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +3 -0
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+- clock-names:	Must be "v3d_clk"

clock-names is pointless for a single clock.

I thought the "-names" was the current style of future-proofing against finding another clock to put in the list. If I drop it, is the DT change acked?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

In reply to Alex Deucher
Quoted 31 lines · Alex Deucher
Quoted 30 lines · Eric Anholt
Quoted 28 lines · Daniel Vetter
Quoted 5 lines · Eric Anholt
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Eric Anholt

The FBDEV initialization would throw an error in dmesg, when we just want to silently not initialize fbdev on a V3D-only VC4 instance.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Hm, this shouldn't be an error really, you might want to hotplug more connectors later on. What exactly complains?

drm_fb_helper_init() throws an error if the passed in connector count is 0, so drm_fb_cma_helper() printks an error.

Oh, _that_ thing. The error in there is correct, but (almost) everyone gets this parameter wrong. This isn't the max number of connectors the fb helper will light up, but just the max number of connectors _per_ crtc when driving in hw clone mode. There's two problems with that:
- fb helpers don't support hw clone mode, we select 1:1 crtcs for each active connector
- I mentioned that everyone gets this wrong?

If you're moderately bored it'd be great to nuke the max_connector argument from drm_fb_helper_init, and hard-code it to 1 (with a big comment explaining that this needs to be changed, probably with dynamic reallocation, once someone gets around to implementing hw clone mode).

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If you're less bored, just hardcode this to 1 in vc4 and done. Plus a TODO.rst entry would be great in that case.

If I'm driving a GPU with no display subsystem at all, it seems like I shouldn't initialize fbdev for it, right?

That's what we do for radeon/amdgpu on hw without display blocks.

Yeah I got slightly distracted with the error :-)

Still might make sense to put this logic into the helpers, if there's no crtc then don't bother initializing the fbcon. But imo the better cleanup is getting rid of the connectors parameter, since most drivers get it wrong, then respin the vc4 patch to explain what it's really doing (it's not about the error really, it's about not registering and fbdev that's not doing anything).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel