Skip to contentSkip to conversation

drm/i915: new blitter ring support from Sandybridge

PATCH In review Zhenyu Wang 2 participants 4 messages Oct 12, 2010

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

PATCH 1/1 drm/i915: new blitter ring support from Sandybridge

This adds new ring for blitter engine starting from Sandybridge.

Patch is against 2.6.36-rc kernel. As I haven't been able to find out all regressions on drm-intel-next yet, which made KMS totally fail on SNB now. I just base on current upstream tip, so I can see the testing result.

---
 drivers/gpu/drm/i915/i915_debugfs.c     |   10 ++
 drivers/gpu/drm/i915/i915_dma.c         |    5 +
 drivers/gpu/drm/i915/i915_drv.c         |    2 +
 drivers/gpu/drm/i915/i915_drv.h         |    5 +
 drivers/gpu/drm/i915/i915_gem.c         |   65 +++++++++++++--
 drivers/gpu/drm/i915/i915_gem_evict.c   |   85 +++++++++++++++++--
 drivers/gpu/drm/i915/i915_irq.c         |   26 +++++-
 drivers/gpu/drm/i915/i915_reg.h         |   11 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.c |  139 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h |    1 +
 include/drm/i915_drm.h                  |    2 +
 11 files changed, 333 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +10 -0
index 5e43d70..eb82af9 100644
@@ -43,6 +43,7 @@
 #define ACTIVE_LIST	1
 #define FLUSHING_LIST	2
 #define INACTIVE_LIST	3
+#define BLIT_LIST	4
 
 static const char *get_pin_flag(struct drm_i915_gem_object *obj_priv)
 {
@@ -80,6 +81,10 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
 		lock = &dev_priv->mm.active_list_lock;
 		head = &dev_priv->render_ring.active_list;
 		break;
+	case BLIT_LIST:
+		seq_printf(m, "BLIT:\n");
+		head = &dev_priv->blit_ring.active_list;
+		break;
 	case INACTIVE_LIST:
 		seq_printf(m, "Inactive:\n");
 		head = &dev_priv->mm.inactive_list;
@@ -242,6 +247,10 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
 			   I915_READ(GTIIR));
 		seq_printf(m, "Graphics Interrupt mask:		%08x\n",
 			   I915_READ(GTIMR));
+		if (HAS_BLIT_SPLIT(dev)) {
+			seq_printf(m, "Blitter Interrupt mask:		%08x\n",
+				   I915_READ(GEN6_BLITTER_IMR));
+		}
 	}
 	seq_printf(m, "Interrupts received: %d\n",
 		   atomic_read(&dev_priv->irq_received));
@@ -826,6 +835,7 @@ static struct drm_info_list i915_debugfs_list[] = {
 	{"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
 	{"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
 	{"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
+	{"i915_gem_blit_active", i915_gem_object_list_info, 0, (void *) BLIT_LIST},
 	{"i915_gem_pageflip", i915_gem_pageflip_info, 0},
 	{"i915_gem_request", i915_gem_request_info, 0},
 	{"i915_gem_seqno", i915_gem_seqno_info, 0},
drivers/gpu/drm/i915/i915_dma.c +5 -0
index c74e4e8..b060a35 100644
@@ -135,6 +135,8 @@ static int i915_dma_cleanup(struct drm_device * dev)
 	intel_cleanup_ring_buffer(dev, &dev_priv->render_ring);
 	if (HAS_BSD(dev))
 		intel_cleanup_ring_buffer(dev, &dev_priv->bsd_ring);
+	if (HAS_BLIT_SPLIT(dev))
+		intel_cleanup_ring_buffer(dev, &dev_priv->blit_ring);
 	mutex_unlock(&dev->struct_mutex);
 
 	/* Clear the HWS virtual address at teardown */
@@ -765,6 +767,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
 	case I915_PARAM_HAS_BSD:
 		value = HAS_BSD(dev);
 		break;
+	case I915_PARAM_HAS_BLIT_SPLIT:
+		value = HAS_BLIT_SPLIT(dev);
+		break;
 	default:
 		DRM_DEBUG_DRIVER("Unknown parameter %d\n",
 				 param->param);
drivers/gpu/drm/i915/i915_drv.c +2 -0
index 6dbe14c..0c08404 100644
@@ -136,11 +136,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_blit_split = 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_blit_split = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
drivers/gpu/drm/i915/i915_drv.h +5 -0
index af4a263..3a98bea 100644
@@ -212,6 +212,7 @@ struct intel_device_info {
 	u8 has_pipe_cxsr : 1;
 	u8 has_hotplug : 1;
 	u8 cursor_needs_physical : 1;
+	u8 has_blit_split : 1;
 };
 
 enum no_fbc_reason {
@@ -244,6 +245,7 @@ typedef struct drm_i915_private {
 	struct pci_dev *bridge_dev;
 	struct intel_ring_buffer render_ring;
 	struct intel_ring_buffer bsd_ring;
+	struct intel_ring_buffer blit_ring;
 	uint32_t next_seqno;
 
 	drm_dma_handle_t *status_page_dmah;
@@ -292,6 +294,7 @@ typedef struct drm_i915_private {
 	u32 flush_rings;
 #define FLUSH_RENDER_RING	0x1
 #define FLUSH_BSD_RING		0x2
+#define FLUSH_BLIT_RING		0x3
 
 	/* For hangcheck timer */
 #define DRM_I915_HANGCHECK_PERIOD 75 /* in jiffies */
@@ -1191,6 +1194,8 @@ extern void intel_overlay_print_error_state(struct seq_file *m, struct intel_ove
 #define HAS_BSD(dev)            (IS_IRONLAKE(dev) || IS_G4X(dev))
 #define I915_NEED_GFX_HWS(dev)	(INTEL_INFO(dev)->need_gfx_hws)
 
+#define HAS_BLIT_SPLIT(dev)	(INTEL_INFO(dev)->has_blit_split)
+
 /* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
  * rows, which changed the alignment requirements and fence programming.
  */
drivers/gpu/drm/i915/i915_gem.c +58 -7

168 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_evict.c +78 -7

126 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +23 -3
index 744225e..34be1b9 100644
@@ -312,6 +312,7 @@ 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;
+	struct intel_ring_buffer *blit_ring = &dev_priv->blit_ring;
 
 	/* disable master interrupt before clearing iir  */
 	de_ier = I915_READ(DEIER);
@@ -345,6 +346,15 @@ irqreturn_t ironlake_irq_handler(struct drm_device *dev)
 	if (gt_iir & GT_BSD_USER_INTERRUPT)
 		DRM_WAKEUP(&dev_priv->bsd_ring.irq_queue);
 
+	if (HAS_BLIT_SPLIT(dev) && (gt_iir & GT_BLIT_USER_INTERRUPT)) {
+		u32 seqno = blit_ring->get_gem_seqno(dev, blit_ring);
+		blit_ring->irq_gem_seqno = seqno;
+		trace_i915_gem_request_complete(dev, seqno);
+		DRM_WAKEUP(&dev_priv->blit_ring.irq_queue);
+		dev_priv->hangcheck_count = 0;
+		mod_timer(&dev_priv->hangcheck_timer,
+			  jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
+	}
 
 	if (de_iir & DE_GSE)
 		ironlake_opregion_gse_intr(dev);
@@ -1367,6 +1377,12 @@ void i915_hangcheck_elapsed(unsigned long data)
 			missed_wakeup = true;
 		}
 
+		if (HAS_BLIT_SPLIT(dev) && dev_priv->blit_ring.waiting_gem_seqno &&
+		    waitqueue_active(&dev_priv->blit_ring.irq_queue)) {
+			DRM_WAKEUP(&dev_priv->blit_ring.irq_queue);
+			missed_wakeup = true;
+		}
+
 		if (missed_wakeup)
 			DRM_ERROR("Hangcheck timer elapsed... GPU idle, missed IRQ.\n");
 		return;
@@ -1436,17 +1452,18 @@ 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_BLIT_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_BLITTER_IMR, ~GEN6_BLITTER_USER_INTERRUPT);
+	}
 	I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg);
 	(void) I915_READ(GTIER);
 
@@ -1510,6 +1527,9 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
 	if (HAS_BSD(dev))
 		DRM_INIT_WAITQUEUE(&dev_priv->bsd_ring.irq_queue);
 
+	if (HAS_BLIT_SPLIT(dev))
+		DRM_INIT_WAITQUEUE(&dev_priv->blit_ring.irq_queue);
+
 	dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
 
 	if (HAS_PCH_SPLIT(dev))
drivers/gpu/drm/i915/i915_reg.h +10 -1
index 4f5e155..209c15b 100644
@@ -192,6 +192,7 @@
 #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)
 #define MI_BATCH_BUFFER		MI_INSTR(0x30, 1)
 #define   MI_BATCH_NON_SECURE	(1)
 #define   MI_BATCH_NON_SECURE_I965 (1<<8)
@@ -476,6 +477,14 @@
 #define BSD_RING_ACTHD         0x04074
 #define BSD_HWS_PGA            0x04080
 
+/* Blit ring */
+#define BLIT_RING_TAIL          0x22030
+#define BLIT_RING_HEAD          0x22034
+#define BLIT_RING_START         0x22038
+#define BLIT_RING_CTL           0x2203c
+#define BLIT_RING_ACTHD         0x22074
+#define BLIT_HWS_PGA            0x24080
+
 /*
  * Framebuffer compression (915+ only)
  */
@@ -2516,7 +2525,7 @@
 #define GT_SYNC_STATUS          (1 << 2)
 #define GT_USER_INTERRUPT       (1 << 0)
 #define GT_BSD_USER_INTERRUPT   (1 << 5)
-
+#define GT_BLIT_USER_INTERRUPT	(1 << 22)
 
 #define GTISR   0x44010
 #define GTIMR   0x44014
drivers/gpu/drm/i915/intel_ringbuffer.c +139 -0

148 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 525e7d3..d6d8a7b 100644
@@ -127,5 +127,6 @@ u32 intel_ring_get_seqno(struct drm_device *dev,
 
 extern struct intel_ring_buffer render_ring;
 extern struct intel_ring_buffer bsd_ring;
+extern struct intel_ring_buffer blit_ring;
 
 #endif /* _INTEL_RINGBUFFER_H_ */
include/drm/i915_drm.h +2 -0
index e41c74f..087879d 100644
@@ -286,6 +286,7 @@ typedef struct drm_i915_irq_wait {
 #define I915_PARAM_HAS_PAGEFLIPPING	 8
 #define I915_PARAM_HAS_EXECBUF2          9
 #define I915_PARAM_HAS_BSD		 10
+#define I915_PARAM_HAS_BLIT_SPLIT	 11
 
 typedef struct drm_i915_getparam {
 	int param;
@@ -629,6 +630,7 @@ struct drm_i915_gem_execbuffer2 {
 	__u64 cliprects_ptr;
 #define I915_EXEC_RENDER                 (1<<0)
 #define I915_EXEC_BSD                    (1<<1)
+#define I915_EXEC_BLIT                   (1<<2)
 	__u64 flags;
 	__u64 rsvd1;
 	__u64 rsvd2;
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 intel: new blitter ring support from Sandybridge

---
 include/drm/i915_drm.h   |    2 ++
 intel/intel_bufmgr_gem.c |   12 +++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
include/drm/i915_drm.h +2 -0
index 7594413..694fb24 100644
@@ -276,6 +276,7 @@ typedef struct drm_i915_irq_wait {
 #define I915_PARAM_HAS_PAGEFLIPPING	 8
 #define I915_PARAM_HAS_EXECBUF2          9
 #define I915_PARAM_HAS_BSD		 10
+#define I915_PARAM_HAS_BLIT_SPLIT	 11
 
 typedef struct drm_i915_getparam {
 	int param;
@@ -619,6 +620,7 @@ struct drm_i915_gem_execbuffer2 {
 	__u64 cliprects_ptr;
 #define I915_EXEC_RENDER                 (1<<0)
 #define I915_EXEC_BSD                    (1<<1)
+#define I915_EXEC_BLIT                   (1<<2)
 	__u64 flags;
 	__u64 rsvd1;
 	__u64 rsvd2;
intel/intel_bufmgr_gem.c +9 -3
index 60174e1..57229e9 100644
@@ -1545,7 +1545,8 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
 	struct drm_i915_gem_execbuffer2 execbuf;
 	int ret, i;
 
-	if ((ring_flag != I915_EXEC_RENDER) && (ring_flag != I915_EXEC_BSD))
+	if ((ring_flag != I915_EXEC_RENDER) && (ring_flag != I915_EXEC_BSD) &&
+	    (ring_flag != I915_EXEC_BLIT))
 		return -EINVAL;
 
 	pthread_mutex_lock(&bufmgr_gem->lock);
@@ -2054,7 +2055,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
 	struct drm_i915_gem_get_aperture aperture;
 	drm_i915_getparam_t gp;
 	int ret;
-	int exec2 = 0, has_bsd = 0;
+	int exec2 = 0, has_bsd = 0, blit_split = 0;
 
 	bufmgr_gem = calloc(1, sizeof(*bufmgr_gem));
 	if (bufmgr_gem == NULL)
@@ -2110,6 +2111,11 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
 	if (!ret)
 		has_bsd = 1;
 
+	gp.param = I915_PARAM_HAS_BLIT_SPLIT;
+	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	if (!ret)
+		blit_split = *gp.value;
+
 	if (bufmgr_gem->gen < 4) {
 		gp.param = I915_PARAM_NUM_FENCES_AVAIL;
 		gp.value = &bufmgr_gem->available_fences;
@@ -2165,7 +2171,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
 	/* Use the new one if available */
 	if (exec2) {
 		bufmgr_gem->bufmgr.bo_exec = drm_intel_gem_bo_exec2;
-		if (has_bsd)
+		if (has_bsd || blit_split)
 			bufmgr_gem->bufmgr.bo_mrb_exec = drm_intel_gem_bo_mrb_exec2;
 	} else
 		bufmgr_gem->bufmgr.bo_exec = drm_intel_gem_bo_exec;
Signature · 1 line
1.7.0.4
#2 lore raw
In reply to Zhenyu Wang
Quoted 1 line · Zhenyu Wang

This adds new ring for blitter engine starting from Sandybridge.

Thanks, look fairly straightforward. The messy parts are a clear reminder that I intended to clean up some areas for multiple rings.

* bikeshedding

s/HAS_BLIT_SPLIT/HAS_BLT/ -- the documentation has ingrained BLT engine into my head (and I hope they haven't changed on a whim for snb)

After initialisation we should not need to care about HAS_BSD/HAS_BLT and just test whether the ring is initialised or active (depending upon op). That should dramatically reduce the number of tests in our code and hopefully lead to further simplifications.

Unified request list (along with per-ring lists) will sort out the mess in i915_gem_evict and also solve the wrap-around issue.

So no get/put irq again?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw
Quoted 10 lines · Chris Wilson
Quoted 1 line · Zhenyu Wang

This adds new ring for blitter engine starting from Sandybridge.

Thanks, look fairly straightforward. The messy parts are a clear reminder that I intended to clean up some areas for multiple rings.

* bikeshedding

s/HAS_BLIT_SPLIT/HAS_BLT/ -- the documentation has ingrained BLT engine into my head (and I hope they haven't changed on a whim for snb)

ok, BLT looks better.

Quoted 10 lines

After initialisation we should not need to care about HAS_BSD/HAS_BLT and just test whether the ring is initialised or active (depending upon op). That should dramatically reduce the number of tests in our code and hopefully lead to further simplifications.

Unified request list (along with per-ring lists) will sort out the mess in i915_gem_evict and also solve the wrap-around issue.

So no get/put irq again?

yeah, current still uses user_interrupt, that has been unmasked and enabled from beginning. I just did some copy&paste, it could be fixed to our original behavior by mask initially and unmask as required, which might involve irq enable/disable sequence specific on different hw though.

Signature · 3 lines
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

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