Skip to contentSkip to conversation

Enable HSW FBC

PATCH In review Rodrigo Vivi 4 participants 26 messages Apr 8, 2013 – Apr 17, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Enable HSW FBC

Hi all, this small series enable Frame Buffer Compression at HSW.

I decided to create a new function haswell_enable_fbc to avoid getting old function messed with many IS_HASWELL checks.

Also I decided to split the 2 needed workarounds in separated pathces to be easy to revert at any time if needed.

On my local tests using a HSW ULT machine I could save around 0.1/0.2W. Up to 0.3W. And apparently stable enough.

As always, reviews, comments, bikeshedings, tests, etc are welcome.

Thanks in advance,
Rodrigo.

Rodrigo Vivi (3):
drm/i915: Enable FBC at Haswell. drm/i915: HSW FBC WaFbcAsynchFlipDisableFbcQueue drm/i915: HSW FBC WaFbcDisableDpfcClockGating

 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h | 16 +++++++++++++
 drivers/gpu/drm/i915/intel_pm.c | 50 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 66 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/3 drm/i915: Enable FBC at Haswell.

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 0cfc778..88fd6fb 100644
@@ -291,6 +291,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 5e91fbb..cb8e213 100644
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +43 -1

56 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#2 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 52 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 0cfc778..88fd6fb 100644
@@ -291,6 +291,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 5e91fbb..cb8e213 100644
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 27f94cd..94e1c3a 100644
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct drm_device *dev)
 	return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 269

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	struct drm_framebuffer *fb = crtc->fb;
+	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+	struct drm_i915_gem_object *obj = intel_fb->obj;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA : DPFC_CTL_PLANEB;
+	unsigned long stall_watermark = 200;
+	u32 dpfc_ctl;
+
+	dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+	dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 1 line
drivers/gpu/drm/i915/intel_pm.c +1 -0
+	dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Quoted 46 lines
drivers/gpu/drm/i915/intel_pm.c +28 -1
+	dpfc_ctl |= HSW_DPFC_CTL_DISABLE_SLB_INIT;
+	I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |
+		   (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+		   (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+	I915_WRITE(HSW_FBC_RT_BASE,
+		   obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+		   ILK_FBC_RT_VALID);
+	/* enable it... */
+	I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
+
+	if (obj->fence_reg != I915_FENCE_REG_NONE) {
+		I915_WRITE(SNB_DPFC_CTL_SA,
+			   SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+		I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+	} else
+		I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+	sandybridge_blit_fbc_update(dev);
+
+	DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4158,7 +4195,12 @@ void intel_init_pm(struct drm_device *dev)
 	if (I915_HAS_FBC(dev)) {
 		if (HAS_PCH_SPLIT(dev)) {
 			dev_priv->display.fbc_enabled = ironlake_fbc_enabled;
-			dev_priv->display.enable_fbc = ironlake_enable_fbc;
+			if (IS_HASWELL(dev))
+				dev_priv->display.enable_fbc =
+					haswell_enable_fbc;
+			else
+				dev_priv->display.enable_fbc =
+					ironlake_enable_fbc;
 			dev_priv->display.disable_fbc = ironlake_disable_fbc;
 		} else if (IS_GM45(dev)) {
 			dev_priv->display.fbc_enabled = g4x_fbc_enabled;
Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
#3 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <[email protected]

Quoted 67 lines

wrote:

Quoted 9 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Review

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /* aka */
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Review

Quoted 17 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct drm_device

*dev)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long

interval)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +8 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
Quoted 9 lines

DPFC_CTL_PLANEB;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 269

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining like:

     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out. It was just bad copy and paste actually.

Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Where did you get this restriction for HSW? Should we write 0 or not touch by removing lis line?

Thanks for all your comments!

Quoted 54 lines
Quoted 27 lines
drivers/gpu/drm/i915/intel_pm.c +22 -0
+     dpfc_ctl |= HSW_DPFC_CTL_DISABLE_SLB_INIT;
+     I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |
+                (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+                (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+     I915_WRITE(HSW_FBC_RT_BASE,
+                obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+                ILK_FBC_RT_VALID);
+     /* enable it... */
+     I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
+
+     if (obj->fence_reg != I915_FENCE_REG_NONE) {
+             I915_WRITE(SNB_DPFC_CTL_SA,
+                        SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+             I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+     } else
+             I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+     sandybridge_blit_fbc_update(dev);
+
+     DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
      struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev) · line 4197

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4158,7 +4195,12 @@ void intel_init_pm(struct drm_device *dev)
      if (I915_HAS_FBC(dev)) {
              if (HAS_PCH_SPLIT(dev)) {
                      dev_priv->display.fbc_enabled =

ironlake_fbc_enabled;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +6 -1
-                     dev_priv->display.enable_fbc = ironlake_enable_fbc;
+                     if (IS_HASWELL(dev))
+                             dev_priv->display.enable_fbc =
+                                     haswell_enable_fbc;
+                     else
+                             dev_priv->display.enable_fbc =
+                                     ironlake_enable_fbc;
                      dev_priv->display.disable_fbc =

ironlake_disable_fbc;

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
              } else if (IS_GM45(dev)) {
                      dev_priv->display.fbc_enabled = g4x_fbc_enabled;
--

1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 85 lines · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <[email protected]

Quoted 67 lines

wrote:

Quoted 9 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Review

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /* aka */
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Review

Quoted 17 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct drm_device

*dev)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long

interval)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +8 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
Quoted 9 lines

DPFC_CTL_PLANEB;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 269

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining like:

     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 6 lines
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out. It was just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths rot.

Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Where did you get this restriction for HSW?

BSpec.

Quoted 2 lines

Should we write 0 or not touch
by removing lis line?

Not sure. The spec doesn't say whether the "CPU fence enable" bit still has some meaning or not. I guess the safe approach would be to set the fence to 0 and only set the fence enable bit when we actually have a fence.

BTW the whole dpfc_ctl handing seems to a bit broken. You're doing it via RMW, but you're not clearing the fields that you modify. So you could be just ORing bits to whatever garbage the register had before.

Quoted 65 lines

Thanks for all your comments!

Quoted 54 lines
Quoted 27 lines
drivers/gpu/drm/i915/intel_pm.c +22 -0
+     dpfc_ctl |= HSW_DPFC_CTL_DISABLE_SLB_INIT;
+     I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |
+                (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+                (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+     I915_WRITE(HSW_FBC_RT_BASE,
+                obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+                ILK_FBC_RT_VALID);
+     /* enable it... */
+     I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
+
+     if (obj->fence_reg != I915_FENCE_REG_NONE) {
+             I915_WRITE(SNB_DPFC_CTL_SA,
+                        SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+             I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+     } else
+             I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+     sandybridge_blit_fbc_update(dev);
+
+     DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
      struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev) · line 4197

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4158,7 +4195,12 @@ void intel_init_pm(struct drm_device *dev)
      if (I915_HAS_FBC(dev)) {
              if (HAS_PCH_SPLIT(dev)) {
                      dev_priv->display.fbc_enabled =

ironlake_fbc_enabled;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +6 -1
-                     dev_priv->display.enable_fbc = ironlake_enable_fbc;
+                     if (IS_HASWELL(dev))
+                             dev_priv->display.enable_fbc =
+                                     haswell_enable_fbc;
+                     else
+                             dev_priv->display.enable_fbc =
+                                     ironlake_enable_fbc;
                      dev_priv->display.disable_fbc =

ironlake_disable_fbc;

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
              } else if (IS_GM45(dev)) {
                      dev_priv->display.fbc_enabled = g4x_fbc_enabled;
--

1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
Signature · 2 lines
Ville Syrjälä
Intel OTC
#5 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 13 lines · Ville Syrjälä
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Where did you get this restriction for HSW?

BSpec.

Quoted 2 lines

Should we write 0 or not touch
by removing lis line?

Quoted 8 lines

Not sure. The spec doesn't say whether the "CPU fence enable" bit still has some meaning or not. I guess the safe approach would be to set the fence to 0 and only set the fence enable bit when we actually have a fence.

BTW the whole dpfc_ctl handing seems to a bit broken. You're doing it via RMW, but you're not clearing the fields that you modify. So you could be just ORing bits to whatever garbage the register had before.

Ok, I guess it's time for me to write down the fbc master plan here ;-)

So imo psr and fbc fit into the exact same category: Both safe a bit of power if the display contents doesn't change. And for both we need to know when contents has changed so that we can either disable it or through some hw magic update screen contents. So imo we can (and should) wire up all the psr magic into the same intel_enable/disable_fbc functions.

Now on platforms thus far the power savings part of fbc worked usually rather well, real ugliness kicked in when trying to enable the hw magic to detect display contents changes. The hw supplies three pieces for that:
- cpu fence to detect writes from the cpu through the gtt
- blt fbc range - each time the blt touches anything in there fbc gets a note
- render fbc range - same
- pageflips send a signal to fbc/psr to update screen

Those above three things are usually riddled with workarounds, tend to hang the box (or as in the case of the gen6 blitter) totally kill throughput when enabled. The only thing which seems to work is the pageflip stuff.

So my proposal is that before we enable anything like fbc or psr by default, we can all this hw magic. Completely.

And then we replace it with some nice software tracking. The main idea is that at least on modern desktop, screen updates always happen with pageflips. That means for X only one active crtc since X still doesn't have per-crtc pixmaps, but meh.

Now for the pageflipping compositor model we don't need any of the fancy (and usually broken) hw magic to detect updates to the currently scanning out framebuffer - the compositor always renders to the backbuffer.

So the idea is now to enable fbc/psr when pageflipping and disable it as soon as we detect a frontbuffer rendering event. Thanks to the current gem api we can do this pretty cheaply:
- CPU writes to the frontbuffer call sw_finish_ioctl. I need to still check whether that only applies to cpu maps or also gtt maps.
- GTT writes could easily be caught by unmapping userspace ptes (we have the infrastructure for that already), but I hope we can avoid that.
- Currently we have some fragile code in our execbuf handler to detect render of the gpu. I think we can rip this all out and instead detect frontbuffer gpu rendering in the busy ioctl - that has been established as the canonical interface for userspace to ask the kernel to flush the frontbuffer. Aside: This semantics was not designed, but we've realized that this is what it is eventually ;-)

Now once we have done the Big Rip and restricted fbc/psr enabling to pageflips and disabling to these few places there's one thing left: We need proper locking. My proposal is to add a new fbc_mutex which protects all the special fbc state. That way we can avoid the current ugly locking hell between kms and gem: Since due to modeset/dpms changes we need to update fbc state, we enable it in the kms pageflip code if possible, but gem events ditacte when we need to disable it again. But if the fbc state is protected by its own mutex which needs within the kms/gem locks we should be fine.

Cheers, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#6 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 6 lines · Daniel Vetter

So the idea is now to enable fbc/psr when pageflipping and disable it as soon as we detect a frontbuffer rendering event. Thanks to the current gem api we can do this pretty cheaply:
- CPU writes to the frontbuffer call sw_finish_ioctl. I need to still check whether that only applies to cpu maps or also gtt maps.
- GTT writes could easily be caught by unmapping userspace ptes (we

Quoted 8 lines

have the infrastructure for that already), but I hope we can avoid that.
- Currently we have some fragile code in our execbuf handler to detect render of the gpu. I think we can rip this all out and instead detect frontbuffer gpu rendering in the busy ioctl - that has been established as the canonical interface for userspace to ask the kernel to flush the frontbuffer. Aside: This semantics was not designed, but we've realized that this is what it is eventually ;-)

To add my wishlist item:
- a global property / param indicating the availabilty of FBC
- a crtc property indicating the status of FBC
That way X can avoid front buffer rendering when it would incur penalties and is likely to result in corruption (I'm sure the next generation of FBC will work, or maybe the next).
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#7 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

In reply to Ville Syrjälä
Quoted 102 lines · Ville Syrjälä
Quoted 1 line · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <

[email protected]

Quoted 22 lines
Quoted 22 lines

wrote:

Quoted 9 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info intel_haswell_m_info = {

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /* aka

*/

Quoted 16 lines
Quoted 16 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Quoted 14 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct

drm_device

Quoted 31 lines
Quoted 14 lines

*dev)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long

interval)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +8 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
Quoted 9 lines

DPFC_CTL_PLANEB;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 269

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining like:

     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 5 lines
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out. It

was

Quoted 1 line

just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths rot.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Where did you get this restriction for HSW?

BSpec.

Are you talking about bit 28 of 43208h DevHSW?
I couldn't find this restriction anywhere.
Besides that, setting it to 0 made me experience bugs like missing some small screen updates. I mean, when it is 0 I missed many "****" when typing my login password.
When it is set FBC works fine.

Quoted 4 lines
Quoted 3 lines

Should we write 0 or not touch
by removing lis line?

Quoted 9 lines

Not sure. The spec doesn't say whether the "CPU fence enable" bit still has some meaning or not. I guess the safe approach would be to set the fence to 0 and only set the fence enable bit when we actually have a fence.

BTW the whole dpfc_ctl handing seems to a bit broken. You're doing it via RMW, but you're not clearing the fields that you modify. So you could be just ORing bits to whatever garbage the register had before.

Although I don't see how a garbage could end up there I completely agree with you. So I'm going to just set the register directly without using this temp variable.

Quoted 73 lines
Quoted 38 lines

Thanks for all your comments!

Quoted 32 lines
Quoted 27 lines
drivers/gpu/drm/i915/intel_pm.c +22 -0
+     dpfc_ctl |= HSW_DPFC_CTL_DISABLE_SLB_INIT;
+     I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |
+                (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+                (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+     I915_WRITE(HSW_FBC_RT_BASE,
+                obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+                ILK_FBC_RT_VALID);
+     /* enable it... */
+     I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
+
+     if (obj->fence_reg != I915_FENCE_REG_NONE) {
+             I915_WRITE(SNB_DPFC_CTL_SA,
+                        SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+             I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+     } else
+             I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+     sandybridge_blit_fbc_update(dev);
+
+     DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
      struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev) · line 4197

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4158,7 +4195,12 @@ void intel_init_pm(struct drm_device *dev)
      if (I915_HAS_FBC(dev)) {
              if (HAS_PCH_SPLIT(dev)) {
                      dev_priv->display.fbc_enabled =

ironlake_fbc_enabled;

Quoted 1 line
drivers/gpu/drm/i915/intel_pm.c +0 -1
-                     dev_priv->display.enable_fbc =

ironlake_enable_fbc;

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev)

Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
+                     if (IS_HASWELL(dev))
+                             dev_priv->display.enable_fbc =
+                                     haswell_enable_fbc;
+                     else
+                             dev_priv->display.enable_fbc =
+                                     ironlake_enable_fbc;
                      dev_priv->display.disable_fbc =

ironlake_disable_fbc;

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
              } else if (IS_GM45(dev)) {
                      dev_priv->display.fbc_enabled =

g4x_fbc_enabled;

Quoted 15 lines
Quoted 12 lines
Quoted 7 lines

--
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

Quoted 3 lines

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 109 lines · Rodrigo Vivi
Quoted 106 lines · Ville Syrjälä
Quoted 1 line · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <

[email protected]

Quoted 22 lines
Quoted 22 lines

wrote:

Quoted 9 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info intel_haswell_m_info = {

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /* aka

*/

Quoted 16 lines
Quoted 16 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Quoted 14 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct

drm_device

Quoted 31 lines
Quoted 14 lines

*dev)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long

interval)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +8 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
Quoted 9 lines

DPFC_CTL_PLANEB;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 269

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining like:

     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 5 lines
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out. It

was

Quoted 1 line

just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths rot.

Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with the same fix.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Where did you get this restriction for HSW?

BSpec.

Are you talking about bit 28 of 43208h DevHSW?

Bits 0:3 of the same register.

Quoted 5 lines

I couldn't find this restriction anywhere.
Besides that, setting it to 0 made me experience bugs like missing some small screen updates. I mean, when it is 0 I missed many "****" when typing my login password.
When it is set FBC works fine.

This is what BSpec is telling us to program:

FBC_CTL
28 = ?
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

So the FBC_CTL bit 28 is not clear. BSpec doesn't say whether it should be 0 or 1. Did you try both values for that bit?

Signature · 2 lines
Ville Syrjälä
Intel OTC
#9 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Yeah, this makes sense. Yes, I tested many times here, with 0 at bit 28 I always got that bug with missing updates, In the way it is it always worked fine.

Quoted 150 lines · Ville Syrjälä
Quoted 10 lines · Rodrigo Vivi
Quoted 7 lines · Ville Syrjälä
Quoted 1 line · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <

[email protected]

Quoted 4 lines
Quoted 4 lines

wrote:

Quoted 1 line · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for

HSW.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 8 lines

It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info intel_haswell_m_info = {

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /*

aka

Quoted 26 lines
Quoted 26 lines

*/

Quoted 16 lines
Quoted 16 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Quoted 14 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct

drm_device

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

*dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned

long

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

interval)

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb =

to_intel_framebuffer(fb);

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :

DPFC_CTL_PLANEB;

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining

like:

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out.

It

Quoted 9 lines
Quoted 9 lines

was

Quoted 1 line

just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths rot.

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with

the

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

same fix.

Where did you get this restriction for HSW?

BSpec.

Are you talking about bit 28 of 43208h DevHSW?

Bits 0:3 of the same register.

Quoted 3 lines

I couldn't find this restriction anywhere.
Besides that, setting it to 0 made me experience bugs like missing some small screen updates. I mean, when it is 0 I missed many "****" when

typing

Quoted 2 lines

my login password.
When it is set FBC works fine.

This is what BSpec is telling us to program:

FBC_CTL
28 = ?
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

So the FBC_CTL bit 28 is not clear. BSpec doesn't say whether it should be 0 or 1. Did you try both values for that bit?

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

Quoted 3 lines · Rodrigo Vivi

Yeah, this makes sense. Yes, I tested many times here, with 0 at bit 28 I always got that bug with missing updates, In the way it is it always worked fine.

So did you actually test with this config?

FBC_CTL
28 = 1
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

Oh, and for this test you should make sure fence reg != 0, so that we can find out for sure whether the FBC_CTL bits 0:3 have some real effect.

Quoted 159 lines
Quoted 150 lines · Ville Syrjälä
Quoted 10 lines · Rodrigo Vivi
Quoted 7 lines · Ville Syrjälä
Quoted 1 line · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <

[email protected]

Quoted 4 lines
Quoted 4 lines

wrote:

Quoted 1 line · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for

HSW.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 8 lines

It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info · line 297

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /*

aka

Quoted 26 lines
Quoted 26 lines

*/

Quoted 16 lines
Quoted 16 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Quoted 14 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct

drm_device

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

*dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned

long

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

interval)

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb =

to_intel_framebuffer(fb);

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct · line 264

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :

DPFC_CTL_PLANEB;

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Accroding to BSpec FBC is always tied to plane A. Bit 30 is MBZ.

Yeah, you are right. I'm going to add a verification at begining

like:

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 3 lines

Maybe fix up plane C FBC support for IVB while you're poking at the general direction?

Actually I wasn't trying general directions since I splited it out.

It

Quoted 9 lines
Quoted 9 lines

was

Quoted 1 line

just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths rot.

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct · line 270

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do with

the

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

same fix.

Where did you get this restriction for HSW?

BSpec.

Are you talking about bit 28 of 43208h DevHSW?

Bits 0:3 of the same register.

Quoted 3 lines

I couldn't find this restriction anywhere.
Besides that, setting it to 0 made me experience bugs like missing some small screen updates. I mean, when it is 0 I missed many "****" when

typing

Quoted 2 lines

my login password.
When it is set FBC works fine.

This is what BSpec is telling us to program:

FBC_CTL
28 = ?
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

So the FBC_CTL bit 28 is not clear. BSpec doesn't say whether it should be 0 or 1. Did you try both values for that bit?

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
Signature · 2 lines
Ville Syrjälä
Intel OTC
#11 lore raw

Re: [PATCH 1/3] drm/i915: Enable FBC at Haswell.

uhm, got your point... I'm getting exactly this values, because fence number is 0 here,
so it is a coincidence and I should remove obj->fence_reg of FBC_CTL set, right?

Quoted 193 lines · Ville Syrjälä
Quoted 2 lines · Rodrigo Vivi

Yeah, this makes sense. Yes, I tested many times here, with 0 at bit 28 I always got that bug with missing updates, In the way it is it always

worked

Quoted 1 line

fine.

So did you actually test with this config?

FBC_CTL
28 = 1
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

Oh, and for this test you should make sure fence reg != 0, so that we can find out for sure whether the FBC_CTL bits 0:3 have some real effect.

Quoted 7 lines
Quoted 4 lines · Ville Syrjälä
Quoted 3 lines · Rodrigo Vivi

On Wed, Apr 10, 2013 at 5:18 AM, Ville Syrjälä <
[email protected]> wrote:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Rodrigo Vivi
Quoted 1 line

On Tue, Apr 9, 2013 at 5:35 AM, Ville Syrjälä <

[email protected]

Quoted 4 lines
Quoted 4 lines

wrote:

Quoted 1 line · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support

for

Quoted 19 lines
Quoted 19 lines

HSW.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 8 lines

It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 44

++++++++++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 3 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 0cfc778..88fd6fb 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -291,6 +291,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info · line 297

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {

/*

Quoted 27 lines
Quoted 27 lines

aka

Quoted 26 lines
Quoted 26 lines

*/

Quoted 16 lines
Quoted 16 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

Quoted 14 lines

index 5e91fbb..cb8e213 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)
 
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct

Quoted 4 lines

index 27f94cd..94e1c3a 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,43 @@ static bool ironlake_fbc_enabled(struct

drm_device

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

*dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc,

unsigned

Quoted 11 lines
Quoted 11 lines

long

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

interval)

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb =

to_intel_framebuffer(fb);

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     int plane = intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

DPFC_CTL_PLANEB;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct · line 269

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+     unsigned long stall_watermark = 200;
+     u32 dpfc_ctl;
+
+     dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
+     dpfc_ctl |= (plane | DPFC_CTL_LIMIT_1X);

Accroding to BSpec FBC is always tied to plane A. Bit 30 is

MBZ.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Yeah, you are right. I'm going to add a verification at begining

like:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
     if (intel_crtc->plane != PLANE_A) {
    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
    return;
}
Quoted 1 line

Maybe fix up plane C FBC support for IVB while you're poking

at the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

general direction?

Actually I wasn't trying general directions since I splited it

out.

Quoted 5 lines
Quoted 5 lines

It

Quoted 4 lines
Quoted 4 lines

was

Quoted 1 line

just bad copy and paste actually.

I'm not a fan of copy pasting code and letting the old code paths

rot.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct · line 270

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+     dpfc_ctl |= (HSW_DPFC_CTL_FENCE_EN | obj->fence_reg);

The CPU fence field must be written with 0. SNB/IVB could do

with

Quoted 9 lines
Quoted 9 lines

the

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

same fix.

Where did you get this restriction for HSW?

BSpec.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

Are you talking about bit 28 of 43208h DevHSW?

Bits 0:3 of the same register.

Quoted 2 lines

I couldn't find this restriction anywhere.
Besides that, setting it to 0 made me experience bugs like missing

some

Quoted 25 lines
Quoted 15 lines
Quoted 1 line

small screen updates. I mean, when it is 0 I missed many "****" when

typing

Quoted 2 lines

my login password.
When it is set FBC works fine.

This is what BSpec is telling us to program:

FBC_CTL
28 = ?
0:3 = 0

DPFC_CONTROL_SA
29 = 1
0:4 = fence number

Quoted 7 lines

So the FBC_CTL bit 28 is not clear. BSpec doesn't say whether it should be 0 or 1. Did you try both values for that bit?

--
Ville Syrjälä
Intel OTC

Quoted 3 lines

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

PATCH 1/1 drm/i915: Enable FBC at Haswell.

In reply to Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 46 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 0cfc778..88fd6fb 100644
@@ -291,6 +291,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 5e91fbb..cb8e213 100644
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +45 -1

58 lines not on this page · raw message

Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [PATCH] drm/i915: Enable FBC at Haswell.

Quoted 58 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 46 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 0cfc778..88fd6fb 100644
@@ -291,6 +291,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 5e91fbb..cb8e213 100644
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +5 -0
index 27f94cd..f3b35c4 100644
@@ -253,6 +253,45 @@ static bool ironlake_fbc_enabled(struct drm_device *dev)
 	return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_framebuffer *fb = crtc->fb;

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 270

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+	struct drm_i915_gem_object *obj = intel_fb->obj;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	unsigned long stall_watermark = 200;
+
+	/* FBC is tied to primary plane A in HSW */
+	if (intel_crtc->plane != PLANE_A) {
+	    dev_priv->no_fbc_reason = FBC_BAD_PLANE;
+	    return;
+	}

Already checked in intel_update_fbc()

Otherwise looks fine.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#14 lore raw

PATCH 1/1 drm/i915: Enable FBC at Haswell.

In reply to Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 43 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 48 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 0cfc778..88fd6fb 100644
@@ -291,6 +291,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 5e91fbb..cb8e213 100644
@@ -849,6 +849,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +41 -2

61 lines not on this page · raw message

Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

PATCH 1/1 drm/i915: Enable FBC at Haswell.

In reply to Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 43 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 48 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 9ebe895..ba0935d 100644
@@ -314,6 +314,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 077d40f..b9725ba 100644
@@ -857,6 +857,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +41 -2

61 lines not on this page · raw message

Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH 1/1 drm/i915: Enable FBC at Haswell.

In reply to Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

v4: Ville pointed out that according to BSpec FBC_CTL bits 0:3 must be 0.

Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 42 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 9ebe895..ba0935d 100644
@@ -314,6 +314,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 077d40f..b9725ba 100644
@@ -857,6 +857,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +40 -2

60 lines not on this page · raw message

Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [PATCH] drm/i915: Enable FBC at Haswell.

Quoted 38 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

v4: Ville pointed out that according to BSpec FBC_CTL bits 0:3 must be 0.

Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 42 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 9ebe895..ba0935d 100644
@@ -314,6 +314,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	GEN7_FEATURES,
 	.is_haswell = 1,
 	.is_mobile = 1,
+	.has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 077d40f..b9725ba 100644

drivers/gpu/drm/i915/i915_reg.h line 865

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -857,6 +857,12 @@
 #define   SNB_CPU_FENCE_ENABLE	(1<<29)
 #define DPFC_CPU_FENCE_OFFSET	0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE			0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT	12
+
+#define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)

These registers/bits already exists on IVB. All the registers you set seem to be in line with IVB BSpec, so I think you just need to to s/haswell/gen7/ everywhere, and then we get FBC for IVB for free.

Well, the only real work left would be adding plane B and C FBC support on IVB.

The new DPFC_CTL bits should also probably be grouped with the rest of the ILK_DPFC_CONTROL bits, otherwise it's difficult to know which register they belong to.

Quoted 22 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
drivers/gpu/drm/i915/intel_pm.c +11 -0
index f747cb0..7b20fc5 100644
@@ -253,6 +253,38 @@ static bool ironlake_fbc_enabled(struct drm_device *dev)
 	return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_framebuffer *fb = crtc->fb;
+	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+	struct drm_i915_gem_object *obj = intel_fb->obj;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	unsigned long stall_watermark = 200;
+
+	I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 276

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+		   (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+		   (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+	I915_WRITE(HSW_FBC_RT_BASE,
+		   obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+		   ILK_FBC_RT_VALID);
+
+	I915_WRITE(ILK_DPFC_CONTROL, DPFC_CTL_EN | DPFC_CTL_LIMIT_1X |
+		   HSW_DPFC_CTL_FENCE_EN | HSW_DPFC_CTL_DISABLE_SLB_INIT);
+
+	if (obj->fence_reg != I915_FENCE_REG_NONE) {

Is there actually a case that we wouldn't have a fence? I think we always reserve a fence for scanout even though we wouldn't really need it on gen4+ (or for untiled on gen2-3). At least we don't have any sanity checks for fence_reg in the ironlake_enable_fbc().

But if this can happen, then shouldn't we also clear the "fence enable" bit from ILK_DPFC_CONTROL?

Quoted 40 lines
drivers/gpu/drm/i915/intel_pm.c +19 -2
+		I915_WRITE(SNB_DPFC_CTL_SA,
+			   SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+		I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+	} else
+		I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+	sandybridge_blit_fbc_update(dev);
+
+	DRM_DEBUG_KMS("enabled fbc on plane A\n");
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -460,7 +492,8 @@ void intel_update_fbc(struct drm_device *dev)
 		dev_priv->no_fbc_reason = FBC_MODE_TOO_LARGE;
 		goto out_disable;
 	}
-	if ((IS_I915GM(dev) || IS_I945GM(dev)) && intel_crtc->plane != 0) {
+	if ((IS_I915GM(dev) || IS_I945GM(dev) || IS_HASWELL(dev))
+	    && intel_crtc->plane != 0) {
 		DRM_DEBUG_KMS("plane not 0, disabling compression\n");
 		dev_priv->no_fbc_reason = FBC_BAD_PLANE;
 		goto out_disable;
@@ -4180,7 +4213,12 @@ void intel_init_pm(struct drm_device *dev)
 	if (I915_HAS_FBC(dev)) {
 		if (HAS_PCH_SPLIT(dev)) {
 			dev_priv->display.fbc_enabled = ironlake_fbc_enabled;
-			dev_priv->display.enable_fbc = ironlake_enable_fbc;
+			if (IS_HASWELL(dev))
+				dev_priv->display.enable_fbc =
+					haswell_enable_fbc;
+			else
+				dev_priv->display.enable_fbc =
+					ironlake_enable_fbc;
 			dev_priv->display.disable_fbc = ironlake_disable_fbc;
 		} else if (IS_GM45(dev)) {
 			dev_priv->display.fbc_enabled = g4x_fbc_enabled;
Signature · 1 line
1.8.1.4
Signature · 2 lines
Ville Syrjälä
Intel OTC
#18 lore raw

Re: [PATCH] drm/i915: Enable FBC at Haswell.

Quoted 57 lines · Ville Syrjälä
Quoted 12 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

v4: Ville pointed out that according to BSpec FBC_CTL bits 0:3 must be 0.

Quoted 7 lines
Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_reg.h |  6 ++++++
 drivers/gpu/drm/i915/intel_pm.c | 42

+++++++++++++++++++++++++++++++++++++++--

Review

Quoted 3 lines
 3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.c

drivers/gpu/drm/i915/i915_drv.c static const struct intel_device_info

Quoted 4 lines

index 9ebe895..ba0935d 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -314,6 +314,7 @@ static const struct intel_device_info

intel_haswell_m_info = {

Review

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
      GEN7_FEATURES,
      .is_haswell = 1,
      .is_mobile = 1,
+     .has_fbc = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {            /* aka */
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

drivers/gpu/drm/i915/i915_reg.h line 865

Quoted 13 lines

index 077d40f..b9725ba 100644

drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -857,6 +857,12 @@
 #define   SNB_CPU_FENCE_ENABLE       (1<<29)
 #define DPFC_CPU_FENCE_OFFSET        0x100104
 
+/* Framebuffer compression for Haswell */
+#define HSW_FBC_RT_BASE                      0x7020
+#define   HSW_FBC_RT_BASE_ADDR_SHIFT 12
+
+#define   HSW_DPFC_CTL_FENCE_EN              (1<<28)
+#define   HSW_DPFC_CTL_DISABLE_SLB_INIT      (1<<15)

These registers/bits already exists on IVB. All the registers you set seem to be in line with IVB BSpec, so I think you just need to to s/haswell/gen7/ everywhere, and then we get FBC for IVB for free.

Quoted 3 lines

Well, the only real work left would be adding plane B and C FBC support on IVB.

I implemented here the ivb version, tested and it didn't worked. So I believe we can go on with HSW names and change it in the future if we can really get fbc working on ivb.
What do you think?

Quoted 5 lines

The new DPFC_CTL bits should also probably be grouped with the rest of the ILK_DPFC_CONTROL bits, otherwise it's difficult to know which register they belong to.

I just didn't do this because it was already organized by platforms. But it makes sense. coming on v5.

Quoted 33 lines

Review

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * GPIO regs
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device

Quoted 4 lines

index f747cb0..7b20fc5 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -253,6 +253,38 @@ static bool ironlake_fbc_enabled(struct drm_device

*dev)

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
      return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
+static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long

interval)

Quoted 17 lines
drivers/gpu/drm/i915/intel_pm.c +17 -0
+{
+     struct drm_device *dev = crtc->dev;
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct drm_framebuffer *fb = crtc->fb;
+     struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+     struct drm_i915_gem_object *obj = intel_fb->obj;
+     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+     unsigned long stall_watermark = 200;
+
+     I915_WRITE(ILK_DPFC_RECOMP_CTL, DPFC_RECOMP_STALL_EN |
+                (stall_watermark << DPFC_RECOMP_STALL_WM_SHIFT) |
+                (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));
+     I915_WRITE(HSW_FBC_RT_BASE,
+                obj->gtt_offset << HSW_FBC_RT_BASE_ADDR_SHIFT |
+                ILK_FBC_RT_VALID);
+
+     I915_WRITE(ILK_DPFC_CONTROL, DPFC_CTL_EN | DPFC_CTL_LIMIT_1X |
Quoted 9 lines

drivers/gpu/drm/i915/intel_pm.c static bool ironlake_fbc_enabled(struct drm_device *dev) · line 276

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+                HSW_DPFC_CTL_FENCE_EN | HSW_DPFC_CTL_DISABLE_SLB_INIT);
+
+     if (obj->fence_reg != I915_FENCE_REG_NONE) {

Is there actually a case that we wouldn't have a fence? I think we always reserve a fence for scanout even though we wouldn't really need it on gen4+ (or for untiled on gen2-3). At least we don't have any sanity checks for fence_reg in the ironlake_enable_fbc().

Yeah, you are right. I don't see any case without the fence. So I'm going to remove this check and else block in v5.

Quoted 52 lines

But if this can happen, then shouldn't we also clear the "fence enable" bit from ILK_DPFC_CONTROL?

Quoted 25 lines
drivers/gpu/drm/i915/intel_pm.c +13 -1
+             I915_WRITE(SNB_DPFC_CTL_SA,
+                        SNB_CPU_FENCE_ENABLE | obj->fence_reg);
+             I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
+     } else
+             I915_WRITE(SNB_DPFC_CTL_SA, ~SNB_CPU_FENCE_ENABLE);
+
+     sandybridge_blit_fbc_update(dev);
+
+     DRM_DEBUG_KMS("enabled fbc on plane A\n");
+}
+
 bool intel_fbc_enabled(struct drm_device *dev)
 {
      struct drm_i915_private *dev_priv = dev->dev_private;
@@ -460,7 +492,8 @@ void intel_update_fbc(struct drm_device *dev)
              dev_priv->no_fbc_reason = FBC_MODE_TOO_LARGE;
              goto out_disable;
      }
-     if ((IS_I915GM(dev) || IS_I945GM(dev)) && intel_crtc->plane != 0) {
+     if ((IS_I915GM(dev) || IS_I945GM(dev) || IS_HASWELL(dev))
+         && intel_crtc->plane != 0) {
              DRM_DEBUG_KMS("plane not 0, disabling compression\n");
              dev_priv->no_fbc_reason = FBC_BAD_PLANE;
              goto out_disable;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev) · line 4215

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4180,7 +4213,12 @@ void intel_init_pm(struct drm_device *dev)
      if (I915_HAS_FBC(dev)) {
              if (HAS_PCH_SPLIT(dev)) {
                      dev_priv->display.fbc_enabled =

ironlake_fbc_enabled;

drivers/gpu/drm/i915/intel_pm.c void intel_init_pm(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +6 -1
-                     dev_priv->display.enable_fbc = ironlake_enable_fbc;
+                     if (IS_HASWELL(dev))
+                             dev_priv->display.enable_fbc =
+                                     haswell_enable_fbc;
+                     else
+                             dev_priv->display.enable_fbc =
+                                     ironlake_enable_fbc;
                      dev_priv->display.disable_fbc =

ironlake_disable_fbc;

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
              } else if (IS_GM45(dev)) {
                      dev_priv->display.fbc_enabled = g4x_fbc_enabled;
--

1.8.1.4

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw

Re: [PATCH] drm/i915: Enable FBC at Haswell.

In reply to Rodrigo Vivi
Quoted 8 lines · Rodrigo Vivi

This patch introduce Frame Buffer Compression (FBC) support for HSW. It adds a new function haswell_enable_fbc to avoid getting ironlake_enable_fbc messed with many IS_HASWELL checks.

v2: Fixes from Ville.
* Fix Plane. FBC is tied to primary plane A in HSW
* Fix DPFC initial write to avoid let trash on the register.

Quoted 7 lines

v3: Checking for bad plane on intel_update_fbc() as Chris suggested.

v4: Ville pointed out that according to BSpec FBC_CTL bits 0:3 must be 0.

Cc Chris Wilson <[email protected]>
Cc Ville Syrjälä <[email protected]>

I'm failing in sanity checking FBC on HSW due to lack of the appropriate hardware. I still believe we need a cooperative userspace to make best use of FBC, avoid known limitations and apply required workarounds. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#20 lore raw

PATCH 2/3 drm/i915: HSW FBC WaFbcAsynchFlipDisableFbcQueue

In reply to Rodrigo Vivi

Display register 420B0h bit 22 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

---
 drivers/gpu/drm/i915/i915_reg.h | 7 +++++++
 drivers/gpu/drm/i915/intel_pm.c | 4 ++++
 2 files changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index cb8e213..2340bc2 100644
@@ -856,6 +856,13 @@
 #define   HSW_DPFC_CTL_FENCE_EN		(1<<28)
 #define   HSW_DPFC_CTL_DISABLE_SLB_INIT	(1<<15)
 
+#define _HSW_PIPE_SLICE_CHICKEN_1_A	0x420B0
+#define _HSW_PIPE_SLICE_CHICKEN_1_B	0x420B4
+#define   HSW_BYPASS_FBC_QUEUE		(1<<22)
+#define HSW_PIPE_SLICE_CHICKEN_1(pipe) _PIPE(pipe, + \
+					     _HSW_PIPE_SLICE_CHICKEN_1_A, + \
+					     _HSW_PIPE_SLICE_CHICKEN_1_B)
+
 /*
  * GPIO regs
  */
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 94e1c3a..0628a84 100644
@@ -278,6 +278,10 @@ static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
 	/* enable it... */
 	I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
 
+	/* WaFbcAsynchFlipDisableFbcQueue */
+	I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
+		   HSW_BYPASS_FBC_QUEUE);
+
 	if (obj->fence_reg != I915_FENCE_REG_NONE) {
 		I915_WRITE(SNB_DPFC_CTL_SA,
 			   SNB_CPU_FENCE_ENABLE | obj->fence_reg);
Signature · 1 line
1.8.1.4
#21 lore raw

PATCH 3/3 drm/i915: HSW FBC WaFbcDisableDpfcClockGating

In reply to Rodrigo Vivi

Display register 46500h bit 23 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

---
 drivers/gpu/drm/i915/i915_reg.h | 3 +++
 drivers/gpu/drm/i915/intel_pm.c | 2 ++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 2340bc2..2ef0292 100644
@@ -863,6 +863,9 @@
 					     _HSW_PIPE_SLICE_CHICKEN_1_A, + \
 					     _HSW_PIPE_SLICE_CHICKEN_1_B)
 
+#define HSW_CLKGATE_DISABLE_PART_1	0x46500
+#define   HSW_DPFC_GATING_DISABLE	(1<<23)
+
 /*
  * GPIO regs
  */
drivers/gpu/drm/i915/intel_pm.c +2 -0
index 0628a84..f2ce541 100644
@@ -281,6 +281,8 @@ static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
 	/* WaFbcAsynchFlipDisableFbcQueue */
 	I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
 		   HSW_BYPASS_FBC_QUEUE);
+	/* WaFbcDisableDpfcClockGating */
+	I915_WRITE(HSW_CLKGATE_DISABLE_PART_1, HSW_DPFC_GATING_DISABLE);
 
 	if (obj->fence_reg != I915_FENCE_REG_NONE) {
 		I915_WRITE(SNB_DPFC_CTL_SA,
Signature · 1 line
1.8.1.4
#22 lore raw

Re: [PATCH 3/3] drm/i915: HSW FBC WaFbcDisableDpfcClockGating

Quoted 2 lines · Rodrigo Vivi

Display register 46500h bit 23 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

So should we enable it again after FBC is disabled to avoid wasting power?

Quoted 41 lines
---
 drivers/gpu/drm/i915/i915_reg.h | 3 +++
 drivers/gpu/drm/i915/intel_pm.c | 2 ++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 2340bc2..2ef0292 100644
@@ -863,6 +863,9 @@
 					     _HSW_PIPE_SLICE_CHICKEN_1_A, + \
 					     _HSW_PIPE_SLICE_CHICKEN_1_B)
 
+#define HSW_CLKGATE_DISABLE_PART_1	0x46500
+#define   HSW_DPFC_GATING_DISABLE	(1<<23)
+
 /*
  * GPIO regs
  */
drivers/gpu/drm/i915/intel_pm.c +2 -0
index 0628a84..f2ce541 100644
@@ -281,6 +281,8 @@ static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
 	/* WaFbcAsynchFlipDisableFbcQueue */
 	I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
 		   HSW_BYPASS_FBC_QUEUE);
+	/* WaFbcDisableDpfcClockGating */
+	I915_WRITE(HSW_CLKGATE_DISABLE_PART_1, HSW_DPFC_GATING_DISABLE);
 
 	if (obj->fence_reg != I915_FENCE_REG_NONE) {
 		I915_WRITE(SNB_DPFC_CTL_SA,
Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
#23 lore raw

Re: [PATCH 3/3] drm/i915: HSW FBC WaFbcDisableDpfcClockGating

On Tue, Apr 9, 2013 at 5:37 AM, Ville Syrjälä <[email protected]

Quoted 9 lines

wrote:

Quoted 2 lines · Rodrigo Vivi

Display register 46500h bit 23 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

So should we enable it again after FBC is disabled to avoid wasting power?

I didn't take the opposite direction because it wasn't explicit. I tested to enabled it again after FBC is disabled but I didn't see any difference.
So, you suggestion is to enable back anyway?

Quoted 51 lines

Review

Quoted 9 lines
---
 drivers/gpu/drm/i915/i915_reg.h | 3 +++
 drivers/gpu/drm/i915/intel_pm.c | 2 ++
 2 files changed, 5 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

drivers/gpu/drm/i915/i915_reg.h line 863

Quoted 5 lines

index 2340bc2..2ef0292 100644

drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -863,6 +863,9 @@
                                           _HSW_PIPE_SLICE_CHICKEN_1_A,

+ \

Review

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
                                           _HSW_PIPE_SLICE_CHICKEN_1_B)
 
+#define HSW_CLKGATE_DISABLE_PART_1   0x46500
+#define   HSW_DPFC_GATING_DISABLE    (1<<23)
+
 /*
  * GPIO regs
  */
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static void haswell_enable_fbc(struct drm_crtc

Quoted 4 lines

index 0628a84..f2ce541 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -281,6 +281,8 @@ static void haswell_enable_fbc(struct drm_crtc

*crtc, unsigned long interval)

Quoted 11 lines
drivers/gpu/drm/i915/intel_pm.c +2 -1
      /* WaFbcAsynchFlipDisableFbcQueue */
      I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
                 HSW_BYPASS_FBC_QUEUE);
+     /* WaFbcDisableDpfcClockGating */
+     I915_WRITE(HSW_CLKGATE_DISABLE_PART_1, HSW_DPFC_GATING_DISABLE);
 
      if (obj->fence_reg != I915_FENCE_REG_NONE) {
              I915_WRITE(SNB_DPFC_CTL_SA,
--

1.8.1.4

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#24 lore raw

Re: [PATCH 3/3] drm/i915: HSW FBC WaFbcDisableDpfcClockGating

Quoted 7 lines · Rodrigo Vivi

On Tue, Apr 9, 2013 at 5:37 AM, Ville Syrjälä <[email protected]

Quoted 6 lines

wrote:

Quoted 2 lines · Rodrigo Vivi

Display register 46500h bit 23 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

Quoted 8 lines
Quoted 3 lines

So should we enable it again after FBC is disabled to avoid wasting power?

I didn't take the opposite direction because it wasn't explicit. I tested to enabled it again after FBC is disabled but I didn't see any difference.
So, you suggestion is to enable back anyway?

Perhaps. The idea was that it might save some tiny amount of power.

Quoted 58 lines
Quoted 52 lines

Review

Quoted 10 lines
---
 drivers/gpu/drm/i915/i915_reg.h | 3 +++
 drivers/gpu/drm/i915/intel_pm.c | 2 ++
 2 files changed, 5 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h

drivers/gpu/drm/i915/i915_reg.h line 863

Quoted 5 lines

index 2340bc2..2ef0292 100644

drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -863,6 +863,9 @@
                                           _HSW_PIPE_SLICE_CHICKEN_1_A,

+ \

Review

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
                                           _HSW_PIPE_SLICE_CHICKEN_1_B)
 
+#define HSW_CLKGATE_DISABLE_PART_1   0x46500
+#define   HSW_DPFC_GATING_DISABLE    (1<<23)
+
 /*
  * GPIO regs
  */
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

drivers/gpu/drm/i915/intel_pm.c static void haswell_enable_fbc(struct drm_crtc

Quoted 4 lines

index 0628a84..f2ce541 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -281,6 +281,8 @@ static void haswell_enable_fbc(struct drm_crtc

*crtc, unsigned long interval)

Quoted 11 lines
drivers/gpu/drm/i915/intel_pm.c +2 -1
      /* WaFbcAsynchFlipDisableFbcQueue */
      I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
                 HSW_BYPASS_FBC_QUEUE);
+     /* WaFbcDisableDpfcClockGating */
+     I915_WRITE(HSW_CLKGATE_DISABLE_PART_1, HSW_DPFC_GATING_DISABLE);
 
      if (obj->fence_reg != I915_FENCE_REG_NONE) {
              I915_WRITE(SNB_DPFC_CTL_SA,
--

1.8.1.4

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Ville Syrjälä
Intel OTC

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
Signature · 2 lines
Ville Syrjälä
Intel OTC
#25 lore raw

PATCH 1/1 drm/i915: HSW FBC WaFbcDisableDpfcClockGating

In reply to Rodrigo Vivi

Display register 46500h bit 23 must be set to 1b for the entire time that Frame Buffer Compression is enabled.

v2: Ville suggested to enable it back when disabling fbc to avoid wasting
power.

Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/i915_reg.h | 3 +++
 drivers/gpu/drm/i915/intel_pm.c | 7 +++++++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 2340bc2..2ef0292 100644
@@ -863,6 +863,9 @@
 					     _HSW_PIPE_SLICE_CHICKEN_1_A, + \
 					     _HSW_PIPE_SLICE_CHICKEN_1_B)
 
+#define HSW_CLKGATE_DISABLE_PART_1	0x46500
+#define   HSW_DPFC_GATING_DISABLE	(1<<23)
+
 /*
  * GPIO regs
  */
drivers/gpu/drm/i915/intel_pm.c +7 -0
index 25dd054..5914d75 100644
@@ -242,6 +242,11 @@ static void ironlake_disable_fbc(struct drm_device *dev)
 		dpfc_ctl &= ~DPFC_CTL_EN;
 		I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl);
 
+		if(IS_HASWELL(dev))
+		    /* WaFbcDisableDpfcClockGating */
+		    I915_WRITE(HSW_CLKGATE_DISABLE_PART_1,
+			       ~HSW_DPFC_GATING_DISABLE);
+
 		DRM_DEBUG_KMS("disabled FBC\n");
 	}
 }
@@ -283,6 +288,8 @@ static void haswell_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
 	/* WaFbcAsynchFlipDisableFbcQueue */
 	I915_WRITE(HSW_PIPE_SLICE_CHICKEN_1(intel_crtc->pipe),
 		   HSW_BYPASS_FBC_QUEUE);
+	/* WaFbcDisableDpfcClockGating */
+	I915_WRITE(HSW_CLKGATE_DISABLE_PART_1, HSW_DPFC_GATING_DISABLE);
 
 	if (obj->fence_reg != I915_FENCE_REG_NONE) {
 		I915_WRITE(SNB_DPFC_CTL_SA,
Signature · 6 lines
1.8.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx