Skip to contentSkip to conversation

drm/i915: prepare for video codec ring buffer on Sandybridge

PATCH In review Xiang, Haihao 2 participants 4 messages Sep 13, 2010 – Sep 15, 2010

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

PATCH v2 1/2 drm/i915: prepare for video codec ring buffer on Sandybridge

Some little changes:
Add set_tail hook to struct intel_ring_buffer fix HAS_BSD with a device info flag
Don't export the initialiser of struct intel_ring_buffer

---
 drivers/gpu/drm/i915/i915_drv.c         |    4 ++
 drivers/gpu/drm/i915/i915_drv.h         |    3 +-
 drivers/gpu/drm/i915/i915_gem.c         |   14 +-------
 drivers/gpu/drm/i915/intel_ringbuffer.c |   51 ++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_ringbuffer.h |    6 ++-
 5 files changed, 56 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +4 -0
index dffc1bc..9d892fc 100644
@@ -121,12 +121,14 @@ static const struct intel_device_info intel_g33_info = {
 static const struct intel_device_info intel_g45_info = {
 	.gen = 4, .is_i965g = 1, .is_g4x = 1, .is_i9xx = 1, .need_gfx_hws = 1,
 	.has_pipe_cxsr = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct intel_device_info intel_gm45_info = {
 	.gen = 4, .is_i965g = 1, .is_g4x = 1, .is_i9xx = 1,
 	.is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1, .has_rc6 = 1,
 	.has_pipe_cxsr = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct intel_device_info intel_pineview_info = {
@@ -138,11 +140,13 @@ static const struct intel_device_info intel_pineview_info = {
 static const struct intel_device_info intel_ironlake_d_info = {
 	.gen = 5, .is_ironlake = 1, .is_i965g = 1, .is_i9xx = 1,
 	.need_gfx_hws = 1, .has_pipe_cxsr = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct intel_device_info intel_ironlake_m_info = {
 	.gen = 5, .is_ironlake = 1, .is_mobile = 1, .is_i965g = 1, .is_i9xx = 1,
 	.need_gfx_hws = 1, .has_fbc = 1, .has_rc6 = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct intel_device_info intel_sandybridge_d_info = {
drivers/gpu/drm/i915/i915_drv.h +2 -1
index b3efb30..863130f 100644
@@ -216,6 +216,7 @@ struct intel_device_info {
 	u8 cursor_needs_physical : 1;
 	u8 has_overlay : 1;
 	u8 overlay_needs_physical : 1;
+	u8 has_bsd_ring : 1;
 };
 
 enum no_fbc_reason {
@@ -1230,7 +1231,7 @@ static inline void i915_write(struct drm_i915_private *dev_priv, u32 reg,
 #define IS_GEN5(dev)	(INTEL_INFO(dev)->gen == 5)
 #define IS_GEN6(dev)	(INTEL_INFO(dev)->gen == 6)
 
-#define HAS_BSD(dev)            (IS_IRONLAKE(dev) || IS_G4X(dev))
+#define HAS_BSD(dev)            (INTEL_INFO(dev)->has_bsd_ring)
 #define I915_NEED_GFX_HWS(dev)	(INTEL_INFO(dev)->need_gfx_hws)
 
 #define HAS_OVERLAY(dev) 		(INTEL_INFO(dev)->has_overlay)
drivers/gpu/drm/i915/i915_gem.c +2 -12
index e0b7ddc..dc2826d 100644
@@ -4451,28 +4451,18 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	int ret;
 
-	dev_priv->render_ring = render_ring;
-
-	if (!I915_NEED_GFX_HWS(dev)) {
-		dev_priv->render_ring.status_page.page_addr
-			= dev_priv->status_page_dmah->vaddr;
-		memset(dev_priv->render_ring.status_page.page_addr,
-				0, PAGE_SIZE);
-	}
-
 	if (HAS_PIPE_CONTROL(dev)) {
 		ret = i915_gem_init_pipe_control(dev);
 		if (ret)
 			return ret;
 	}
 
-	ret = intel_init_ring_buffer(dev, &dev_priv->render_ring);
+	ret = intel_init_render_ring_buffer(dev);
 	if (ret)
 		goto cleanup_pipe_control;
 
 	if (HAS_BSD(dev)) {
-		dev_priv->bsd_ring = bsd_ring;
-		ret = intel_init_ring_buffer(dev, &dev_priv->bsd_ring);
+		ret = intel_init_bsd_ring_buffer(dev);
 		if (ret)
 			goto cleanup_render_ring;
 	}
drivers/gpu/drm/i915/intel_ringbuffer.c +44 -7

108 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +4 -2
index d3e5f40..c0fa105 100644
@@ -45,6 +45,8 @@ struct  intel_ring_buffer {
 			struct intel_ring_buffer *ring);
 	unsigned int	(*get_tail)(struct drm_device *dev,
 			struct intel_ring_buffer *ring);
+	void		(*set_tail)(struct drm_device *dev,
+			u32 value);
 	unsigned int	(*get_active_head)(struct drm_device *dev,
 			struct intel_ring_buffer *ring);
 	void		(*advance_ring)(struct drm_device *dev,
@@ -130,7 +132,7 @@ void intel_ring_advance(struct drm_device *dev,
 u32 intel_ring_get_seqno(struct drm_device *dev,
 		struct intel_ring_buffer *ring);
 
-extern struct intel_ring_buffer render_ring;
-extern struct intel_ring_buffer bsd_ring;
+int intel_init_render_ring_buffer(struct drm_device *dev);
+int intel_init_bsd_ring_buffer(struct drm_device *dev);
 
 #endif /* _INTEL_RINGBUFFER_H_ */
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 2/2 drm/i95: Add a new ring buffer on Sandybridge

This ring buffer is used for video decoding/encoding on Sandybridge.

---
 drivers/gpu/drm/i915/i915_drv.c         |    2 +
 drivers/gpu/drm/i915/i915_irq.c         |   15 +++-
 drivers/gpu/drm/i915/i915_reg.h         |   26 ++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.c |  131 ++++++++++++++++++++++++++++++-
 4 files changed, 166 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 9d892fc..1bc1125 100644
@@ -152,11 +152,13 @@ static const struct intel_device_info intel_ironlake_m_info = {
 static const struct intel_device_info intel_sandybridge_d_info = {
 	.gen = 6, .is_i965g = 1, .is_i9xx = 1,
 	.need_gfx_hws = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct intel_device_info intel_sandybridge_m_info = {
 	.gen = 6, .is_i965g = 1, .is_mobile = 1, .is_i9xx = 1,
 	.need_gfx_hws = 1, .has_hotplug = 1,
+	.has_bsd_ring = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_irq.c +10 -5
index bc8438d..bff4ba7 100644
@@ -300,6 +300,10 @@ static irqreturn_t ironlake_irq_handler(struct drm_device *dev)
 	u32 de_iir, gt_iir, de_ier, pch_iir;
 	struct drm_i915_master_private *master_priv;
 	struct intel_ring_buffer *render_ring = &dev_priv->render_ring;
+	u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT;
+
+	if (IS_GEN6(dev))
+		bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT;
 
 	/* disable master interrupt before clearing iir  */
 	de_ier = I915_READ(DEIER);
@@ -330,10 +334,9 @@ static irqreturn_t ironlake_irq_handler(struct drm_device *dev)
 		dev_priv->hangcheck_count = 0;
 		mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD);
 	}
-	if (gt_iir & GT_BSD_USER_INTERRUPT)
+	if (gt_iir & bsd_usr_interrupt)
 		DRM_WAKEUP(&dev_priv->bsd_ring.irq_queue);
 
-
 	if (de_iir & DE_GSE)
 		intel_opregion_gse_intr(dev);
 
@@ -1441,17 +1444,19 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
 	I915_WRITE(DEIER, dev_priv->de_irq_enable_reg);
 	(void) I915_READ(DEIER);
 
-	/* Gen6 only needs render pipe_control now */
 	if (IS_GEN6(dev))
-		render_mask = GT_PIPE_NOTIFY;
+		render_mask = GT_PIPE_NOTIFY | GT_GEN6_BSD_USER_INTERRUPT;
 
 	dev_priv->gt_irq_mask_reg = ~render_mask;
 	dev_priv->gt_irq_enable_reg = render_mask;
 
 	I915_WRITE(GTIIR, I915_READ(GTIIR));
 	I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
-	if (IS_GEN6(dev))
+	if (IS_GEN6(dev)) {
 		I915_WRITE(GEN6_RENDER_IMR, ~GEN6_RENDER_PIPE_CONTROL_NOTIFY_INTERRUPT);
+		I915_WRITE(GEN6_BSD_IMR, ~GEN6_BSD_IMR_USER_INTERRUPT);
+	}
+
 	I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg);
 	(void) I915_READ(GTIER);
 
drivers/gpu/drm/i915/i915_reg.h +24 -2
index fd229ab..c7ef079 100644
@@ -194,11 +194,11 @@
 #define MI_STORE_DWORD_INDEX	MI_INSTR(0x21, 1)
 #define   MI_STORE_DWORD_INDEX_SHIFT 2
 #define MI_LOAD_REGISTER_IMM	MI_INSTR(0x22, 1)
+#define MI_FLUSH_DW		MI_INSTR(0x26, 2) /* for GEN6 */
 #define MI_BATCH_BUFFER		MI_INSTR(0x30, 1)
 #define   MI_BATCH_NON_SECURE	(1)
 #define   MI_BATCH_NON_SECURE_I965 (1<<8)
 #define MI_BATCH_BUFFER_START	MI_INSTR(0x31, 0)
-
 /*
  * 3D instructions used by the kernel
  */
@@ -481,6 +481,28 @@
 #define BSD_HWS_PGA            0x04080
 
 /*
+ * video command stream instruction and interrupt control register defines
+ * for GEN6
+ */
+#define GEN6_BSD_RING_TAIL		0x12030
+#define GEN6_BSD_RING_HEAD		0x12034
+#define GEN6_BSD_RING_START		0x12038
+#define GEN6_BSD_RING_CTL		0x1203c
+#define GEN6_BSD_RING_ACTHD		0x12074
+#define GEN6_BSD_HWS_PGA		0x14080
+
+#define GEN6_BSD_SLEEP_PSMI_CONTROL	0x12050
+#define   GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_MODIFY_MASK	(1 << 16)
+#define   GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_DISABLE		(1 << 0)
+#define   GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_ENABLE		0
+#define   GEN6_BSD_SLEEP_PSMI_CONTROL_IDLE_INDICATOR			(1 << 3) 
+
+#define GEN6_BSD_IMR			0x120a8
+#define   GEN6_BSD_IMR_USER_INTERRUPT	(1 << 12)
+
+#define GEN6_BSD_RNCID			0x12198
+
+/*
  * Framebuffer compression (915+ only)
  */
 
@@ -2556,7 +2578,7 @@
 #define GT_SYNC_STATUS          (1 << 2)
 #define GT_USER_INTERRUPT       (1 << 0)
 #define GT_BSD_USER_INTERRUPT   (1 << 5)
-
+#define GT_GEN6_BSD_USER_INTERRUPT	(1 << 12)
 
 #define GTISR   0x44010
 #define GTIMR   0x44014
drivers/gpu/drm/i915/intel_ringbuffer.c +130 -1

149 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw
In reply to Xiang, Haihao
Quoted 4 lines · Haihao

Some little changes:
Add set_tail hook to struct intel_ring_buffer fix HAS_BSD with a device info flag
Don't export the initialiser of struct intel_ring_buffer

A really nice set of cleanups, thanks! However, that changelog should have been an instant give away that something was wrong with the patch. ;-)

Carl, would you care to remind us how to write a good commit? You do it so much better than I. Here is my lame version:

- A patch should just do one thing and one thing only.

This is vital if we ever need to bisect or revert a patch. It also means that we create smaller, more readable commits - which is a good thing!

- Give an overview of what was done and more importantly *why*.

We can all read code and spend a long time pondering the complexities and mysteries of a piece of code and eventually come to an understanding of what that code does. We will never be able to work out what you were thinking or intending to do as you wrote that piece of code though.

You may have to write several paragraphs explaining the background and your analysis of a bug or design that you wish to implement. Obviously, for these simple cleanups there is little to say other than it makes the code easier to read and reduces the chance for subtle bugs to creep in. More complex code requires deeper thought and understanding and the changelog should reflect that.

- The patch should record all those who contributed to the discovery of the bug, if applicable, and to those who reviewed and tested the patches. If the patch touches code outside of our sole purview, we must obtain at least an ACK by the maintainer of that code.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw
Quoted 6 lines · Chris Wilson
Quoted 4 lines · Haihao

Some little changes:
Add set_tail hook to struct intel_ring_buffer fix HAS_BSD with a device info flag
Don't export the initialiser of struct intel_ring_buffer

Quoted 7 lines

A really nice set of cleanups, thanks! However, that changelog should have been an instant give away that something was wrong with the patch. ;-)

Carl, would you care to remind us how to write a good commit? You do it so much better than I. Here is my lame version:

- A patch should just do one thing and one thing only.

Thanks for your comments. I will separate it into three patches

Haihao

Quoted 26 lines

This is vital if we ever need to bisect or revert a patch. It also means that we create smaller, more readable commits - which is a good thing!

- Give an overview of what was done and more importantly *why*.

We can all read code and spend a long time pondering the complexities and mysteries of a piece of code and eventually come to an understanding of what that code does. We will never be able to work out what you were thinking or intending to do as you wrote that piece of code though.

You may have to write several paragraphs explaining the background and your analysis of a bug or design that you wish to implement. Obviously, for these simple cleanups there is little to say other than it makes the code easier to read and reduces the chance for subtle bugs to creep in. More complex code requires deeper thought and understanding and the changelog should reflect that.

- The patch should record all those who contributed to the discovery of the bug, if applicable, and to those who reviewed and tested the patches. If the patch touches code outside of our sole purview, we must obtain at least an ACK by the maintainer of that code.
-Chris