Skip to contentSkip to conversation

drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

PATCH In review Zhao Yakui 3 participants 9 messages Jun 22, 2018

Subsystems (2)
lore
Share & tools
lore

Zhao Yakui

author
#0 lore raw

PATCH v2 1/1 drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Under execlists mode the context buffer is allocated in global Gtt region. The I915_MAP_WB type is used to map the buffer so that the driver can initialize the context buffer.(Ring reg, Context Ctrl reg and so on). And then __context_pin is called to flush back corresponding contents. In fact as it also tries to update context buffer (Ring Tail offset) before writing the ELSP port, it has no explicit cache flsuh.Maybe it is handled by HW. But this is quite confusing as BXT has no LLC. So the WC is used to map the context buffer on the platform without LLC and the update of context buffer is writen into phys page directly. It will be safer.

V1->V2: Remove the dirty flag of execlists state buffer and one minor typo in commit log

---
 drivers/gpu/drm/i915/intel_lrc.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +7 -6
index 10deebe..5ffd76e 100644
@@ -1386,6 +1386,7 @@ __execlists_context_pin(struct intel_engine_cs *engine,
 {
 	void *vaddr;
 	int ret;
+	enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB : I915_MAP_WC;
 
 	ret = execlists_context_deferred_alloc(ctx, engine, ce);
 	if (ret)
@@ -1396,7 +1397,7 @@ __execlists_context_pin(struct intel_engine_cs *engine,
 	if (ret)
 		goto err;
 
-	vaddr = i915_gem_object_pin_map(ce->state->obj, I915_MAP_WB);
+	vaddr = i915_gem_object_pin_map(ce->state->obj, map);
 	if (IS_ERR(vaddr)) {
 		ret = PTR_ERR(vaddr);
 		goto unpin_vma;
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context *ctx,
 		    struct intel_engine_cs *engine,
 		    struct intel_ring *ring)
 {
+	enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB : I915_MAP_WC;
 	void *vaddr;
 	u32 *regs;
 	int ret;
@@ -2738,13 +2740,12 @@ populate_lr_context(struct i915_gem_context *ctx,
 		return ret;
 	}
 
-	vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+	vaddr = i915_gem_object_pin_map(ctx_obj, map);
 	if (IS_ERR(vaddr)) {
 		ret = PTR_ERR(vaddr);
 		DRM_DEBUG_DRIVER("Could not map object pages! (%d)\n", ret);
 		return ret;
 	}
-	ctx_obj->mm.dirty = true;
 
 	if (engine->default_state) {
 		/*
@@ -2756,7 +2757,7 @@ populate_lr_context(struct i915_gem_context *ctx,
 		void *defaults;
 
 		defaults = i915_gem_object_pin_map(engine->default_state,
-						   I915_MAP_WB);
+						   map);
 		if (IS_ERR(defaults)) {
 			ret = PTR_ERR(defaults);
 			goto err_unpin_ctx;
@@ -2851,6 +2852,7 @@ void intel_lr_context_resume(struct drm_i915_private *dev_priv)
 	struct intel_engine_cs *engine;
 	struct i915_gem_context *ctx;
 	enum intel_engine_id id;
+	enum i915_map_type map = HAS_LLC(dev_priv) ? I915_MAP_WB : I915_MAP_WC;
 
 	/* Because we emit WA_TAIL_DWORDS there may be a disparity
 	 * between our bookkeeping in ce->ring->head and ce->ring->tail and
@@ -2872,7 +2874,7 @@ void intel_lr_context_resume(struct drm_i915_private *dev_priv)
 				continue;
 
 			reg = i915_gem_object_pin_map(ce->state->obj,
-						      I915_MAP_WB);
+						      map);
 			if (WARN_ON(IS_ERR(reg)))
 				continue;
 
@@ -2880,7 +2882,6 @@ void intel_lr_context_resume(struct drm_i915_private *dev_priv)
 			reg[CTX_RING_HEAD+1] = 0;
 			reg[CTX_RING_TAIL+1] = 0;
 
-			ce->state->obj->mm.dirty = true;
 			i915_gem_object_unpin_map(ce->state->obj);
 
 			intel_ring_reset(ce->ring, 0);
Signature · 6 lines
2.7.4

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

Quoting Zhao Yakui (2018-06-22 07:09:10)

Quoted 11 lines

Under execlists mode the context buffer is allocated in global Gtt region. The I915_MAP_WB type is used to map the buffer so that the driver can initialize the context buffer.(Ring reg, Context Ctrl reg and so on). And then __context_pin is called to flush back corresponding contents. In fact as it also tries to update context buffer (Ring Tail offset) before writing the ELSP port, it has no explicit cache flsuh.Maybe it is handled by HW. But this is quite confusing as BXT has no LLC. So the WC is used to map the context buffer on the platform without LLC and the update of context buffer is writen into phys page directly. It will be safer.

Quoted 2 lines

V1->V2: Remove the dirty flag of execlists state buffer and one minor typo in commit log

The object's pages are still dirty, so why? It's not about CPU cache dirt, here it is about whether the pages differ from any potential swapcache.

I was anticipating there would be some type conflict with engine->pinned_default_state, but that just happens to work out correctly... so long as there is always a retirement during load and we park before any reset. Hmm.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
Quoted 22 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 2:26 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Cc: Zhao, Yakui <[email protected]>
Subject: Re: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoting Zhao Yakui (2018-06-22 07:09:10)

Quoted 11 lines

Under execlists mode the context buffer is allocated in global Gtt region. The I915_MAP_WB type is used to map the buffer so that the driver can initialize the context buffer.(Ring reg, Context Ctrl reg and so on). And then __context_pin is called to flush back corresponding contents. In fact as it also tries to update context buffer (Ring Tail offset) before writing the ELSP port, it has no explicit cache flsuh.Maybe it is handled by HW. But this is quite confusing as BXT has no LLC. So the WC is used to map the context buffer on the platform without LLC and the update of context buffer is writen into phys page directly. It will be safer.

Quoted 6 lines
Quoted 2 lines

V1->V2: Remove the dirty flag of execlists state buffer and one minor typo in commit log

The object's pages are still dirty, so why? It's not about CPU cache dirt, here it is about whether the pages differ from any potential swapcache.

Based on the test it seems that this patch still has some problems. More works are needed in order to change the MAP type. Maybe this buffer should be handled like intel_ring biffer.
I will check it later.

Quoted 5 lines

I was anticipating there would be some type conflict with engine->pinned_default_state, but that just happens to work out correctly... so long as there is always a retirement during load and we park before any reset. Hmm.
-Chris

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

#3 lore raw

✗ Fi.CI.BAT: failure for drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC (rev2)

In reply to Zhao Yakui
== Series Details ==

== Series Details ==

Series: drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC (rev2)
URL : https://patchwork.freedesktop.org/series/45213/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4368 -> Patchwork_9393 =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_9393 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9393, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/45213/revisions/2/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9393:

=== IGT changes ===

    ==== Possible regressions ====

    igt@gem_close_race@basic-threads:
      fi-bsw-n3050:       PASS -> INCOMPLETE

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-kbl-7560u:       PASS -> INCOMPLETE

== Known issues ==

Here are the changes found in Patchwork_9393 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_close_race@basic-threads:
      fi-glk-j4005:       PASS -> INCOMPLETE (fdo#103359, k.org#198133)
      fi-bxt-j4205:       PASS -> INCOMPLETE (fdo#103927)
      fi-bxt-dsi:         PASS -> INCOMPLETE (fdo#103927)

    igt@gem_exec_gttfill@basic:
      fi-byt-n2820:       PASS -> FAIL (fdo#106744)

fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#106744 https://bugs.freedesktop.org/show_bug.cgi?id=106744
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133

== Participating hosts (43 -> 37) ==

Missing (6): fi-ilk-m540 fi-hsw-4200u fi-glk-dsi fi-bsw-cyan fi-ctg-p8600 fi-kbl-x1275

== Build changes ==

* Linux: CI_DRM_4368 -> Patchwork_9393

CI_DRM_4368: f9f621dc095a8bfd2157fba018ddb542260d8daa @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4528: 6be300d405de5974b262e8b93a445be4ac618e6a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9393: 292099bbc3f1594c5ab092e1667266474262d161 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

292099bbc3f1 drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9393/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Zhao Yakui

Quoting Zhao Yakui (2018-06-22 07:09:10)

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context *ctx,
                    struct intel_engine_cs *engine,
                    struct intel_ring *ring)
 {
+       enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB : I915_MAP_WC;
        void *vaddr;
        u32 *regs;
        int ret;

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct i915_gem_context *ctx, · line 2743

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -2738,13 +2740,12 @@ populate_lr_context(struct i915_gem_context *ctx,
                return ret;
        }
 
-       vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+       vaddr = i915_gem_object_pin_map(ctx_obj, map);

As this uses the cpu domain and flushed afterwards, this one is correct in its usage of MAP_WB.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 21 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 2:36 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Cc: Zhao, Yakui <[email protected]>
Subject: Re: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoting Zhao Yakui (2018-06-22 07:09:10)

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct i915_gem_context

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context *ctx,
                    struct intel_engine_cs *engine,
                    struct intel_ring *ring)  {
+       enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB :
+ I915_MAP_WC;
        void *vaddr;
        u32 *regs;
        int ret;
@@ -2738,13 +2740,12 @@ populate_lr_context(struct i915_gem_context

*ctx,

Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct i915_gem_context *ctx, · line 2743

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
                return ret;
        }
 
-       vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+       vaddr = i915_gem_object_pin_map(ctx_obj, map);

As this uses the cpu domain and flushed afterwards, this one is correct in its usage of MAP_WB.

In this function the content of context state is flushed.

But the function of execlists_submit_ports will update it again before writing the ELSP port. And there is no flush. In fact after the ELSP port is written, the HW will start to execute the submitted commands.

Quoted 1 line

-Chris

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

#6 lore raw

Quoting Zhao, Yakui (2018-06-22 08:29:15)

Quoted 27 lines
Quoted 27 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 2:36 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Cc: Zhao, Yakui <[email protected]>
Subject: Re: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoting Zhao Yakui (2018-06-22 07:09:10)

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct i915_gem_context

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context *ctx,
                    struct intel_engine_cs *engine,
                    struct intel_ring *ring)  {
+       enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB :
+ I915_MAP_WC;
        void *vaddr;
        u32 *regs;
        int ret;
@@ -2738,13 +2740,12 @@ populate_lr_context(struct i915_gem_context

*ctx,

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
                return ret;
        }
 
-       vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+       vaddr = i915_gem_object_pin_map(ctx_obj, map);
Quoted 7 lines
Quoted 2 lines

As this uses the cpu domain and flushed afterwards, this one is correct in its usage of MAP_WB.

In this function the content of context state is flushed.

But the function of execlists_submit_ports will update it again before writing the ELSP port. And there is no flush. In fact after the ELSP port is written, the HW will start to execute the submitted commands.

That's a different map.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 43 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 3:37 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Subject: RE: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoting Zhao, Yakui (2018-06-22 08:29:15)

Quoted 11 lines
Quoted 11 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 2:36 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Cc: Zhao, Yakui <[email protected]>
Subject: Re: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoted 2 lines
Quoted 2 lines

Quoting Zhao Yakui (2018-06-22 07:09:10)

Review populate_lr_context(struct i915_gem_context

Quoted 1 line
(quoted diff) +0 -0
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context

*ctx,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
                    struct intel_engine_cs *engine,
                    struct intel_ring *ring)  {
+       enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB :
+ I915_MAP_WC;
        void *vaddr;
        u32 *regs;
        int ret;
@@ -2738,13 +2740,12 @@ populate_lr_context(struct

i915_gem_context

Quoted 10 lines
Quoted 9 lines

*ctx,

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct i915_gem_context *ctx, · line 2743

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
                return ret;
        }
 
-       vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+       vaddr = i915_gem_object_pin_map(ctx_obj, map);

As this uses the cpu domain and flushed afterwards, this one is correct in its usage of MAP_WB.

Quoted 8 lines
Quoted 3 lines

In this function the content of context state is flushed.

But the function of execlists_submit_ports will update it again before writing

the ELSP port.

Quoted 1 line

And there is no flush. In fact after the ELSP port is written, the HW will start

to execute the submitted commands.

That's a different map.

Really? It is allocated in one gem obj.

Will you please help to point out where to handle the different map?

Thanks
Yakui

Quoted 1 line

-Chris

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

#8 lore raw

Quoting Zhao, Yakui (2018-06-22 09:06:27)

Quoted 47 lines
Quoted 47 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 3:37 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Subject: RE: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoting Zhao, Yakui (2018-06-22 08:29:15)

Quoted 11 lines
Quoted 11 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, June 22, 2018 2:36 PM
To: Zhao, Yakui <[email protected]>; [email protected]
Cc: Zhao, Yakui <[email protected]>
Subject: Re: [PATCH V2] drm/i915: Use I915_MAP_WC for execlists context buffer on the platforms without LLC

Quoted 2 lines
Quoted 2 lines

Quoting Zhao Yakui (2018-06-22 07:09:10)

Review populate_lr_context(struct i915_gem_context

Quoted 1 line
(quoted diff) +0 -0
@@ -2728,6 +2729,7 @@ populate_lr_context(struct i915_gem_context

*ctx,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c populate_lr_context(struct

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
                    struct intel_engine_cs *engine,
                    struct intel_ring *ring)  {
+       enum i915_map_type map = HAS_LLC(ctx->i915) ? I915_MAP_WB :
+ I915_MAP_WC;
        void *vaddr;
        u32 *regs;
        int ret;
@@ -2738,13 +2740,12 @@ populate_lr_context(struct

i915_gem_context

Quoted 7 lines
Quoted 7 lines

*ctx,

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
                return ret;
        }
 
-       vaddr = i915_gem_object_pin_map(ctx_obj, I915_MAP_WB);
+       vaddr = i915_gem_object_pin_map(ctx_obj, map);
Quoted 6 lines
Quoted 2 lines

As this uses the cpu domain and flushed afterwards, this one is correct in its usage of MAP_WB.

In this function the content of context state is flushed.

But the function of execlists_submit_ports will update it again before writing

the ELSP port.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

And there is no flush. In fact after the ELSP port is written, the HW will start

to execute the submitted commands.

That's a different map.

Really? It is allocated in one gem obj.

Will you please help to point out where to handle the different map?

It is reallocated on demand. The map used to prepopulate the context image is not the same map used to update the ring registers in flight. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx