Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915:  SNB BLT workaround
@ 2010-11-02  8:31 Zou Nan hai
  2010-11-02  9:04 ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Zou Nan hai @ 2010-11-02  8:31 UTC (permalink / raw)
  To: intel-gfx, Chris Wilson

	on some stepping of SNB cpu, the first command to be parsed in BLT
	command streamer should be MI_BATCHBUFFER_START
	otherwise the GPU may hang.

Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c |   89 +++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 09f2dc3..4070f32 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -854,15 +854,98 @@ blt_ring_put_user_irq(struct drm_device *dev,
 	/* do nothing */
 }
 
+
+/* workaround for some stepping of SNB,
+   each time when BLT engine ring tail moved,
+   the first command in the ring to be parsed
+   should be MI_BATCH_BUFFER_START
+ */
+static struct drm_gem_object *wa_batch;
+static unsigned long wa_batch_addr;
+
+#define NEED_BLT_WORKAROUND(dev) \
+	(IS_GEN6(dev) && (dev->pdev->revision < 8))
+
+static int blt_ring_init(struct drm_device *dev,
+			 struct intel_ring_buffer *ring)
+{
+	u32 *ptr;
+	struct drm_i915_gem_object *batch;
+	if (NEED_BLT_WORKAROUND(dev) && wa_batch == NULL) {
+		wa_batch = i915_gem_alloc_object(dev, 4096);
+
+		i915_gem_object_pin(wa_batch, 4096);
+
+		batch = to_intel_bo(wa_batch);
+		wa_batch_addr = batch->gtt_offset;
+
+		ptr = kmap(batch->pages[0]);
+		memset((u8 *)ptr, 0, 4096);
+		*ptr = MI_BATCH_BUFFER_END;
+		kunmap(batch->pages[0]);
+	}
+	return init_ring_common(dev, ring);
+}
+
+static void blt_ring_flush(struct drm_device *dev,
+			    struct intel_ring_buffer *ring,
+			    u32 invalidate_domains,
+			    u32 flush_domains)
+{
+	if (NEED_BLT_WORKAROUND(dev)) {
+		intel_ring_begin(dev, ring, 6);
+		intel_ring_emit(dev, ring, MI_BATCH_BUFFER_START);
+		intel_ring_emit(dev, ring, wa_batch_addr);
+	} else
+		intel_ring_begin(dev, ring, 4);
+
+	intel_ring_emit(dev, ring, MI_FLUSH_DW);
+	intel_ring_emit(dev, ring, 0);
+	intel_ring_emit(dev, ring, 0);
+	intel_ring_emit(dev, ring, 0);
+
+	intel_ring_advance(dev, ring);
+}
+
+static u32
+blt_ring_add_request(struct drm_device *dev,
+		     struct intel_ring_buffer *ring,
+		     u32 flush_domains)
+{
+	u32 seqno;
+
+	seqno = i915_gem_get_seqno(dev);
+
+	if (NEED_BLT_WORKAROUND(dev)) {
+		intel_ring_begin(dev, ring, 6);
+		intel_ring_emit(dev, ring, MI_BATCH_BUFFER_START);
+		intel_ring_emit(dev, ring, wa_batch_addr);
+	} else {
+		intel_ring_begin(dev, ring, 4);
+	}
+
+	intel_ring_emit(dev, ring, MI_STORE_DWORD_INDEX);
+	intel_ring_emit(dev, ring,
+			I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
+	intel_ring_emit(dev, ring, seqno);
+	intel_ring_emit(dev, ring, MI_USER_INTERRUPT);
+
+	intel_ring_advance(dev, ring);
+
+	DRM_DEBUG_DRIVER("%s %d\n", ring->name, seqno);
+
+	return seqno;
+}
+
 static const struct intel_ring_buffer gen6_blt_ring = {
        .name			= "blt ring",
        .id			= RING_BLT,
        .mmio_base		= BLT_RING_BASE,
        .size			= 32 * PAGE_SIZE,
-       .init			= init_ring_common,
+       .init			= blt_ring_init,
        .write_tail		= ring_write_tail,
-       .flush			= gen6_ring_flush,
-       .add_request		= ring_add_request,
+       .flush			= blt_ring_flush,
+       .add_request		= blt_ring_add_request,
        .get_seqno		= ring_status_page_get_seqno,
        .user_irq_get		= blt_ring_get_user_irq,
        .user_irq_put		= blt_ring_put_user_irq,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915:  SNB BLT workaround
  2010-11-02  8:31 [PATCH] drm/i915: SNB BLT workaround Zou Nan hai
@ 2010-11-02  9:04 ` Chris Wilson
  2010-11-02  9:08   ` Zou, Nanhai
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2010-11-02  9:04 UTC (permalink / raw)
  To: Zou Nan hai, intel-gfx

On Tue,  2 Nov 2010 16:31:01 +0800, Zou Nan hai <nanhai.zou@intel.com> wrote:
> 	on some stepping of SNB cpu, the first command to be parsed in BLT
> 	command streamer should be MI_BATCHBUFFER_START
> 	otherwise the GPU may hang.

Then just add the workaround to the init routine.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915:  SNB BLT workaround
  2010-11-02  9:04 ` Chris Wilson
@ 2010-11-02  9:08   ` Zou, Nanhai
  2010-11-02 10:43     ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Zou, Nanhai @ 2010-11-02  9:08 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx@lists.freedesktop.org

>>-----Original Message-----
>>From: Chris Wilson [mailto:chris@chris-wilson.co.uk]
>>Sent: 2010年11月2日 17:05
>>To: Zou, Nanhai; intel-gfx@lists.freedesktop.org
>>Cc: Zou, Nanhai
>>Subject: Re: [PATCH] drm/i915: SNB BLT workaround
>>
>>On Tue,  2 Nov 2010 16:31:01 +0800, Zou Nan hai <nanhai.zou@intel.com> wrote:
>>> 	on some stepping of SNB cpu, the first command to be parsed in BLT
>>> 	command streamer should be MI_BATCHBUFFER_START
>>> 	otherwise the GPU may hang.
>>
>>Then just add the workaround to the init routine.
>>-Chris
>>

The first command here means each BLT command streamer 
begin the parse action, when the ring tail is moving ahead.

Thanks
Zou Nan hai
>>--
>>Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915:  SNB BLT workaround
  2010-11-02  9:08   ` Zou, Nanhai
@ 2010-11-02 10:43     ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2010-11-02 10:43 UTC (permalink / raw)
  To: Zou, Nanhai, intel-gfx@lists.freedesktop.org

[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]

On Tue, 2 Nov 2010 17:08:09 +0800, "Zou, Nanhai" <nanhai.zou@intel.com> wrote:
> >>-----Original Message-----
> >>From: Chris Wilson [mailto:chris@chris-wilson.co.uk]
> >>Sent: 2010年11月2日 17:05
> >>To: Zou, Nanhai; intel-gfx@lists.freedesktop.org
> >>Cc: Zou, Nanhai
> >>Subject: Re: [PATCH] drm/i915: SNB BLT workaround
> >>
> >>On Tue,  2 Nov 2010 16:31:01 +0800, Zou Nan hai <nanhai.zou@intel.com> wrote:
> >>> 	on some stepping of SNB cpu, the first command to be parsed in BLT
> >>> 	command streamer should be MI_BATCHBUFFER_START
> >>> 	otherwise the GPU may hang.
> >>
> >>Then just add the workaround to the init routine.
> >>-Chris
> >>
> 
> The first command here means each BLT command streamer 
> begin the parse action, when the ring tail is moving ahead.

Okay, that makes more sense. :)

I added some error checking, then realised that no error checking was done
in 2.6.36 and swore.

Applied to -next and -fixes, with a tag for stable since I presume that
some of these chips were sent to vendors for validation.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-02 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-02  8:31 [PATCH] drm/i915: SNB BLT workaround Zou Nan hai
2010-11-02  9:04 ` Chris Wilson
2010-11-02  9:08   ` Zou, Nanhai
2010-11-02 10:43     ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox