Skip to contentSkip to conversation

(no subject)

PATCH In review Jesse Barnes 3 participants 9 messages Apr 7, 2011 – Apr 20, 2011

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

These are some prep patches I'd like to get feedback on. I've only compile tested them so far (the actual hw support code this is for was tested before the split), so testing would be appreciated as well.

Thanks,
Jesse

#1 lore raw

PATCH 1/3 drm/i915: make FDI training a display function

Rather than branching in ironlake_pch_enable, add a new train_fdi function to the display function pointer struct and use it instead.

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 5004724..b4116ae 100644
@@ -203,6 +203,7 @@ struct drm_i915_display_funcs {
 	int (*get_display_clock_speed)(struct drm_device *dev);
 	int (*get_fifo_size)(struct drm_device *dev, int plane);
 	void (*update_wm)(struct drm_device *dev);
+	void (*train_fdi)(struct drm_crtc *crtc);
 	/* clock updates for mode set */
 	/* cursor updates */
 	/* render clock increase/decrease */
drivers/gpu/drm/i915/intel_display.c +3 -4
index 432fc04..9055eff 100644
@@ -2757,10 +2757,7 @@ static void ironlake_pch_enable(struct drm_crtc *crtc)
 	u32 reg, temp;
 
 	/* For PCH output, training FDI link */
-	if (IS_GEN6(dev))
-		gen6_fdi_link_train(crtc);
-	else
-		ironlake_fdi_link_train(crtc);
+	dev_priv->display.train_fdi(crtc);
 
 	intel_enable_pch_pll(dev_priv, pipe);
 
@@ -7270,6 +7267,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = ironlake_fdi_link_train;
 		} else if (IS_GEN6(dev)) {
 			if (SNB_READ_WM0_LATENCY()) {
 				dev_priv->display.update_wm = sandybridge_update_wm;
@@ -7278,6 +7276,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = gen6_fdi_link_train;
 		} else
 			dev_priv->display.update_wm = NULL;
 	} else if (IS_PINEVIEW(dev)) {
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/3] drm/i915: make FDI training a display function

Quoted 46 lines · Jesse Barnes

Rather than branching in ironlake_pch_enable, add a new train_fdi function to the display function pointer struct and use it instead.

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 5004724..b4116ae 100644
@@ -203,6 +203,7 @@ struct drm_i915_display_funcs {
 	int (*get_display_clock_speed)(struct drm_device *dev);
 	int (*get_fifo_size)(struct drm_device *dev, int plane);
 	void (*update_wm)(struct drm_device *dev);
+	void (*train_fdi)(struct drm_crtc *crtc);
 	/* clock updates for mode set */
 	/* cursor updates */
 	/* render clock increase/decrease */
drivers/gpu/drm/i915/intel_display.c +2 -4
index 432fc04..9055eff 100644
@@ -2757,10 +2757,7 @@ static void ironlake_pch_enable(struct drm_crtc *crtc)
 	u32 reg, temp;
 
 	/* For PCH output, training FDI link */
-	if (IS_GEN6(dev))
-		gen6_fdi_link_train(crtc);
-	else
-		ironlake_fdi_link_train(crtc);
+	dev_priv->display.train_fdi(crtc);
 
 	intel_enable_pch_pll(dev_priv, pipe);
 
@@ -7270,6 +7267,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = ironlake_fdi_link_train;
 		} else if (IS_GEN6(dev)) {
 			if (SNB_READ_WM0_LATENCY()) {
 				dev_priv->display.update_wm = sandybridge_update_wm;

drivers/gpu/drm/i915/intel_display.c static void intel_init_display(struct drm_device *dev) · line 7282

Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -7278,6 +7276,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = gen6_fdi_link_train;
 		} else
 			dev_priv->display.update_wm = NULL;
 	} else if (IS_PINEVIEW(dev)) {

I prefer when the function pointer is named similarly to the function. Makes it easier to read/find code.

(*fdi_link_train)(struct drm_crtc *crtc);
OR
(*link_train)(struct drm_crtc *crtc);

#3 lore raw

Re: [PATCH 1/3] drm/i915: make FDI training a display function

Quoted 20 lines · On Wed, 20 Apr 2011 07:45:08 -0700 Ben Widawsky <[email protected]> wrote:
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -7270,6 +7267,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = ironlake_fdi_link_train;
 		} else if (IS_GEN6(dev)) {
 			if (SNB_READ_WM0_LATENCY()) {
 				dev_priv->display.update_wm = sandybridge_update_wm;

drivers/gpu/drm/i915/intel_display.c static void intel_init_display(struct drm_device *dev) · line 7282

Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -7278,6 +7276,7 @@ static void intel_init_display(struct drm_device *dev)
 					      "Disable CxSR\n");
 				dev_priv->display.update_wm = NULL;
 			}
+			dev_priv->display.train_fdi = gen6_fdi_link_train;
 		} else
 			dev_priv->display.update_wm = NULL;
 	} else if (IS_PINEVIEW(dev)) {

I prefer when the function pointer is named similarly to the function. Makes it easier to read/find code.

Quoted 3 lines

(*fdi_link_train)(struct drm_crtc *crtc);
OR
(*link_train)(struct drm_crtc *crtc);

Yeah, fdi_link_train is probably a better name. Thanks for checking it out.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#4 lore raw

PATCH 2/3 drm/i915: split irq handling into per-chipset functions

In reply to Jesse Barnes

Set the IRQ handling functions in driver load so they'll just be used directly, rather than branching over most of the code in the chipset functions.

---
 drivers/gpu/drm/i915/i915_dma.c |   12 ++++++++++
 drivers/gpu/drm/i915/i915_drv.h |    6 +++++
 drivers/gpu/drm/i915/i915_irq.c |   45 +++++++++++++++++++++-----------------
 3 files changed, 43 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +12 -0
index 7273037..38e62bd 100644
@@ -1253,6 +1253,18 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
 	intel_modeset_init(dev);
 
+	if (HAS_PCH_SPLIT(dev)) {
+		dev->driver->irq_handler = ironlake_irq_handler;
+		dev->driver->irq_preinstall = ironlake_irq_preinstall;
+		dev->driver->irq_postinstall = ironlake_irq_postinstall;
+		dev->driver->irq_uninstall = ironlake_irq_uninstall;
+	} else {
+		dev->driver->irq_preinstall = i915_driver_irq_preinstall;
+		dev->driver->irq_postinstall = i915_driver_irq_postinstall;
+		dev->driver->irq_uninstall = i915_driver_irq_uninstall;
+		dev->driver->irq_handler = i915_driver_irq_handler;
+	}
+
 	ret = drm_irq_install(dev);
 	if (ret)
 		goto cleanup_vga_switcheroo;
drivers/gpu/drm/i915/i915_drv.h +6 -0
index b4116ae..313202f 100644
@@ -1011,6 +1011,12 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
 extern void i915_driver_irq_preinstall(struct drm_device * dev);
 extern int i915_driver_irq_postinstall(struct drm_device *dev);
 extern void i915_driver_irq_uninstall(struct drm_device * dev);
+
+extern irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS);
+extern void ironlake_irq_preinstall(struct drm_device *dev);
+extern int ironlake_irq_postinstall(struct drm_device *dev);
+extern void ironlake_irq_uninstall(struct drm_device *dev);
+
 extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
 				struct drm_file *file_priv);
 extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_irq.c +25 -20

111 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH 2/3] drm/i915: split irq handling into per-chipset functions

Quoted 3 lines · Jesse Barnes

Set the IRQ handling functions in driver load so they'll just be used directly, rather than branching over most of the code in the chipset functions.

This is the direction we definitely need to go in. However, it is still a tangled mess of which functions are called for which chipset.

Is it any clearer to have a display vfunc table for each chipset? It would still be a mess, but at least there will be an overview of how each chipset works in a single spot. Invaluable for tracing through the function pointers later.

One thing we need to be careful is to move the common code into small helper routines to avoid unnecessarily duplicating it. -Chris

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

Re: [PATCH 2/3] drm/i915: split irq handling into per-chipset functions

Quoted 5 lines · On Thu, 07 Apr 2011 22:50:42 +0100 Chris Wilson <[email protected]>…
Quoted 3 lines · Jesse Barnes

Set the IRQ handling functions in driver load so they'll just be used directly, rather than branching over most of the code in the chipset functions.

Quoted 7 lines

This is the direction we definitely need to go in. However, it is still a tangled mess of which functions are called for which chipset.

Is it any clearer to have a display vfunc table for each chipset? It would still be a mess, but at least there will be an overview of how each chipset works in a single spot. Invaluable for tracing through the function pointers later.

Yeah, initializing it all in one place would help, but the existing KMS/non-KMS split makes that hard for things like IRQ handling.

Quoted 2 lines

One thing we need to be careful is to move the common code into small helper routines to avoid unnecessarily duplicating it.

But not before we're sure about the duplication! Obviously things like the workqueue init at IRQ install time could be shared, but I don't like the idea of sharing hardware code unless it's absolutely identical, given our history.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#7 lore raw

Re: [PATCH 2/3] drm/i915: split irq handling into per-chipset functions

Quoted 7 lines · Jesse Barnes
Quoted 2 lines · On Thu, 07 Apr 2011 22:50:42 +0100 Chris Wilson <[email protected]>…

One thing we need to be careful is to move the common code into small helper routines to avoid unnecessarily duplicating it.

But not before we're sure about the duplication! Obviously things like the workqueue init at IRQ install time could be shared,

Actually that workqueue init is in the wrong place entirely, but that was the sort of generic code I was looking at. ;-)

Quoted 3 lines

but I don't
like the idea of sharing hardware code unless it's absolutely identical, given our history.

Agreed, I think the model you've proposed of doing bring-up on a separate copy of the code and then gradually merge back the duplicate portions carries the least risk. Also looking at our history, we carry a lot of bugs that we only notice when looking at the next chipset iteration... -Chris

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

PATCH 3/3 drm/i915: split enable/disable vblank code into chipset specific functions

In reply to Jesse Barnes

This makes the Ironlake+ code trivial and generally simplifies things.

---
 drivers/gpu/drm/i915/i915_dma.c |    4 +++
 drivers/gpu/drm/i915/i915_drv.h |    2 +
 drivers/gpu/drm/i915/i915_irq.c |   42 ++++++++++++++++++++++++++++----------
 3 files changed, 37 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -0
index 38e62bd..a369634 100644
@@ -1258,11 +1258,15 @@ static int i915_load_modeset_init(struct drm_device *dev)
 		dev->driver->irq_preinstall = ironlake_irq_preinstall;
 		dev->driver->irq_postinstall = ironlake_irq_postinstall;
 		dev->driver->irq_uninstall = ironlake_irq_uninstall;
+		dev->driver->enable_vblank = ironlake_enable_vblank;
+		dev->driver->disable_vblank = ironlake_disable_vblank;
 	} else {
 		dev->driver->irq_preinstall = i915_driver_irq_preinstall;
 		dev->driver->irq_postinstall = i915_driver_irq_postinstall;
 		dev->driver->irq_uninstall = i915_driver_irq_uninstall;
 		dev->driver->irq_handler = i915_driver_irq_handler;
+		dev->driver->enable_vblank = i915_enable_vblank;
+		dev->driver->disable_vblank = i915_disable_vblank;
 	}
 
 	ret = drm_irq_install(dev);
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 313202f..7d4fafc 100644
@@ -1023,6 +1023,8 @@ extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
 				struct drm_file *file_priv);
 extern int i915_enable_vblank(struct drm_device *dev, int crtc);
 extern void i915_disable_vblank(struct drm_device *dev, int crtc);
+extern int ironlake_enable_vblank(struct drm_device *dev, int crtc);
+extern void ironlake_disable_vblank(struct drm_device *dev, int crtc);
 extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
 extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc);
 extern int i915_vblank_swap(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_irq.c +31 -11

60 lines not on this page · raw message

Signature · 1 line
1.7.1