drm/i915: Only grab correct forcewake for the engine with execlists
Subsystems (2)
PATCH 1/1 drm/i915: Only grab correct forcewake for the engine with execlists
From: Tvrtko Ursulin <[email protected]>
Rather than blindly waking up all forcewake domains on command submission, we can teach each engine what is (or are) the correct one to take.
On platforms with multiple forcewake domains like VLV, CHV, SKL and BXT, this has the potential of lowering the GPU and CPU power use and submission latency.
To implement it, we extract the code which holds the built in knowledge on which forcewake domains are applicable for each registers from the MMIO accessors into separate macros, and implement two new functions named intel_reg_read_fw_domains and intel_reg_read_fw_domains.
These enables callers, in this case the execlists engine setup code, to query which forcewake domains are relevant per engine on the currently running platform.
--- drivers/gpu/drm/i915/i915_drv.h | 6 + drivers/gpu/drm/i915/intel_lrc.c | 18 +- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + drivers/gpu/drm/i915/intel_uncore.c | 306 +++++++++++++++++++++----------- 4 files changed, 226 insertions(+), 105 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +6 -0
@@ -633,6 +633,12 @@ enum forcewake_domains { FORCEWAKE_MEDIA) }; +enum forcewake_domains +intel_reg_read_fw_domains (struct drm_i915_private *dev_priv,i915_reg_t reg); + +enum forcewake_domains +intel_reg_write_fw_domains (struct drm_i915_private *dev_priv,i915_reg_t reg); +struct intel_uncore_funcs {void (*force_wake_get)(struct drm_i915_private *dev_priv,enum forcewake_domains domains);
drivers/gpu/drm/i915/intel_lrc.c +13 -5
@@ -418,6 +418,7 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0, struct drm_i915_gem_request *rq1) {struct drm_i915_private *dev_priv = rq0->i915; +unsigned int fw_domains = rq0->engine->fw_domains_elsp;execlists_update_context (rq0);
@@ -425,11 +426,11 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0,execlists_update_context (rq1);spin_lock_irq (&dev_priv->uncore.lock); -intel_uncore_forcewake_get__locked (dev_priv,FORCEWAKE_ALL ); +intel_uncore_forcewake_get__locked (dev_priv, fw_domains);execlists_elsp_write (rq0, rq1); -intel_uncore_forcewake_put__locked (dev_priv,FORCEWAKE_ALL ); +intel_uncore_forcewake_put__locked (dev_priv, fw_domains);spin_unlock_irq (&dev_priv->uncore.lock); }
@@ -552,7 +553,7 @@ static void intel_lrc_irq_handler(unsigned long data)unsigned int csb_read =0 , i;unsigned int submit_contexts =0 ; -intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); +intel_uncore_forcewake_get (dev_priv, engine->fw_domains_csb); status_pointer =I915_READ_FW (RING_CONTEXT_STATUS_PTR (engine));
@@ -577,7 +578,7 @@ static void intel_lrc_irq_handler(unsigned long data)_MASKED_FIELD (GEN8_CSB_READ_PTR_MASK , engine->next_context_status_buffer << 8)); -intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL ); +intel_uncore_forcewake_put (dev_priv, engine->fw_domains_csb);spin_lock (&engine->execlist_lock);
@@ -2077,7 +2078,8 @@ logical_ring_default_irqs(struct intel_engine_cs *engine, unsigned shift)static int logical_ring_init (struct drm_device *dev,struct intel_engine_cs *engine) { -struct intel_context *dctx =to_i915 (dev)->kernel_context; +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_context *dctx = dev_priv->kernel_context;int ret;/* Intentionally left blank. */
@@ -2099,6 +2101,12 @@ logical_ring_init(struct drm_device *dev, struct intel_engine_cs *engine)logical_ring_init_platform_invariants (engine); + engine->fw_domains_elsp = +intel_reg_write_fw_domains (dev_priv,RING_ELSP (engine)); + engine->fw_domains_csb = +intel_reg_write_fw_domains (dev_priv, +RING_CONTEXT_STATUS_PTR (engine)); + ret =i915_cmd_parser_init_ring (engine);if (ret) goto error;
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -270,6 +270,7 @@ struct intel_engine_cs {spinlock_t execlist_lock;/* used inside tasklet, use spin_lock_bh */ struct list_head execlist_queue;struct list_head execlist_retired_req_list; +unsigned int fw_domains_elsp, fw_domains_csb;unsigned int next_context_status_buffer;unsigned int idle_lite_restore_wa;bool disable_lite_restore_wa;
drivers/gpu/drm/i915/intel_uncore.c +206 -100
394 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 51 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Rather than blindly waking up all forcewake domains on command submission, we can teach each engine what is (or are) the correct one to take.
On platforms with multiple forcewake domains like VLV, CHV, SKL and BXT, this has the potential of lowering the GPU and CPU power use and submission latency.
To implement it, we extract the code which holds the built in knowledge on which forcewake domains are applicable for each registers from the MMIO accessors into separate macros, and implement two new functions named
intel_reg_read_fw_domainsandintel_reg_read_fw_domains.These enables callers, in this case the execlists engine setup code, to query which forcewake domains are relevant per engine on the currently running platform.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 6 + drivers/gpu/drm/i915/intel_lrc.c | 18 +- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + drivers/gpu/drm/i915/intel_uncore.c | 306 +++++++++++++++++++++----------- 4 files changed, 226 insertions(+), 105 deletions(-)drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -633,6 +633,12 @@ enum forcewake_domains { FORCEWAKE_MEDIA) }; +enum forcewake_domains +intel_reg_read_fw_domains (struct drm_i915_private *dev_priv,i915_reg_t reg); + +enum forcewake_domains +intel_reg_write_fw_domains (struct drm_i915_private *dev_priv,i915_reg_t reg); +struct intel_uncore_funcs {void (*force_wake_get)(struct drm_i915_private *dev_priv,enum forcewake_domains domains);drivers/gpu/drm/i915/intel_lrc.c +0
-0
drivers/gpu/drm/i915/intel_lrc.c static void execlists_submit_requests(struct drm_i915_gem_request *rq0, · line 421
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1
-0@@ -418,6 +418,7 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0, struct drm_i915_gem_request *rq1) {struct drm_i915_private *dev_priv = rq0->i915; +unsigned int fw_domains = rq0->engine->fw_domains_elsp;
So I was thinking this was overly specific and that no hw engineer would ever split the block of ring registers into separate power domains, and then I realised they already had with the shadow_regs.
The only other place where we could make semantic use of this is in intel_ringbuffer.c:init_ring_common. We don't make use of the block fw put/get anywhere else - the only other candidate I can think of right now would be gen6 bsd legacy tail writes. That is a block of register writes were marking the intent to stay awake through the entire sequence would be worth it.
drivers/gpu/drm/i915/intel_lrc.c static void execlists_submit_requests(struct drm_i915_gem_request *rq0,
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +9
-0+#define __gen6_reg_read_fw_domains (offset) \ +({ \ + enum forcewake_domains __fwd; \ + if (NEEDS_FORCE_WAKE(offset)) \ + __fwd = FORCEWAKE_RENDER; \ + else \ + __fwd = 0; \ + __fwd; \ +})
[snip]
This split out looks right, but it is probably worth doing as a seperate step and checking for changes in objdump. Just to be paranoid that we didn't make an unexpected modification.
Quoted 12 lines
drivers/gpu/drm/i915/intel_lrc.c +12
-0+enum forcewake_domains +intel_reg_read_fw_domains (struct drm_i915_private *dev_priv,i915_reg_t reg) +{ +if (intel_vgpu_active (dev_priv->dev)) +return 0 ; + +switch (INTEL_INFO (dev_priv)->gen) { +case 9 : +return __gen9_reg_read_fw_domains (i915_mmio_reg_offset (reg)); +case 8 : +if (IS_CHERRYVIEW (dev_priv)) +return __chv_reg_read_fw_domains (i915_mmio_reg_offset (reg));
drivers/gpu/drm/i915/intel_lrc.c
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10
-0+else +return __gen6_reg_read_fw_domains (i915_mmio_reg_offset (reg)); +case 7 : +case 6 : +if (IS_VALLEYVIEW (dev_priv)) +return __vlv_reg_read_fw_domains (i915_mmio_reg_offset (reg)); +else +return __gen6_reg_read_fw_domains (i915_mmio_reg_offset (reg)); +default : +/* It is a bug to think about forcewake on older platforms. */
Yes, but we might as well report them correctly as 0 and not throw a warning. You are calling this an intel_() function, and not gen6_() after all (that is inviting everybody to use it).
default:
drivers/gpu/drm/i915/intel_lrc.c
Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1
-0+MISSING_CASE (INTEL_INFO (dev_priv)->gen);
case 5: /* forcewake was introduced with gen6 */
case 4:
case 3:
case 2:
drivers/gpu/drm/i915/intel_lrc.c
Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1
-0+return 0 ;
A nice touch here would be toWARN_ON(fw_domains & ~dev_priv->uncore.forcewake_domains);
R-b on the engine->fw_domains_*, a-b on the split, but let's try to use the compiler to our advantage on that step.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Only grab correct forcewake for the engine with execlists
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: drm/i915: Only grab correct forcewake for the engine with execlists
URL : https://patchwork.freedesktop.org/series/5375/
State : success
== Summary ==
Series 5375v1 drm/i915: Only grab correct forcewake for the engine with execlists
http://patchwork.freedesktop.org/api/1.0/series/5375/revisions/1/mbox/
Test drv_module_reload_basic:
dmesg-warn -> PASS (bsw-nuc-2)
Test gem_ctx_param_basic:
Subgroup invalid-ctx-set:
dmesg-warn -> PASS (bsw-nuc-2)
Test gem_storedw_loop:
Subgroup basic-blt:
dmesg-fail -> PASS (bsw-nuc-2)
Subgroup basic-bsd:
skip -> PASS (bsw-nuc-2)
Test kms_addfb_basic:
Subgroup bad-pitch-128:
dmesg-warn -> PASS (bsw-nuc-2)
Test kms_flip:
Subgroup basic-flip-vs-dpms:
dmesg-warn -> PASS (bsw-nuc-2)
Subgroup basic-flip-vs-modeset:
dmesg-warn -> PASS (ilk-hp8440p) UNSTABLE
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
incomplete -> PASS (hsw-gt2)bdw-nuci7 total:196 pass:184 dwarn:0 dfail:0 fail:0 skip:12 bdw-ultra total:196 pass:175 dwarn:0 dfail:0 fail:0 skip:21 bsw-nuc-2 total:196 pass:159 dwarn:0 dfail:0 fail:0 skip:37 byt-nuc total:196 pass:161 dwarn:0 dfail:0 fail:0 skip:35 hsw-brixbox total:196 pass:174 dwarn:0 dfail:0 fail:0 skip:22 hsw-gt2 total:196 pass:179 dwarn:0 dfail:0 fail:0 skip:17 ilk-hp8440p total:196 pass:132 dwarn:0 dfail:0 fail:0 skip:64 ivb-t430s total:196 pass:171 dwarn:0 dfail:0 fail:0 skip:25 skl-i7k-2 total:196 pass:173 dwarn:0 dfail:0 fail:0 skip:23 skl-nuci5 total:196 pass:185 dwarn:0 dfail:0 fail:0 skip:11 snb-dellxps total:196 pass:162 dwarn:0 dfail:0 fail:0 skip:34 snb-x220t total:196 pass:162 dwarn:0 dfail:0 fail:1 skip:33
Results at /archive/results/CI_IGT_test/Patchwork_1817/
ab13a48af1102b84bdb8dcdfbef1b5b44fab8d3d drm-intel-nightly: 2016y-04m-06d-11h-23m-30s UTC integration manifest f9519b6967e2c9d16ea1413a735a4c33cc943b65 drm/i915: Only grab correct forcewake for the engine with execlists
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✓ Fi.CI.BAT: success for drm/i915: Only grab correct forcewake for the engine with execlists
Quoted 24 lines · Patchwork
== Series Details ==
Series: drm/i915: Only grab correct forcewake for the engine with execlists
URL : https://patchwork.freedesktop.org/series/5375/
State : success== Summary ==
Series 5375v1 drm/i915: Only grab correct forcewake for the engine with execlists
http://patchwork.freedesktop.org/api/1.0/series/5375/revisions/1/mbox/Test
drv_module_reload_basic:dmesg-warn -> PASS (bsw-nuc-2) Test gem_ctx_param_basic: Subgroup invalid-ctx-set: dmesg-warn -> PASS (bsw-nuc-2) Test gem_storedw_loop: Subgroup basic-blt: dmesg-fail -> PASS (bsw-nuc-2) Subgroup basic-bsd: skip -> PASS (bsw-nuc-2) Test kms_addfb_basic: Subgroup bad-pitch-128: dmesg-warn -> PASS (bsw-nuc-2)
Quoted 8 lines
Test
kms_flip:Subgroup basic-flip-vs-dpms: dmesg-warn -> PASS (bsw-nuc-2) Subgroup basic-flip-vs-modeset: dmesg-warn -> PASS (ilk-hp8440p) UNSTABLE Test kms_pipe_crc_basic: Subgroup suspend-read-crc-pipe-b: incomplete -> PASS (hsw-gt2)
Hmm, intriguing. I wonder if fortune holds if we send the patch again... -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
drivers/gpu/drm/i915/intel_uncore.c void assert_forcewakes_inactive(struct drm_i915_private *dev_priv) · line 725
Quoted 5 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/intel_uncore.c +5
-0+static const i915_reg_t gen9_shadowed_regs[] = { +RING_TAIL (RENDER_RING_BASE ), +RING_TAIL (GEN6_BSD_RING_BASE ), +RING_TAIL (VEBOX_RING_BASE ), +RING_TAIL (BLT_RING_BASE ),
It occurs to me that we will never use these in anger and so can drop from the search table.
drivers/gpu/drm/i915/intel_uncore.c void assert_forcewakes_inactive(struct drm_i915_private *dev_priv) · line 728
Quoted 3 lines
drivers/gpu/drm/i915/intel_uncore.c +3
-0+FORCEWAKE_BLITTER_GEN9 , +FORCEWAKE_RENDER_GEN9 , + FORCEWAKE_MEDIA_GEN9,
These always use raw accessors (internal to intel_uncore.c).
Review
Quoted 1 line
(quoted diff) +1
-0+ GEN6_RPNSWREQ,
Always written in conjunction with other registers notable by their absence from this table
Review
Quoted 1 line
(quoted diff) +1
-0+ GEN6_RC_VIDEO_FREQ,
Used once per load/resume/reset, whoop-a-do.
Review
Quoted 1 line
(quoted diff) +1
-0+ /* TODO: Other registers are not yet used */
I hope there are more magic registers that we actually use. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx