drm/i915/guc: Don't make assumptions while getting the lrca offset
Subsystems (2)
PATCH 1/1 drm/i915/guc: Don't make assumptions while getting the lrca offset
Using the HWSP ggtt_offset to get the lrca offset is only correct if the HWSP happens to be before it (when we reuse the PPHWSP of the kernel context as the engine HWSP). Instead of making this assumption, get the lrca offset from the kernel_context engine state.
And while looking at this part of the GuC interaction, it was also noticed that the firmware expects the size of only the engine context (context minus the execlist part, i.e. don't include the first 80 dwords), so pass the right size.
--- drivers/gpu/drm/i915/i915_guc_submission.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +12 -3
@@ -1018,6 +1018,12 @@ static void guc_policies_init(struct guc_policies *policies) policies->is_valid =1 ; } +/* +* The first 80 dwords of the register state context, containing the +* execlists and ppgtt registers. +*/ +#define LR_HW_CONTEXT_SIZE (80 * sizeof(u32)) +static int guc_ads_create (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);
@@ -1033,6 +1039,7 @@ static int guc_ads_create(struct intel_guc *guc)struct intel_engine_cs *engine;enum intel_engine_id id;u32 base; +u32 lrca_offset =LRC_PPHWSP_PN *PAGE_SIZE ;GEM_BUG_ON (guc->ads_vma);
@@ -1062,13 +1069,15 @@ static int guc_ads_create(struct intel_guc *guc)* engines after a reset. Here we use the Render ring default * context, which must already exist and be pinned in the GGTT, * so its address won't change after we've told the GuC where -* to find it. +* to find it. GuC will skip the PPHWSP and 'Execlist Context', +* thus reduce the size by 1 page (PPHWSP) and 80 dwords. */ blob->ads.golden_context_lrca = - dev_priv->engine[RCS ]->status_page.ggtt_offset; +guc_ggtt_offset (dev_priv->kernel_context->engine[RCS ].state) + lrca_offset; +/* context_size - PPHWSP - first 80 dwords */ for_each_engine (engine, dev_priv, id) - blob->ads.eng_state_size[engine->guc_id] = engine->context_size; + blob->ads.eng_state_size[engine->guc_id] = engine->context_size - lrca_offset -LR_HW_CONTEXT_SIZE ; base =guc_ggtt_offset (vma); blob->ads.scheduler_policies = base +ptr_offset (blob, policies);
Signature · 6 lines
2.13.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915/guc: Don't make assumptions while getting the lrca offset
== Series Details ==
== Series Details ==
Series: drm/i915/guc: Don't make assumptions while getting the lrca offset
URL : https://patchwork.freedesktop.org/series/27136/
State : success
== Summary ==
Series 27136v1 drm/i915/guc: Don't make assumptions while getting the lrca offset
https://patchwork.freedesktop.org/api/1.0/series/27136/revisions/1/mbox/
Test gem_exec_suspend:
Subgroup basic-s4-devices:
pass -> DMESG-WARN (fi-kbl-7560u) fdo#100125
Test kms_flip:
Subgroup basic-flip-vs-wf_vblank:
pass -> FAIL (fi-skl-6770hq) fdo#99739fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fdo#99739 https://bugs.freedesktop.org/show_bug.cgi?id=99739
fi-bdw-5557u total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:436s fi-bdw-gvtdvm total:279 pass:265 dwarn:0 dfail:0 fail:0 skip:14 time:433s fi-blb-e6850 total:279 pass:224 dwarn:1 dfail:0 fail:0 skip:54 time:361s fi-bsw-n3050 total:279 pass:243 dwarn:0 dfail:0 fail:0 skip:36 time:525s fi-bxt-j4205 total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:508s fi-byt-j1900 total:279 pass:254 dwarn:1 dfail:0 fail:0 skip:24 time:487s fi-byt-n2820 total:279 pass:250 dwarn:1 dfail:0 fail:0 skip:28 time:487s fi-glk-2a total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:598s fi-hsw-4770 total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:443s fi-hsw-4770r total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:412s fi-ilk-650 total:279 pass:229 dwarn:0 dfail:0 fail:0 skip:50 time:421s fi-ivb-3520m total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:494s fi-ivb-3770 total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:471s fi-kbl-7500u total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:461s fi-kbl-7560u total:279 pass:268 dwarn:1 dfail:0 fail:0 skip:10 time:572s fi-kbl-r total:279 pass:260 dwarn:1 dfail:0 fail:0 skip:18 time:576s fi-pnv-d510 total:279 pass:222 dwarn:2 dfail:0 fail:0 skip:55 time:560s fi-skl-6260u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:467s fi-skl-6700hq total:279 pass:262 dwarn:0 dfail:0 fail:0 skip:17 time:585s fi-skl-6700k total:279 pass:257 dwarn:4 dfail:0 fail:0 skip:18 time:468s fi-skl-6770hq total:279 pass:268 dwarn:0 dfail:0 fail:1 skip:10 time:470s fi-skl-gvtdvm total:279 pass:266 dwarn:0 dfail:0 fail:0 skip:13 time:436s fi-skl-x1585l total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:505s fi-snb-2520m total:279 pass:251 dwarn:0 dfail:0 fail:0 skip:28 time:550s fi-snb-2600 total:279 pass:250 dwarn:0 dfail:0 fail:0 skip:29 time:406s
8ad9e19aafea47c272163c2cbf554e06ff7f9857 drm-tip: 2017y-07m-11d-19h-08m-20s UTC integration manifest 84116ad drm/i915/guc: Don't make assumptions while getting the lrca offset
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_5166/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michel Thierry (2017-07-11 22:29:39)
Quoted 37 lines
Using the HWSP
ggtt_offsetto get the lrca offset is only correct if the HWSP happens to be before it (when we reuse the PPHWSP of the kernel context as the engine HWSP). Instead of making this assumption, get the lrca offset from thekernel_contextengine state.And while looking at this part of the GuC interaction, it was also noticed that the firmware expects the size of only the engine context (context minus the execlist part, i.e. don't include the first 80 dwords), so pass the right size.
Reported-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Michel Thierry <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +6
-0@@ -1018,6 +1018,12 @@ static void guc_policies_init(struct guc_policies *policies) policies->is_valid =1 ; } +/* +* The first 80 dwords of the register state context, containing the +* execlists and ppgtt registers. +*/ +#define LR_HW_CONTEXT_SIZE (80 * sizeof(u32)) +static int guc_ads_create (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1042
Quoted 4 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-0@@ -1033,6 +1039,7 @@ static int guc_ads_create(struct intel_guc *guc)struct intel_engine_cs *engine;enum intel_engine_id id;u32 base; +u32 lrca_offset =LRC_PPHWSP_PN *PAGE_SIZE ;
Make it const and try to avoid the visual breaks in line length? (Whilst also trying not to gratuitously mix types.)
Quoted 9 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-1GEM_BUG_ON (guc->ads_vma);@@ -1062,13 +1069,15 @@ static int guc_ads_create(struct intel_guc *guc)* engines after a reset. Here we use the Render ring default * context, which must already exist and be pinned in the GGTT, * so its address won't change after we've told the GuC where -* to find it. +* to find it. GuC will skip the PPHWSP and 'Execlist Context',
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1080
Quoted 10 lines
drivers/gpu/drm/i915/i915_guc_submission.c +4
-2+* thus reduce the size by 1 page (PPHWSP) and 80 dwords. */ blob->ads.golden_context_lrca = - dev_priv->engine[RCS ]->status_page.ggtt_offset; +guc_ggtt_offset (dev_priv->kernel_context->engine[RCS ].state) + lrca_offset; +/* context_size - PPHWSP - first 80 dwords */ for_each_engine (engine, dev_priv, id) - blob->ads.eng_state_size[engine->guc_id] = engine->context_size; + blob->ads.eng_state_size[engine->guc_id] = engine->context_size - lrca_offset -LR_HW_CONTEXT_SIZE ;
The first LRC_PPHWSP_PN pages are not included in engine->context_size, they are added on by execlist_context_deferred_alloc().
I'm finding it odd that we pass in a pointer to the start of the context image, but that the guc wants to be told the size of the context minus the bytes that *it* is choosing to skip at the start. (May be correct, but looks weird and merits a warning.) The alternative explanation is that it is not skipping the first 80 dwords, but the last. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 37 lines · Chris Wilson
Quoting Michel Thierry (2017-07-11 22:29:39)
Quoted 36 lines
Using the HWSP
ggtt_offsetto get the lrca offset is only correct if the HWSP happens to be before it (when we reuse the PPHWSP of the kernel context as the engine HWSP). Instead of making this assumption, get the lrca offset from thekernel_contextengine state.And while looking at this part of the GuC interaction, it was also noticed that the firmware expects the size of only the engine context (context minus the execlist part, i.e. don't include the first 80 dwords), so pass the right size.
Reported-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Michel Thierry <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +6
-0@@ -1018,6 +1018,12 @@ static void guc_policies_init(struct guc_policies *policies) policies->is_valid =1 ; } +/* +* The first 80 dwords of the register state context, containing the +* execlists and ppgtt registers. +*/ +#define LR_HW_CONTEXT_SIZE (80 * sizeof(u32)) +static int guc_ads_create (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);
Quoted 8 lines
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1042
Quoted 5 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-0@@ -1033,6 +1039,7 @@ static int guc_ads_create(struct intel_guc *guc)struct intel_engine_cs *engine;enum intel_engine_id id;u32 base; +u32 lrca_offset =LRC_PPHWSP_PN *PAGE_SIZE ;Make it const and try to avoid the visual breaks in line length? (Whilst also trying not to gratuitously mix types.)
ok
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-2GEM_BUG_ON (guc->ads_vma);@@ -1062,13 +1069,15 @@ static int guc_ads_create(struct intel_guc *guc)* engines after a reset. Here we use the Render ring default * context, which must already exist and be pinned in the GGTT, * so its address won't change after we've told the GuC where -* to find it. +* to find it. GuC will skip the PPHWSP and 'Execlist Context', +* thus reduce the size by 1 page (PPHWSP) and 80 dwords. */ blob->ads.golden_context_lrca = - dev_priv->engine[RCS ]->status_page.ggtt_offset; +guc_ggtt_offset (dev_priv->kernel_context->engine[RCS ].state) + lrca_offset;
Quoted 8 lines
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1080
Quoted 4 lines
drivers/gpu/drm/i915/i915_guc_submission.c +2
-1+/* context_size - PPHWSP - first 80 dwords */ for_each_engine (engine, dev_priv, id) - blob->ads.eng_state_size[engine->guc_id] = engine->context_size; + blob->ads.eng_state_size[engine->guc_id] = engine->context_size - lrca_offset -LR_HW_CONTEXT_SIZE ;The first
LRC_PPHWSP_PNpages are not included inengine->context_size, they are added on byexeclist_context_deferred_alloc().
I think there is only one extra page added in execlists_context_deferred_alloc, and it is the "GuC shared data". And yes, we don't include that one in in the context_size. (also __intel_engine_context_size has a comment saying the size includes the HWSP).
Quoted 5 lines
I'm finding it odd that we pass in a pointer to the start of the context image, but that the guc wants to be told the size of the context minus the bytes that *it* is choosing to skip at the start. (May be correct, but looks weird and merits a warning.) The alternative explanation is that it is not skipping the first 80 dwords, but the last.
Yes, it's really odd style. Daniele & I looked at it, and guc takes the pointer and uses "size of the PPHWSP + the size of the execlist_context (those 80 dwords)" as the starting point of the engine-state... that's why ads.eng_state_size needs to be decreased.
Anyway, since we always round up the ctx size to the next page, I imagine we've been lucky and there are enough 0's at the end of the context.
Quoted 2 lines
-Chris
Thanks!
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michel Thierry (2017-07-12 00:01:04)
Quoted 73 lines · Chris Wilson
Quoted 37 lines
Quoting Michel Thierry (2017-07-11 22:29:39)
Quoted 36 lines
Using the HWSP
ggtt_offsetto get the lrca offset is only correct if the HWSP happens to be before it (when we reuse the PPHWSP of the kernel context as the engine HWSP). Instead of making this assumption, get the lrca offset from thekernel_contextengine state.And while looking at this part of the GuC interaction, it was also noticed that the firmware expects the size of only the engine context (context minus the execlist part, i.e. don't include the first 80 dwords), so pass the right size.
Reported-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Michel Thierry <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +6
-0@@ -1018,6 +1018,12 @@ static void guc_policies_init(struct guc_policies *policies) policies->is_valid =1 ; } +/* +* The first 80 dwords of the register state context, containing the +* execlists and ppgtt registers. +*/ +#define LR_HW_CONTEXT_SIZE (80 * sizeof(u32)) +static int guc_ads_create (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);Quoted 8 lines
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1042
Quoted 5 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-0@@ -1033,6 +1039,7 @@ static int guc_ads_create(struct intel_guc *guc)struct intel_engine_cs *engine;enum intel_engine_id id;u32 base; +u32 lrca_offset =LRC_PPHWSP_PN *PAGE_SIZE ;Make it const and try to avoid the visual breaks in line length? (Whilst also trying not to gratuitously mix types.)
ok
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-2GEM_BUG_ON (guc->ads_vma);@@ -1062,13 +1069,15 @@ static int guc_ads_create(struct intel_guc *guc)* engines after a reset. Here we use the Render ring default * context, which must already exist and be pinned in the GGTT, * so its address won't change after we've told the GuC where -* to find it. +* to find it. GuC will skip the PPHWSP and 'Execlist Context', +* thus reduce the size by 1 page (PPHWSP) and 80 dwords. */ blob->ads.golden_context_lrca = - dev_priv->engine[RCS ]->status_page.ggtt_offset; +guc_ggtt_offset (dev_priv->kernel_context->engine[RCS ].state) + lrca_offset;Quoted 8 lines
drivers/gpu/drm/i915/i915_guc_submission.c static int guc_ads_create(struct intel_guc *guc) · line 1080
Quoted 4 lines
drivers/gpu/drm/i915/i915_guc_submission.c +2
-1+/* context_size - PPHWSP - first 80 dwords */ for_each_engine (engine, dev_priv, id) - blob->ads.eng_state_size[engine->guc_id] = engine->context_size; + blob->ads.eng_state_size[engine->guc_id] = engine->context_size - lrca_offset -LR_HW_CONTEXT_SIZE ;The first
LRC_PPHWSP_PNpages are not included inengine->context_size, they are added on byexeclist_context_deferred_alloc().
Quoted 5 lines
I think there is only one extra page added in
execlists_context_deferred_alloc, and it is the "GuC shared data". And yes, we don't include that one in in thecontext_size.
(also__intel_engine_context_sizehas a comment saying the size includes the HWSP).
Oh, I see what my confusion is. You are using lrca_offset for two very different meanings just because they are the same value. (And also the use of LRC_PPHWSP_PN for execlists_context_deferred_alloc() has the same dubious semantics, which lead me to think that PPHWSP couldn't possibly mean per-process hwsp anymore!) The first is an offset from the start of the allocation to the HWSP, which is the correct meaning of LRC_PPHWSP_PN (that is, its page index). In second case, you just mean PAGE_SIZE to remove the single page being skipped. Please, I am easily confused! That does strongly suggest the comment needs an actual sentence and not just rehashing of the code:
/*
* The GuC expects us to exclude the portion of the context image that
* it skips from the size it is to read. It starts reading from after
* the execlist context (so skipping the first page [PPHWSP] and 80
* dwords). Weird guc is weird.
*/
for_each_engine(engine) {
const u32 skipped = PAGE_SIZE + LR_HW_CONTEXT_SIZE;
blob->ads.eng_state_size[engine->guc_id] = engine->context_size - skipped;
}Also feel free to try and fixup the other confusion in intel_lrc.c. Perhaps something like:
drivers/gpu/drm/i915/intel_lrc.c +3 -2
@@ -2031,8 +2031,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ +BUILD_BUG_ON (LRC_PPHWSP_PN !=1 ); + context_size +=PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Chris Wilson (2017-07-12 01:00:02)
Quoted 9 lines
Also feel free to try and fixup the other confusion in
intel_lrc.c. Perhaps something like:drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2039
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ +BUILD_BUG_ON (LRC_PPHWSP_PN !=1 ); + context_size +=PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {
Or better
drivers/gpu/drm/i915/intel_lrc.c +2 -2
@@ -2031,8 +2031,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ + context_size +=LRC_GUCSHR_PAGES *PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {
drivers/gpu/drm/i915/intel_lrc.h +2 -1
@@ -72,7 +72,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine);/* One extra page is added before LRC for GuC as shared data */ #define LRC_GUCSHR_PN (0) -#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) +#define LRC_GUCSHR_PAGES 1 +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_PAGES)#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)struct drm_i915_private ;
Nowhere do we use LRC_GUCSHR_PN. Having it just gives us the mirage of flexibility...
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 53 lines · Chris Wilson
Quoting Chris Wilson (2017-07-12 01:00:02)
Quoted 9 lines
Also feel free to try and fixup the other confusion in
intel_lrc.c. Perhaps something like:drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2039
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ +BUILD_BUG_ON (LRC_PPHWSP_PN !=1 ); + context_size +=PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {Or better
drivers/gpu/drm/i915/intel_lrc.c +2
-2@@ -2031,8 +2031,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ + context_size +=LRC_GUCSHR_PAGES *PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {drivers/gpu/drm/i915/intel_lrc.h +2
-1@@ -72,7 +72,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine);/* One extra page is added before LRC for GuC as shared data */ #define LRC_GUCSHR_PN (0) -#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) +#define LRC_GUCSHR_PAGES 1 +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_PAGES)#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)struct drm_i915_private ;
Quoted 2 lines
Nowhere do we use
LRC_GUCSHR_PN. Having it just gives us the mirage of flexibility...
LRC_GUCSHR_PN is not used because people assumed it is always page 0 of the kernel ctx :S
One more thing to fix, use LRC_GUCSHR_PN in all the places where this _shared_ GuC page is used (guc_ggtt_offset(ctx->engine[RCS].state))
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michel Thierry (2017-07-12 01:14:46)
Quoted 30 lines · Chris Wilson
Quoted 29 lines
Quoting Chris Wilson (2017-07-12 01:00:02)
Quoted 9 lines
Also feel free to try and fixup the other confusion in
intel_lrc.c. Perhaps something like:drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2039
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ +BUILD_BUG_ON (LRC_PPHWSP_PN !=1 ); + context_size +=PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {Or better
drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2035
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ + context_size +=LRC_GUCSHR_PAGES *PAGE_SIZE ;
One more thought about this, and with a little coaxing LRC_PPHWSP_PN may be the most appropriate constant to use here.
/* Before the actual start of the context image, we insert a few pages
* for our own use and for sharing with the GuC.
*/context_size += LRC_HEADER_PAGES * PAGE_SIZE;
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +0
-0ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {drivers/gpu/drm/i915/intel_lrc.h +0
-0@@ -72,7 +72,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine);
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.h int logical_xcs_ring_init(struct intel_engine_cs *engine); · line 77
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.h +2
-1/* One extra page is added before LRC for GuC as shared data */ #define LRC_GUCSHR_PN (0) -#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) +#define LRC_GUCSHR_PAGES 1 +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_PAGES)#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)
but
/* We allocate a header at the start of the context image for our own
* use, therefore the actual location of the logical state is offset
* from the start of the VMA. The layout is
*
* | [guc] | [hwsp] [logical state] | * |<- our header ->|<- context image ->|
*
*/
/* One extra page is used for sharing with the GuC */ #define LRC_GUCSHR_PN (0)
#define LRC_GUCSHR_PAGES 1
/* At the start of the context image is its per-process HWS page */ #define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_PAGES)
/* Finally we have the logical state for the context */
#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)
/* Currently we include the PPHWSP in __intel_engine_context_size() so
* the size of the header is synonymous with the start of the PPHWSP. */
#define LRC_HEADER_PAGES LRC_PPHWSP_PN
Quoted 11 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.h +0
-0struct drm_i915_private ;Nowhere do we use
LRC_GUCSHR_PN. Having it just gives us the mirage of flexibility...
LRC_GUCSHR_PNis not used because people assumed it is always page 0 of the kernel ctx :SOne more thing to fix, use
LRC_GUCSHR_PNin all the places where this _shared_ GuC page is used (guc_ggtt_offset(ctx->engine[RCS].state))
That may prove very handy.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 79 lines · Chris Wilson
Quoting Michel Thierry (2017-07-12 01:14:46)
Quoted 30 lines · Chris Wilson
Quoted 29 lines
Quoting Chris Wilson (2017-07-12 01:00:02)
Quoted 9 lines
Also feel free to try and fixup the other confusion in
intel_lrc.c. Perhaps something like:drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2039
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ +BUILD_BUG_ON (LRC_PPHWSP_PN !=1 ); + context_size +=PAGE_SIZE ; ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {Or better
drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -2031,8 +2031,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, · line 2035
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-2context_size =round_up (engine->context_size,I915_GTT_PAGE_SIZE ); -/* One extra page as the sharing data between driver and GuC */ - context_size +=PAGE_SIZE *LRC_PPHWSP_PN ; +/* Add an extra page at the start for sharing data with the GuC */ + context_size +=LRC_GUCSHR_PAGES *PAGE_SIZE ;One more thought about this, and with a little coaxing
LRC_PPHWSP_PNmay be the most appropriate constant to use here./* Before the actual start of the context image, we insert a few pages
* for our own use and for sharing with the GuC.
*/context_size+=LRC_HEADER_PAGES*PAGE_SIZE;Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +0
-0ctx_obj =i915_gem_object_create (ctx->i915, context_size);if (IS_ERR (ctx_obj)) {drivers/gpu/drm/i915/intel_lrc.h +0
-0@@ -72,7 +72,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine);Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.h int logical_xcs_ring_init(struct intel_engine_cs *engine); · line 77
Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.h +2
-1/* One extra page is added before LRC for GuC as shared data */ #define LRC_GUCSHR_PN (0) -#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) +#define LRC_GUCSHR_PAGES 1 +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_PAGES)#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)but
/* We allocate a header at the start of the context image for our own
* use, therefore the actual location of the logical state is offset
* from the start of the VMA. The layout is
** | [guc] | [hwsp] [logical state] | * |<- our header ->|<- context image ->|*
*//* One extra page is used for sharing with the GuC */ #define
LRC_GUCSHR_PN(0)
#defineLRC_GUCSHR_PAGES1/* At the start of the context image is its per-process HWS page */ #define
LRC_PPHWSP_PN(LRC_GUCSHR_PN+LRC_GUCSHR_PAGES)
Quoted 8 lines
/* Finally we have the logical state for the context */
#defineLRC_STATE_PN(LRC_PPHWSP_PN+ 1)/* Currently we include the PPHWSP in
__intel_engine_context_size()so
* the size of the header is synonymous with the start of the PPHWSP. */
#defineLRC_HEADER_PAGESLRC_PPHWSP_PN
It cannot be clearer now.
The only extra thing I was thinking about was also defining the 'size' (length?) of the guc and pphwsp sections, in case those "+ 1" were not clear:
#define LRC_GUCSHR_PN (0) -#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) -#define LRC_STATE_PN (LRC_PPHWSP_PN + 1) +#define LRC_GUCSHR_SZ (1) +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_SZ) +#define LRC_PPHWSP_SZ (1) +#define LRC_STATE_PN (LRC_PPHWSP_PN + LRC_PPHWSP_SZ)
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.h +0
-0struct drm_i915_private ;Nowhere do we use
LRC_GUCSHR_PN. Having it just gives us the mirage of flexibility...
Quoted 9 lines
Quoted 5 lines
LRC_GUCSHR_PNis not used because people assumed it is always page 0 of the kernel ctx :SOne more thing to fix, use
LRC_GUCSHR_PNin all the places where this _shared_ GuC page is used (guc_ggtt_offset(ctx->engine[RCS].state))That may prove very handy.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michel Thierry (2017-07-12 02:01:29)
Quoted 34 lines · Chris Wilson
Quoted 16 lines
/* We allocate a header at the start of the context image for our own
* use, therefore the actual location of the logical state is offset
* from the start of the VMA. The layout is
** | [guc] | [hwsp] [logical state] | * |<- our header ->|<- context image ->|*
*//* One extra page is used for sharing with the GuC */ #define
LRC_GUCSHR_PN(0)
#defineLRC_GUCSHR_PAGES1/* At the start of the context image is its per-process HWS page */ #define
LRC_PPHWSP_PN(LRC_GUCSHR_PN+LRC_GUCSHR_PAGES)Quoted 8 lines
/* Finally we have the logical state for the context */
#defineLRC_STATE_PN(LRC_PPHWSP_PN+ 1)/* Currently we include the PPHWSP in
__intel_engine_context_size()so
* the size of the header is synonymous with the start of the PPHWSP. */
#defineLRC_HEADER_PAGESLRC_PPHWSP_PNIt cannot be clearer now.
The only extra thing I was thinking about was also defining the 'size' (length?) of the guc and pphwsp sections, in case those "+ 1" were not clear:
#define LRC_GUCSHR_PN (0)
Review
Quoted 6 lines
(quoted diff) +4
-2-#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1) -#define LRC_STATE_PN (LRC_PPHWSP_PN + 1) +#define LRC_GUCSHR_SZ (1) +#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_SZ) +#define LRC_PPHWSP_SZ (1) +#define LRC_STATE_PN (LRC_PPHWSP_PN + LRC_PPHWSP_SZ)
Yes, I erred on the side of laziness thinking that this is common enough that there should be a generator somewhere, but was to lazy to find/write one.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx