Various improvements around the GuC topic
Subsystems (2)
cover Various improvements around the GuC topic
Now rebased on top of Arek's "GuC Scrub". There are also two new patches at the end compared to when I last sent the series.
Oscar Mateo (12):
drm/i915/guc: Sanitize GuC client initialization drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access drm/i915/guc: Add onion teardown to the GuC setup drm/i915/guc: The Additional Data Struct (ADS) should get enabled
together with GuC submission
drm/i915/guc: Break out the GuC log extras into their own "runtime"
struct
drm/i915/guc: Make intel_guc_send a function pointer drm/i915/guc: Improve the GuC documentation & comments about proxy
submissions
drm/i915/guc: Wait for doorbell to be inactive before deallocating drm/i915/guc: A little bit more of doorbell sanitization drm/i915/guc: Refactor the concept "GuC context descriptor" into "GuC
stage descriptor"
drm/i915/guc: Split out the mmio_white_list struct drm/i915/guc: Move guc_interrupts_release next to
guc_interrupts_capture
drivers/gpu/drm/i915/i915_debugfs.c | 8 +- drivers/gpu/drm/i915/i915_drv.c | 11 +- drivers/gpu/drm/i915/i915_gem.c | 10 +- drivers/gpu/drm/i915/i915_guc_submission.c | 784 +++++++++++++++++------------ drivers/gpu/drm/i915/i915_irq.c | 4 +- drivers/gpu/drm/i915/intel_guc_fwif.h | 71 +-- drivers/gpu/drm/i915/intel_guc_loader.c | 33 +- drivers/gpu/drm/i915/intel_guc_log.c | 386 +++++++------- drivers/gpu/drm/i915/intel_uc.c | 62 ++- drivers/gpu/drm/i915/intel_uc.h | 51 +- 10 files changed, 788 insertions(+), 632 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/12 drm/i915/guc: Sanitize GuC client initialization
Started adding proper teardown to guc_client_alloc, ended up removing quite a few dead ends where errors communicating with the GuC were silently ignored. There also seemed to be quite a few erronous teardown actions performed in case of an error (ordering wrong).
v2:
- Increase function symmetry/proximity (Michal/Daniele)
- Fix __reserve_doorbell accounting for high priority (Daniele)
- Call __update_doorbell_desc! (Daniele)
- Isolate __guc_{,de}allocate_doorbell (Michal/Daniele)
v3:
- "Select" a cacheline is a more accurate verb than "reserve" (Daniele).
- We cannot update & create the doorbell without reserving it first, so move the whole doorbell creation for execbuf_client to the submission enable (Oscar).i
- Add a fixme for ignoring possible doorbell destroy errors.
v4:
- Remove comment about is_high_priority (Daniele)
- Debug message typo (Daniele)
- Reuse __get_doorbell in more places (Daniele)
- Do not do arithmetic on void pointers (Daniele)
- Add comment to __reset_doorbell (Daniele)
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 +- drivers/gpu/drm/i915/i915_guc_submission.c | 399 ++++++++++++++++------------- drivers/gpu/drm/i915/intel_guc_fwif.h | 4 +- drivers/gpu/drm/i915/intel_uc.h | 11 +- 4 files changed, 234 insertions(+), 184 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -2476,7 +2476,7 @@ static void i915_guc_client_info(struct seq_file *m,seq_printf (m,"\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n" , client->priority, client->ctx_index, client->proc_desc_offset); -seq_printf (m,"\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n" , +seq_printf (m,"\tDoorbell id %d, offset: 0x%lx, cookie 0x%x\n" , client->doorbell_id, client->doorbell_offset, client->doorbell_cookie);seq_printf (m,"\tWQ size %d, offset: 0x%x, tail %d\n" , client->wq_size, client->wq_offset, client->wq_tail);
@@ -2511,7 +2511,7 @@ static int i915_guc_info(struct seq_file *m, void *data) }seq_printf (m,"Doorbell map:\n" ); -seq_printf (m,"\t%*pb\n" ,GUC_MAX_DOORBELLS , guc->doorbell_bitmap); +seq_printf (m,"\t%*pb\n" ,GUC_NUM_DOORBELLS , guc->doorbell_bitmap);seq_printf (m,"Doorbell next cacheline: 0x%x\n\n" , guc->db_cacheline);seq_printf (m,"GuC total action count: %llu\n" , guc->action_count);
drivers/gpu/drm/i915/i915_guc_submission.c +225 -174
589 lines not on this page · raw message
drivers/gpu/drm/i915/intel_guc_fwif.h +2 -2
@@ -241,8 +241,8 @@ struct guc_doorbell_info {u64 value_qw; } __packed; -#define GUC_MAX_DOORBELLS 256 -#define GUC_INVALID_DOORBELL_ID (GUC_MAX_DOORBELLS) +#define GUC_NUM_DOORBELLS 256 +#define GUC_DOORBELL_INVALID (GUC_NUM_DOORBELLS)#define GUC_DB_SIZE (PAGE_SIZE)#define GUC_WQ_SIZE (PAGE_SIZE * 2)
drivers/gpu/drm/i915/intel_uc.h +5 -6
@@ -72,13 +72,12 @@ struct i915_guc_client {uint32_t engines;/* bitmap of (host) engine ids */ uint32_t priority; -uint32_t ctx_index; +u32 ctx_index;uint32_t proc_desc_offset; -uint32_t doorbell_offset; -uint32_t doorbell_cookie; -uint16_t doorbell_id; -uint16_t padding[3 ];/* Maintain alignment */ +u16 doorbell_id; +unsigned long doorbell_offset; +u32 doorbell_cookie;spinlock_t wq_lock;uint32_t wq_offset;
@@ -159,7 +158,7 @@ struct intel_guc {struct i915_guc_client *execbuf_client; -DECLARE_BITMAP (doorbell_bitmap,GUC_MAX_DOORBELLS ); +DECLARE_BITMAP (doorbell_bitmap,GUC_NUM_DOORBELLS );uint32_t db_cacheline;/* Cyclic counter mod pagesize */ /* Action status & statistics */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH 01/12] drm/i915/guc: Sanitize GuC client initialization
It's a good practice to use "git am" to apply the original patch and then "git commit --amend" to it, so that the "From: " field stays intact. Or use git commit --amend --author="John Doe <[email protected]>" but that is more prone to typos.
Quoted 25 lines · Oscar Mateo
Started adding proper teardown to
guc_client_alloc, ended up removing quite a few dead ends where errors communicating with the GuC were silently ignored. There also seemed to be quite a few erronous teardown actions performed in case of an error (ordering wrong).v2:
- Increase function symmetry/proximity (Michal/Daniele)
- Fix__reserve_doorbellaccounting for high priority (Daniele)
- Call__update_doorbell_desc! (Daniele)
- Isolate __guc_{,de}allocate_doorbell (Michal/Daniele)v3:
- "Select" a cacheline is a more accurate verb than "reserve" (Daniele).
- We cannot update & create the doorbell without reserving it first, so move the whole doorbell creation forexecbuf_clientto the submission enable (Oscar).i
- Add a fixme for ignoring possible doorbell destroy errors.v4:
- Remove comment aboutis_high_priority(Daniele)
- Debug message typo (Daniele)
- Reuse__get_doorbellin more places (Daniele)
- Do not do arithmetic on void pointers (Daniele)
- Add comment to__reset_doorbell(Daniele)
Quoted 7 lines
Signed-off-by Joonas Lahtinen <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Arkadiusz Hiler <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>Reviewed-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
The R-b should probably be after S-o-b if it was to last version.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/12] drm/i915/guc: Sanitize GuC client initialization
Quoted 38 lines · Joonas Lahtinen
It's a good practice to use "git am" to apply the original patch and then "git commit --amend" to it, so that the "From: " field stays intact. Or use git commit --amend --author="John Doe <[email protected]>" but that is more prone to typos.
Quoted 25 lines · Oscar Mateo
Started adding proper teardown to
guc_client_alloc, ended up removing quite a few dead ends where errors communicating with the GuC were silently ignored. There also seemed to be quite a few erronous teardown actions performed in case of an error (ordering wrong).v2:
- Increase function symmetry/proximity (Michal/Daniele)
- Fix__reserve_doorbellaccounting for high priority (Daniele)
- Call__update_doorbell_desc! (Daniele)
- Isolate __guc_{,de}allocate_doorbell (Michal/Daniele)v3:
- "Select" a cacheline is a more accurate verb than "reserve" (Daniele).
- We cannot update & create the doorbell without reserving it first, so move the whole doorbell creation forexecbuf_clientto the submission enable (Oscar).i
- Add a fixme for ignoring possible doorbell destroy errors.v4:
- Remove comment aboutis_high_priority(Daniele)
- Debug message typo (Daniele)
- Reuse__get_doorbellin more places (Daniele)
- Do not do arithmetic on void pointers (Daniele)
- Add comment to__reset_doorbell(Daniele)Quoted 7 lines
Signed-off-by Joonas Lahtinen <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Arkadiusz Hiler <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>Reviewed-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
Quoted 3 lines
The R-b should probably be after S-o-b if it was to last version.
Regards, Joonas
My bad. I have spent too much time without using Git I'm like wicked rusty (you have probably noticed other weird things I've done, like sending the last series without the word "PATCH" or sending this one without proper versions in the subject). I'll fix those things and resubmit. Thanks,
Oscar
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/12 drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access
In reply to Oscar MateoThe GuC descriptor is big in size. If we use a local definition of guc_desc we have a chance to overflow stack, so avoid it.
Also, Chris abhors scatterlists :)
v2: Rebased, helper function to retrieve the context descriptor, s/ctx_pool_vma/ctx_pool/
v3: Zero out guc_context_desc before initialization
v4: Do not do arithmetic on void pointers
--- drivers/gpu/drm/i915/i915_guc_submission.c | 93 +++++++++++++++--------------- drivers/gpu/drm/i915/intel_guc_loader.c | 2 +- drivers/gpu/drm/i915/intel_uc.h | 3 +- 3 files changed, 48 insertions(+), 50 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +45 -48
@@ -133,6 +133,12 @@ static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index)return intel_guc_send (guc, action,ARRAY_SIZE (action)); } +static struct guc_context_desc *__get_context_desc (struct i915_guc_client *client) +{ +return (struct guc_context_desc *)((char *)client->guc->ctx_pool_vaddr + +sizeof (struct guc_context_desc ) * client->ctx_index); +} +/* * Initialise, update, or clear doorbell data shared with the GuC *
@@ -142,21 +148,11 @@ static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index)static int __update_doorbell_desc (struct i915_guc_client *client,u16 new_id) { -struct sg_table *sg = client->guc->ctx_pool_vma->pages; -struct guc_context_desc desc; -size_t len; +struct guc_context_desc *desc;/* Update the GuC's idea of the doorbell ID */ - len =sg_pcopy_to_buffer (sg->sgl, sg->nents, &desc,sizeof (desc), -sizeof (desc) * client->ctx_index); -if (len !=sizeof (desc)) -return -EFAULT ; - - desc.db_id = new_id; - len =sg_pcopy_from_buffer (sg->sgl, sg->nents, &desc,sizeof (desc), -sizeof (desc) * client->ctx_index); -if (len !=sizeof (desc)) -return -EFAULT ; + desc =__get_context_desc (client); + desc->db_id = new_id;return 0 ; }
@@ -272,29 +268,28 @@ static void guc_proc_desc_init(struct intel_guc *guc,* data structures relating to this client (doorbell, process descriptor, * write queue, etc). */ -static void guc_ctx_desc_init (struct intel_guc *guc,struct i915_guc_client *client) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);struct intel_engine_cs *engine;struct i915_gem_context *ctx = client->owner; -struct guc_context_desc desc; -struct sg_table *sg; +struct guc_context_desc *desc;unsigned int tmp;u32 gfx_addr; -memset (&desc,0 ,sizeof (desc)); + desc =__get_context_desc (client); +memset (desc,0 ,sizeof (*desc)); - desc.attribute =GUC_CTX_DESC_ATTR_ACTIVE |GUC_CTX_DESC_ATTR_KERNEL ; - desc.context_id = client->ctx_index; - desc.priority = client->priority; - desc.db_id = client->doorbell_id; + desc->attribute =GUC_CTX_DESC_ATTR_ACTIVE |GUC_CTX_DESC_ATTR_KERNEL ; + desc->context_id = client->ctx_index; + desc->priority = client->priority; + desc->db_id = client->doorbell_id;for_each_engine_masked (engine, dev_priv, client->engines, tmp) {struct intel_context *ce = &ctx->engine[engine->id];uint32_t guc_engine_id = engine->guc_id; -struct guc_execlist_context *lrc = &desc.lrc[guc_engine_id]; +struct guc_execlist_context *lrc = &desc->lrc[guc_engine_id];/* TODO: We have a design issue to be solved here. Only when we * receive the first batch, we know which engine is used by the
@@ -319,49 +314,40 @@ static void guc_ctx_desc_init(struct intel_guc *guc, lrc->ring_next_free_location = lrc->ring_begin; lrc->ring_current_tail_pointer_value =0 ; - desc.engines_used |= (1 << guc_engine_id); + desc->engines_used |= (1 << guc_engine_id); }DRM_DEBUG_DRIVER ("Host engines 0x%x => GuC engines used 0x%x\n" , - client->engines, desc.engines_used); -WARN_ON (desc.engines_used ==0 ); + client->engines, desc->engines_used); +WARN_ON (desc->engines_used ==0 );/* * The doorbell, process descriptor, and workqueue are all parts * of the client object, which the GuC will reference via the GGTT */ gfx_addr =guc_ggtt_offset (client->vma); - desc.db_trigger_phy =sg_dma_address (client->vma->pages->sgl) + + desc->db_trigger_phy =sg_dma_address (client->vma->pages->sgl) + client->doorbell_offset; - desc.db_trigger_cpu = (uintptr_t )__get_doorbell (client); - desc.db_trigger_uk = gfx_addr + client->doorbell_offset; - desc.process_desc = gfx_addr + client->proc_desc_offset; - desc.wq_addr = gfx_addr + client->wq_offset; - desc.wq_size = client->wq_size; + desc->db_trigger_cpu = (uintptr_t )__get_doorbell (client); + desc->db_trigger_uk = gfx_addr + client->doorbell_offset; + desc->process_desc = gfx_addr + client->proc_desc_offset; + desc->wq_addr = gfx_addr + client->wq_offset; + desc->wq_size = client->wq_size;/* * XXX: Take LRCs from an existing context if this is not an * IsKMDCreatedContext client */ - desc.desc_private = (uintptr_t )client; - -/* Pool context is pinned already */ - sg = guc->ctx_pool_vma->pages; -sg_pcopy_from_buffer (sg->sgl, sg->nents, &desc,sizeof (desc), -sizeof (desc) * client->ctx_index); + desc->desc_private = (uintptr_t )client; }static void guc_ctx_desc_fini (struct intel_guc *guc,struct i915_guc_client *client) { -struct guc_context_desc desc; -struct sg_table *sg; - -memset (&desc,0 ,sizeof (desc)); +struct guc_context_desc *desc; - sg = guc->ctx_pool_vma->pages; -sg_pcopy_from_buffer (sg->sgl, sg->nents, &desc,sizeof (desc), -sizeof (desc) * client->ctx_index); + desc =__get_context_desc (client); +memset (desc,0 ,sizeof (*desc)); }/**
@@ -1025,6 +1011,7 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)const size_t gemsize =round_up (poolsize,PAGE_SIZE );struct intel_guc *guc = &dev_priv->guc;struct i915_vma *vma; +void *vaddr;if (!HAS_GUC_SCHED (dev_priv))return 0 ;
@@ -1036,14 +1023,21 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)if (!i915.enable_guc_submission)return 0 ;/* not enabled */ -if (guc->ctx_pool_vma) +if (guc->ctx_pool)return 0 ;/* already allocated */ vma =intel_guc_allocate_vma (guc, gemsize);if (IS_ERR (vma))return PTR_ERR (vma); - guc->ctx_pool_vma = vma; + guc->ctx_pool = vma; + + vaddr =i915_gem_object_pin_map (vma->obj,I915_MAP_WB ); +if (IS_ERR (vaddr)) + goto err; + + guc->ctx_pool_vaddr = vaddr; +ida_init (&guc->ctx_ids);intel_guc_log_create (guc);guc_addon_create (guc);
@@ -1218,9 +1212,12 @@ void i915_guc_submission_fini(struct drm_i915_private *dev_priv)i915_vma_unpin_and_release (&guc->ads_vma);i915_vma_unpin_and_release (&guc->log.vma); -if (guc->ctx_pool_vma) +if (guc->ctx_pool_vaddr) {ida_destroy (&guc->ctx_ids); -i915_vma_unpin_and_release (&guc->ctx_pool_vma); +i915_gem_object_unpin_map (guc->ctx_pool->obj); + } + +i915_vma_unpin_and_release (&guc->ctx_pool); }/**
drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
@@ -156,7 +156,7 @@ static void guc_params_init(struct drm_i915_private *dev_priv)/* If GuC submission is enabled, set up additional parameters here */ if (i915.enable_guc_submission) { -u32 pgs =guc_ggtt_offset (dev_priv->guc.ctx_pool_vma); +u32 pgs =guc_ggtt_offset (dev_priv->guc.ctx_pool);u32 ctx_in_16 =GUC_MAX_GPU_CONTEXTS /16 ; pgs >>=PAGE_SHIFT ;
drivers/gpu/drm/i915/intel_uc.h +2 -1
@@ -153,7 +153,8 @@ struct intel_guc {bool interrupts_enabled;struct i915_vma *ads_vma; -struct i915_vma *ctx_pool_vma; +struct i915_vma *ctx_pool; +void *ctx_pool_vaddr;struct ida ctx_ids;struct i915_guc_client *execbuf_client;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/12] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access
Quoted 27 lines · Oscar Mateo
The GuC descriptor is big in size. If we use a local definition of
guc_descwe have a chance to overflow stack, so avoid it.Also, Chris abhors scatterlists :)
v2: Rebased, helper function to retrieve the context descriptor, s/ctx_pool_vma/ctx_pool/
v3: Zero out
guc_context_descbefore initializationv4: Do not do arithmetic on void pointers
Cc Daniele Ceraolo Spurio <[email protected]>Reviewed-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 93 +++++++++++++++--------------- drivers/gpu/drm/i915/intel_guc_loader.c | 2 +- drivers/gpu/drm/i915/intel_uc.h | 3 +- 3 files changed, 48 insertions(+), 50 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +0
-0
drivers/gpu/drm/i915/i915_guc_submission.c static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index) · line 138
Quoted 6 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-0@@ -133,6 +133,12 @@ static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index)return intel_guc_send (guc, action,ARRAY_SIZE (action)); } +static struct guc_context_desc *__get_context_desc (struct i915_guc_client *client) +{ + return (struct guc_context_desc *)((char *)client->guc->ctx_pool_vaddr +
We can use gccisms like using void * for arithmetic computations in the kernel, i.e.
void *base = client->guc->ctx_pool_vaddr; return base + sizeof(struct guc_context_desc) * client->ctx_index;
is just fine.
-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
Re: [PATCH 02/12] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access
Quoted 36 lines · Chris Wilson
Quoted 27 lines · Oscar Mateo
The GuC descriptor is big in size. If we use a local definition of
guc_descwe have a chance to overflow stack, so avoid it.Also, Chris abhors scatterlists :)
v2: Rebased, helper function to retrieve the context descriptor, s/ctx_pool_vma/ctx_pool/
v3: Zero out
guc_context_descbefore initializationv4: Do not do arithmetic on void pointers
Cc Daniele Ceraolo Spurio <[email protected]>Reviewed-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 93 +++++++++++++++--------------- drivers/gpu/drm/i915/intel_guc_loader.c | 2 +- drivers/gpu/drm/i915/intel_uc.h | 3 +- 3 files changed, 48 insertions(+), 50 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +0
-0drivers/gpu/drm/i915/i915_guc_submission.c static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index) · line 138
Quoted 6 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-0@@ -133,6 +133,12 @@ static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index)return intel_guc_send (guc, action,ARRAY_SIZE (action)); } +static struct guc_context_desc *__get_context_desc (struct i915_guc_client *client) +{ + return (struct guc_context_desc *)((char *)client->guc->ctx_pool_vaddr +We can use gccisms like using void * for arithmetic computations in the kernel, i.e.
Quoted 4 lines
void *base = client->guc->ctx_pool_vaddr; return base + sizeof(struct guc_context_desc) * client->ctx_index;is just fine.
-Chris
:_(
I got convinced by a previous review comment that arithmetic with void pointers was frowned upon. Ok, thanks!
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/12] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access
Quoted 43 lines · Oscar Mateo
Quoted 35 lines · Chris Wilson
Quoted 27 lines · Oscar Mateo
The GuC descriptor is big in size. If we use a local definition of
guc_descwe have a chance to overflow stack, so avoid it.Also, Chris abhors scatterlists :)
v2: Rebased, helper function to retrieve the context descriptor, s/ctx_pool_vma/ctx_pool/
v3: Zero out
guc_context_descbefore initializationv4: Do not do arithmetic on void pointers
Cc Daniele Ceraolo Spurio <[email protected]>Reviewed-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 93 +++++++++++++++--------------- drivers/gpu/drm/i915/intel_guc_loader.c | 2 +- drivers/gpu/drm/i915/intel_uc.h | 3 +- 3 files changed, 48 insertions(+), 50 deletions(-)drivers/gpu/drm/i915/i915_guc_submission.c +0
-0drivers/gpu/drm/i915/i915_guc_submission.c static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index) · line 137
Quoted 5 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-0@@ -133,6 +133,12 @@ static int __guc_deallocate_doorbell(struct intel_guc *guc, u32 ctx_index)return intel_guc_send (guc, action,ARRAY_SIZE (action)); } +static struct guc_context_desc *__get_context_desc (struct i915_guc_client *client) +{ + return (struct guc_context_desc *)((char *)client->guc->ctx_pool_vaddr +We can use gccisms like using void * for arithmetic computations in the kernel, i.e.
Quoted 4 lines
void *base = client->guc->ctx_pool_vaddr; return base + sizeof(struct guc_context_desc) * client->ctx_index;is just fine.
-Chris
Quoted 4 lines
:_(
I got convinced by a previous review comment that arithmetic with void pointers was frowned upon.
Ok, thanks!
Joonas mentioned trying:
struct guc_context_desc *base = client->guc->ctx_pool_vaddr; return base + client->ctx_index;
or
return &base[client->ctx_index];
for even more idiomatic C.
-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
PATCH 3/12 drm/i915/guc: Add onion teardown to the GuC setup
In reply to Oscar MateoStarting with intel_guc_loader, down to intel_guc_submission and finally to intel_guc_log.
v2:
- Null execbuf client outside guc_client_free (Daniele)
- Assert if things try to get allocated twice (Daniele/Joonas)
- Null guc->log.buf_addr when destroyed (Daniele)
- Newline between returning success and error labels (Joonas)
- Remove some unnecessary comments (Joonas)
- Keep guc_log_create_extras naming convention (Joonas)
- Helper function guc_log_has_extras (Joonas)
- No need for separate relay_channel create/destroy. It's just another extra.
- No need to nullify guc->log.flush_wq when destroyed (Joonas)
- Hoist the check for has_extras out of guc_log_create_extras (Joonas)
- Try to do i915_guc_log_register/unregister calls (kind of) symmetric (Daniele)
- Make sure initel_guc_fini is not called before init is ever called (Daniele)
v3:
- Remove unnecessary parenthesis (Joonas)
- Check for logs enabled on debugfs registration
- Rebase on top of Tvrtko's "Fix request re-submission after reset"
v4:
- Rebased
- Comment around enabling/disabling interrupts inside GuC logging (Joonas)
--- drivers/gpu/drm/i915/i915_drv.c | 11 +- drivers/gpu/drm/i915/i915_gem.c | 10 +- drivers/gpu/drm/i915/i915_guc_submission.c | 97 ++++---- drivers/gpu/drm/i915/intel_guc_loader.c | 21 -- drivers/gpu/drm/i915/intel_guc_log.c | 364 ++++++++++++++--------------- drivers/gpu/drm/i915/intel_uc.c | 55 +++-- drivers/gpu/drm/i915/intel_uc.h | 8 +- 7 files changed, 297 insertions(+), 269 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +6 -5
@@ -549,6 +549,8 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)static void i915_gem_fini (struct drm_i915_private *dev_priv) {mutex_lock (&dev_priv->drm.struct_mutex); +if (i915.enable_guc_loading) +intel_uc_fini_hw (dev_priv);i915_gem_cleanup_engines (dev_priv);i915_gem_context_fini (dev_priv);mutex_unlock (&dev_priv->drm.struct_mutex);
@@ -609,7 +611,7 @@ static int i915_load_modeset_init(struct drm_device *dev) ret =i915_gem_init (dev_priv);if (ret) - goto cleanup_irq; + goto cleanup_uc;intel_modeset_gem_init (dev);
@@ -631,9 +633,9 @@ static int i915_load_modeset_init(struct drm_device *dev)if (i915_gem_suspend (dev_priv))DRM_ERROR ("failed to idle hardware; continuing to unload!\n" );i915_gem_fini (dev_priv); +cleanup_uc: +intel_uc_fini_fw (dev_priv); cleanup_irq: -intel_guc_fini (dev_priv); -intel_huc_fini (dev_priv);drm_irq_uninstall (dev);intel_teardown_gmbus (dev_priv); cleanup_csr:
@@ -1369,9 +1371,8 @@ void i915_driver_unload(struct drm_device *dev)/* Flush any outstanding unpin_work. */ drain_workqueue (dev_priv->wq); -intel_guc_fini (dev_priv); -intel_huc_fini (dev_priv);i915_gem_fini (dev_priv); +intel_uc_fini_fw (dev_priv);intel_fbc_cleanup_cfb (dev_priv);intel_power_domains_fini (dev_priv);
drivers/gpu/drm/i915/i915_gem.c +6 -4
@@ -4596,10 +4596,12 @@ int i915_gem_init_hw(struct drm_i915_private *dev_priv)intel_mocs_init_l3cc_table (dev_priv); -/* We can't enable contexts until all firmware is loaded */ - ret =intel_uc_init_hw (dev_priv); -if (ret) - goto out; +if (i915.enable_guc_loading) { +/* We can't enable contexts until all firmware is loaded */ + ret =intel_uc_init_hw (dev_priv); +if (ret) + goto out; + } out:intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL );
drivers/gpu/drm/i915/i915_guc_submission.c +57 -40
162 lines not on this page · raw message
drivers/gpu/drm/i915/intel_guc_loader.c +0 -21
@@ -430,24 +430,3 @@ int intel_guc_select_fw(struct intel_guc *guc)return 0 ; } - -/** -* intel_guc_fini() - clean up all allocated resources -* @dev_priv: i915 device private -*/ -void intel_guc_fini (struct drm_i915_private *dev_priv) -{ -struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; -struct drm_i915_gem_object *obj; - -mutex_lock (&dev_priv->drm.struct_mutex); -i915_guc_submission_disable (dev_priv); -i915_guc_submission_fini (dev_priv); -mutex_unlock (&dev_priv->drm.struct_mutex); - - obj =fetch_and_zero (&guc_fw->obj); -if (obj) -i915_gem_object_put (obj); - - guc_fw->fetch_status =INTEL_UC_FIRMWARE_NONE ; -}
drivers/gpu/drm/i915/intel_guc_log.c +182 -182
461 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.c +41 -14
89 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.h +5 -3
@@ -187,7 +187,9 @@ struct intel_huc {void intel_uc_sanitize_options (struct drm_i915_private *dev_priv);void intel_uc_init_early (struct drm_i915_private *dev_priv);void intel_uc_init_fw (struct drm_i915_private *dev_priv); +void intel_uc_fini_fw (struct drm_i915_private *dev_priv);int intel_uc_init_hw (struct drm_i915_private *dev_priv); +void intel_uc_fini_hw (struct drm_i915_private *dev_priv);void intel_uc_prepare_fw (struct drm_i915_private *dev_priv,struct intel_uc_fw *uc_fw);int intel_guc_send (struct intel_guc *guc,const u32 *action,u32 len);
@@ -196,7 +198,6 @@ void intel_uc_prepare_fw(struct drm_i915_private *dev_priv,/* intel_guc_loader.c */ int intel_guc_select_fw (struct intel_guc *guc);int intel_guc_init_hw (struct intel_guc *guc); -void intel_guc_fini (struct drm_i915_private *dev_priv);const char *intel_uc_fw_status_repr (enum intel_uc_fw_status status);int intel_guc_suspend (struct drm_i915_private *dev_priv);int intel_guc_resume (struct drm_i915_private *dev_priv);
@@ -212,10 +213,11 @@ void intel_uc_prepare_fw(struct drm_i915_private *dev_priv,struct i915_vma *intel_guc_allocate_vma (struct intel_guc *guc,u32 size);/* intel_guc_log.c */ -void intel_guc_log_create (struct intel_guc *guc); +int intel_guc_log_create (struct intel_guc *guc); +void intel_guc_log_destroy (struct intel_guc *guc); +int i915_guc_log_control (struct drm_i915_private *dev_priv,u64 control_val);void i915_guc_log_register (struct drm_i915_private *dev_priv);void i915_guc_log_unregister (struct drm_i915_private *dev_priv); -int i915_guc_log_control (struct drm_i915_private *dev_priv,u64 control_val);static inline u32 guc_ggtt_offset (struct i915_vma *vma) {
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/12 drm/i915/guc: The Additional Data Struct (ADS) should get enabled together with GuC submission
In reply to Oscar MateoIt's mandatory and it gets created if and only if GuC submission is enabled, so that should be the condition for informing the GuC about it.
Also s/guc_addon_create/guc_ads_create and s/guc_addon_destroy/guc_ads_destroy and, while at it, add an explanation of what things go inside the ADS object.
--- drivers/gpu/drm/i915/i915_guc_submission.c | 17 ++++++++++++----- drivers/gpu/drm/i915/intel_guc_loader.c | 10 ++++------ 2 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +12 -5
@@ -62,6 +62,13 @@* ELSP context descriptor dword into Work Item. * See guc_wq_item_append() * +* ADS: +* The Additional Data Struct (ADS) has pointers for different buffers used by +* the GuC. One single gem object contains the ADS struct itself (guc_ads), the +* scheduling policies (guc_policies), a structure describing a collection of +* register sets (guc_mmio_reg_state) and some extra pages for the GuC to save +* its internal state for sleep. +* */ static inline bool is_high_priority (struct i915_guc_client * client)
@@ -937,7 +944,7 @@ static void guc_policies_init(struct guc_policies *policies) policies->is_valid =1 ; } -static int guc_addon_create (struct intel_guc *guc) +static int guc_ads_create (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);struct i915_vma *vma;
@@ -1000,7 +1007,7 @@ static int guc_addon_create(struct intel_guc *guc)return 0 ; } -static void guc_addon_destroy (struct intel_guc *guc) +static void guc_ads_destroy (struct intel_guc *guc) {i915_vma_unpin_and_release (&guc->ads_vma); }
@@ -1050,7 +1057,7 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)if (ret <0 ) goto err_vaddr; - ret =guc_addon_create (guc); + ret =guc_ads_create (guc);if (ret <0 ) goto err_log;
@@ -1069,7 +1076,7 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)return 0 ; err_ads: -guc_addon_destroy (guc); +guc_ads_destroy (guc); err_log:intel_guc_log_destroy (guc); err_vaddr:
@@ -1089,7 +1096,7 @@ void i915_guc_submission_fini(struct drm_i915_private *dev_priv)guc_client_free (guc->execbuf_client); guc->execbuf_client =NULL ;ida_destroy (&guc->ctx_ids); -guc_addon_destroy (guc); +guc_ads_destroy (guc);intel_guc_log_destroy (guc);i915_gem_object_unpin_map (guc->ctx_pool->obj);i915_vma_unpin_and_release (&guc->ctx_pool);
drivers/gpu/drm/i915/intel_guc_loader.c +4 -6
@@ -148,17 +148,15 @@ static void guc_params_init(struct drm_i915_private *dev_priv) }else params[GUC_CTL_DEBUG ] =GUC_LOG_DISABLED ; -if (guc->ads_vma) { -u32 ads =guc_ggtt_offset (guc->ads_vma) >>PAGE_SHIFT ; - params[GUC_CTL_DEBUG ] |= ads <<GUC_ADS_ADDR_SHIFT ; - params[GUC_CTL_DEBUG ] |=GUC_ADS_ENABLED ; - } -/* If GuC submission is enabled, set up additional parameters here */ if (i915.enable_guc_submission) { +u32 ads =guc_ggtt_offset (guc->ads_vma) >>PAGE_SHIFT ;u32 pgs =guc_ggtt_offset (dev_priv->guc.ctx_pool);u32 ctx_in_16 =GUC_MAX_GPU_CONTEXTS /16 ; + params[GUC_CTL_DEBUG ] |= ads <<GUC_ADS_ADDR_SHIFT ; + params[GUC_CTL_DEBUG ] |=GUC_ADS_ENABLED ; + pgs >>=PAGE_SHIFT ; params[GUC_CTL_CTXINFO ] = (pgs <<GUC_CTL_BASE_ADDR_SHIFT ) | (ctx_in_16 <<GUC_CTL_CTXNUM_IN16_SHIFT );
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/12] drm/i915/guc: The Additional Data Struct (ADS) should get enabled together with GuC submission
Quoted 2 lines · Oscar Mateo
It's mandatory and it gets created if and only if GuC submission is enabled, so that should be the condition for informing the GuC about it.
This is true now, but GuC might actually require the ADS even if GuC submission is disabled, depending on the features being used. In the future we might therefore want to gate ADS logic based on the value of guc_loading instead of guc_submission.
This change is coherent with the current flow and makes things cleaner, so:
Quoted 7 lines
Also s/guc_addon_create/guc_ads_create and s/guc_addon_destroy/guc_ads_destroy and, while at it, add an explanation of what things go inside the ADS object.
Cc Daniele Ceraolo Spurio <[email protected]>Cc Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/12 drm/i915/guc: Break out the GuC log extras into their own "runtime" struct
In reply to Oscar MateoWhen initializing the GuC log struct, there is an object we need to allocate always, since the GuC needs its address at fw load time. The rest is only needed during runtime, in the sense that we only create if we actually enable GuC logging. Make that distinction explicit by subdividing further the intel_guc_log struct.
v2: Call the new struct "runtime", instead of "extras" (Joonas)
v3: Check indent (Joonas)
--- drivers/gpu/drm/i915/i915_irq.c | 4 +- drivers/gpu/drm/i915/intel_guc_log.c | 72 ++++++++++++++++++------------------ drivers/gpu/drm/i915/intel_uc.h | 12 +++--- 3 files changed, 45 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -1741,8 +1741,8 @@ static void gen9_guc_irq_handler(struct drm_i915_private *dev_priv, u32 gt_iir)I915_WRITE (SOFT_SCRATCH (15 ), msg & ~flush);/* Handle flush interrupt in bottom half */ -queue_work (dev_priv->guc.log.flush_wq, - &dev_priv->guc.log.flush_work); +queue_work (dev_priv->guc.log.runtime.flush_wq, + &dev_priv->guc.log.runtime.flush_work); dev_priv->guc.log.flush_interrupt_count++; }else {
drivers/gpu/drm/i915/intel_guc_log.c +36 -36
202 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.h +7 -5
@@ -132,11 +132,13 @@ struct intel_uc_fw {struct intel_guc_log {uint32_t flags;struct i915_vma *vma; -void *buf_addr; -struct workqueue_struct *flush_wq; -struct work_struct flush_work; -struct rchan *relay_chan; - +/* The runtime stuff gets created only when GuC logging gets enabled */ +struct { +void *buf_addr; +struct workqueue_struct *flush_wq; +struct work_struct flush_work; +struct rchan *relay_chan; + } runtime;/* logging related stats */ u32 capture_miss_count;u32 flush_interrupt_count;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/12 drm/i915/guc: Make intel_guc_send a function pointer
In reply to Oscar MateoPrepare for an alternate GuC communication interface.
v2: Make a few functions static and name them correctly while we are at it (Oscar), but leave an intel_guc_send_mmio interface for users that require old-style communication.
v3: Send intel_uc_init_early back to the top (Michal).
--- drivers/gpu/drm/i915/intel_uc.c | 16 +++++++++++----- drivers/gpu/drm/i915/intel_uc.h | 9 ++++++++- 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_uc.c +11 -5
@@ -83,7 +83,10 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)void intel_uc_init_early (struct drm_i915_private *dev_priv) { -mutex_init (&dev_priv->guc.send_mutex); +struct intel_guc *guc = &dev_priv->guc; + +mutex_init (&guc->send_mutex); + guc->send = intel_guc_send_mmio; }void intel_uc_init_fw (struct drm_i915_private *dev_priv)
@@ -216,7 +219,7 @@ void intel_uc_fini_hw(struct drm_i915_private *dev_priv)* Read GuC command/status register (SOFT_SCRATCH_0) * Return true if it contains a response rather than a command */ -static bool intel_guc_recv (struct intel_guc *guc,u32 *status) +static bool guc_recv (struct intel_guc *guc,u32 *status) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);
@@ -225,7 +228,10 @@ static bool intel_guc_recv(struct intel_guc *guc, u32 *status)return INTEL_GUC_RECV_IS_RESPONSE (val); } -int intel_guc_send (struct intel_guc *guc,const u32 *action,u32 len) +/* +* This function implements the MMIO based host to GuC interface. +*/ +int intel_guc_send_mmio (struct intel_guc *guc,const u32 *action,u32 len) {struct drm_i915_private *dev_priv =guc_to_i915 (guc);u32 status;
@@ -253,9 +259,9 @@ int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)* up to that length of time, then switch to a slower sleep-wait loop. * No inte_guc_send command should ever take longer than 10ms. */ - ret =wait_for_us (intel_guc_recv (guc, &status),10 ); + ret =wait_for_us (guc_recv (guc, &status),10 );if (ret) - ret =wait_for (intel_guc_recv (guc, &status),10 ); + ret =wait_for (guc_recv (guc, &status),10 );if (status !=INTEL_GUC_STATUS_SUCCESS ) {/* * Either the GuC explicitly returned an error (which
drivers/gpu/drm/i915/intel_uc.h +8 -1
@@ -176,6 +176,9 @@ struct intel_guc {/* To serialize the intel_guc_send actions */ struct mutex send_mutex; + +/* GuC's FW specific send function */ +int (*send)(struct intel_guc *guc,const u32 *data,u32 len); };struct intel_huc {
@@ -194,8 +197,12 @@ struct intel_huc {void intel_uc_fini_hw (struct drm_i915_private *dev_priv);void intel_uc_prepare_fw (struct drm_i915_private *dev_priv,struct intel_uc_fw *uc_fw); -int intel_guc_send (struct intel_guc *guc,const u32 *action,u32 len);int intel_guc_sample_forcewake (struct intel_guc *guc); +int intel_guc_send_mmio (struct intel_guc *guc,const u32 *action,u32 len); +static inline int intel_guc_send (struct intel_guc *guc,const u32 *action,u32 len) +{ +return guc->send (guc, action, len); +}/* intel_guc_loader.c */ int intel_guc_select_fw (struct intel_guc *guc);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/12 drm/i915/guc: Improve the GuC documentation & comments about proxy submissions
In reply to Oscar MateoWhile at it, fix a typo (s/ring_lcra/ring_lrca) and improve the naming of one firware interface field (s/ring_tail/submit_element_info, since it can contain more than just the ring tail).
No change in functionality.
v2:
- Remove reference to "unique user" of the GuC (Daniele)
- Keep mention to renaming from "GuC context" to "client" (Daniele)
--- drivers/gpu/drm/i915/i915_guc_submission.c | 42 +++++++++++++++++++----------- drivers/gpu/drm/i915/intel_guc_fwif.h | 4 +-- drivers/gpu/drm/i915/intel_uc.h | 6 +++-- 3 files changed, 33 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +27 -15
@@ -30,16 +30,25 @@/** * DOC: GuC-based command submission * -* i915_guc_client: -* We use the term client to avoid confusion with contexts. A i915_guc_client is -* equivalent to GuC object guc_context_desc. This context descriptor is -* allocated from a pool of 1024 entries. Kernel driver will allocate doorbell -* and workqueue for it. Also the process descriptor (guc_process_desc), which -* is mapped to client space. So the client can write Work Item then ring the -* doorbell. +* GuC client: +* A i915_guc_client refers to a submission path through GuC. Currently, there +* is only one of these (the execbuf_client) and this one is charged with all +* submissions to the GuC. This struct is the owner of a doorbell, a process +* descriptor and a workqueue (all of them inside a single gem object that +* contains all required pages for these elements). * -* To simplify the implementation, we allocate one gem object that contains all -* pages for doorbell, process descriptor and workqueue. +* GuC context descriptor: +* During initialization, the driver allocates a static pool of 1024 such +* descriptors, and shares them with the GuC. +* Currently, there exists a 1:1 mapping between a i915_guc_client and a +* guc_context_desc (via the client's context_index), so effectively only +* one guc_context_desc gets used. This context descriptor lets the GuC know +* about the doorbell, workqueue and process descriptor. Theoretically, it also +* lets the GuC know about our HW contexts (Context ID, etc...), but we actually +* employ a kind of submission where the GuC uses the LRCA sent via the work +* item instead (the single guc_context_desc associated to execbuf client +* contains information about the default kernel context only, but this is +* essentially unused). This is called a "proxy" submission. * * The Scratch registers: * There are 16 MMIO-based registers start from 0xC180. The kernel driver writes
@@ -308,10 +317,17 @@ static void guc_ctx_desc_init(struct intel_guc *guc,if (!ce->state)break ;/* XXX: continue? */ +/* +* XXX: When this is a GUC_CTX_DESC_ATTR_KERNEL client (proxy +* submission or, in other words, not using a direct submission +* model) the KMD's LRCA is not used for any work submission. +* Instead, the GuC uses the LRCA of the user mode context (see +* guc_wq_item_append below). +*/ lrc->context_desc =lower_32_bits (ce->lrc_desc);/* The state page is after PPHWSP */ - lrc->ring_lcra = + lrc->ring_lrca =guc_ggtt_offset (ce->state) +LRC_STATE_PN *PAGE_SIZE ; lrc->context_id = (client->ctx_index <<GUC_ELC_CTXID_OFFSET ) | (guc_engine_id <<GUC_ELC_ENGINE_OFFSET );
@@ -341,10 +357,6 @@ static void guc_ctx_desc_init(struct intel_guc *guc, desc->wq_addr = gfx_addr + client->wq_offset; desc->wq_size = client->wq_size; -/* -* XXX: Take LRCs from an existing context if this is not an -* IsKMDCreatedContext client -*/ desc->desc_private = (uintptr_t )client; }
@@ -468,7 +480,7 @@ static void guc_wq_item_append(struct i915_guc_client *client,/* The GuC wants only the low-order word of the context descriptor */ wqi->context_desc = (u32 )intel_lr_context_descriptor (rq->ctx, engine); - wqi->ring_tail = tail <<WQ_RING_TAIL_SHIFT ; + wqi->submit_element_info = tail <<WQ_RING_TAIL_SHIFT ; wqi->fence_id = rq->global_seqno; }
drivers/gpu/drm/i915/intel_guc_fwif.h +2 -2
@@ -251,7 +251,7 @@ struct guc_doorbell_info {struct guc_wq_item {u32 header;u32 context_desc; -u32 ring_tail; +u32 submit_element_info;u32 fence_id; } __packed;
@@ -278,7 +278,7 @@ struct guc_execlist_context {u32 context_desc;u32 context_id;u32 ring_status; -u32 ring_lcra; +u32 ring_lrca;u32 ring_begin;u32 ring_end;u32 ring_next_free_location;
drivers/gpu/drm/i915/intel_uc.h +4 -2
@@ -34,7 +34,9 @@/* * This structure primarily describes the GEM object shared with the GuC. -* The GEM object is held for the entire lifetime of our interaction with +* The specs sometimes refer to this object as a "GuC context", but we use +* the term "client" to avoid confusion with hardware contexts. This +* GEM object is held for the entire lifetime of our interaction with * the GuC, being allocated before the GuC is loaded with its firmware. * Because there's no way to update the address used by the GuC after * initialisation, the shared object must stay pinned into the GGTT as
@@ -44,7 +46,7 @@* * The single GEM object described here is actually made up of several * separate areas, as far as the GuC is concerned. The first page (kept -* kmap'd) includes the "process decriptor" which holds sequence data for +* kmap'd) includes the "process descriptor" which holds sequence data for * the doorbell, and one cacheline which actually *is* the doorbell; a * write to this will "ring the doorbell" (i.e. send an interrupt to the * GuC). The subsequent pages of the client object constitute the work
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/12] drm/i915/guc: Improve the GuC documentation & comments about proxy submissions
Quoted 4 lines · Oscar Mateo
While at it, fix a typo (s/ring_lcra/ring_lrca) and improve the naming of one firware interface field (s/ring_tail/submit_element_info, since it can contain more than just the ring tail).
Quoted 8 lines
No change in functionality.
v2:
- Remove reference to "unique user" of the GuC (Daniele)
- Keep mention to renaming from "GuC context" to "client" (Daniele)Cc Daniele Ceraolo Spurio <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
Thanks,
Daniele
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/12 drm/i915/guc: Wait for doorbell to be inactive before deallocating
In reply to Oscar MateoDoorbell release flow requires that we wait for GEN8_DRB_VALID bit to go to zero after updating db_status before we call the GuC to release the doorbell.
Kudos to Daniele for finding this out.
v2: WARN instead of DRM_ERROR (Joonas)
--- drivers/gpu/drm/i915/i915_guc_submission.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_guc_submission.c +10 -0
@@ -206,12 +206,22 @@ static int __create_doorbell(struct i915_guc_client *client)static int __destroy_doorbell (struct i915_guc_client *client) { +struct drm_i915_private *dev_priv =guc_to_i915 (client->guc);struct guc_doorbell_info *doorbell; +u16 db_id = client->doorbell_id; + +GEM_BUG_ON (db_id >=GUC_DOORBELL_INVALID ); doorbell =__get_doorbell (client); doorbell->db_status =GUC_DOORBELL_DISABLED ; doorbell->cookie =0 ; +/* Doorbell release flow requires that we wait for GEN8_DRB_VALID bit +* to go to zero after updating db_status before we call the GuC to +* release the doorbell */ +if (wait_for_us (!(I915_READ (GEN8_DRBREGL (db_id)) &GEN8_DRB_VALID ),10 )) +WARN_ONCE (true,"Doorbell never became invalid after disable\n" ); +return __guc_deallocate_doorbell (client->guc, client->ctx_index); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/12] drm/i915/guc: Wait for doorbell to be inactive before deallocating
Quoted 11 lines · Oscar Mateo
Doorbell release flow requires that we wait for
GEN8_DRB_VALIDbit to go to zero after updatingdb_statusbefore we call the GuC to release the doorbell.Kudos to Daniele for finding this out.
v2: WARN instead of
DRM_ERROR(Joonas)Cc Joonas Lahtinen <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
I'd like Joonas to give his ack on not returning after the wait since he commented on it in the previous version. I personally prefer it this way because we gain a bit more time for the doorbell to disable itself (there is no spec in regards to how long this should take, but it should be quick) while the GuC processes the H2G. If we ever see a case where the warn fires but the H2G is successful it would mean that we have to tune our wait time.
Thanks,
Daniele
Quoted 32 lines
--- drivers/gpu/drm/i915/i915_guc_submission.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/i915_guc_submission.c +10
-0@@ -206,12 +206,22 @@ static int __create_doorbell(struct i915_guc_client *client)static int __destroy_doorbell (struct i915_guc_client *client) { +struct drm_i915_private *dev_priv =guc_to_i915 (client->guc);struct guc_doorbell_info *doorbell; +u16 db_id = client->doorbell_id; + +GEM_BUG_ON (db_id >=GUC_DOORBELL_INVALID ); doorbell =__get_doorbell (client); doorbell->db_status =GUC_DOORBELL_DISABLED ; doorbell->cookie =0 ; +/* Doorbell release flow requires that we wait for GEN8_DRB_VALID bit +* to go to zero after updating db_status before we call the GuC to +* release the doorbell */ +if (wait_for_us (!(I915_READ (GEN8_DRBREGL (db_id)) &GEN8_DRB_VALID ),10 )) +WARN_ONCE (true,"Doorbell never became invalid after disable\n" ); +
Quoted 4 lines
return
__guc_deallocate_doorbell(client->guc, client->ctx_index);
}
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/12] drm/i915/guc: Wait for doorbell to be inactive before deallocating
Quoted 15 lines · Daniele
Quoted 11 lines · Oscar Mateo
Doorbell release flow requires that we wait for
GEN8_DRB_VALIDbit to go to zero after updatingdb_statusbefore we call the GuC to release the doorbell.Kudos to Daniele for finding this out.
v2: WARN instead of
DRM_ERROR(Joonas)Cc Joonas Lahtinen <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
Quoted 6 lines
Reviewed-by Daniele Ceraolo Spurio <[email protected]>I'd like Joonas to give his ack on not returning after the wait since he commented on it in the previous version. I personally prefer it this way because we gain a bit more time for the doorbell to disable itself (there is no spec in regards to how long this should take, but it should be quick) while the GuC processes the H2G. If we ever see a case where the warn fires but the H2G is successful it would mean that we have to tune our wait time.
Thanks,
Daniele
True. I went with his second option (WARN instead of DRM_ERROR) without asking him first...
Thanks,
-- Oscar
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/12] drm/i915/guc: Wait for doorbell to be inactive before deallocating
Quoted 3 lines · Oscar Mateo
True. I went with his second option (WARN instead of
DRM_ERROR) without asking him first...
Without knowing more of the innards of GuC, it's hard to say which will be more appropriate action. WARN should be enough for now.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/12 drm/i915/guc: A little bit more of doorbell sanitization
In reply to Oscar MateoSome recent refactoring patches have left the doorbell creation outside the GuC client allocation, which does not make a lot of sense (a client without a doorbell is something useless). Move it back there, and refactor the init_doorbell_hw consequently.
Thanks to this, we can do some other improvements, like hoisting the check for GuC submission enabled out of the enable function.
v2: Rebased.
--- drivers/gpu/drm/i915/i915_guc_submission.c | 231 ++++++++++++++++------------- drivers/gpu/drm/i915/intel_uc.c | 21 +-- 2 files changed, 138 insertions(+), 114 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +126 -105
@@ -162,15 +162,13 @@ static struct guc_context_desc *__get_context_desc(struct i915_guc_client *clien* client object which contains the page being used for the doorbell */ -static int __update_doorbell_desc (struct i915_guc_client *client,u16 new_id) +static void __update_doorbell_desc (struct i915_guc_client *client,u16 new_id) {struct guc_context_desc *desc;/* Update the GuC's idea of the doorbell ID */ desc =__get_context_desc (client); desc->db_id = new_id; - -return 0 ; }static struct guc_doorbell_info *__get_doorbell (struct i915_guc_client *client)
@@ -225,6 +223,28 @@ static int __destroy_doorbell(struct i915_guc_client *client)return __guc_deallocate_doorbell (client->guc, client->ctx_index); } +static int create_doorbell (struct i915_guc_client *client) +{ +int ret; + + ret =__reserve_doorbell (client); +if (ret) +return ret; + +__update_doorbell_desc (client, client->doorbell_id); + + ret =__create_doorbell (client); +if (ret) + goto err; + +return 0 ; + +err: +__update_doorbell_desc (client,GUC_DOORBELL_INVALID ); +__unreserve_doorbell (client); +return ret; +} +static int destroy_doorbell (struct i915_guc_client *client) {int err;
@@ -494,6 +514,17 @@ static void guc_wq_item_append(struct i915_guc_client *client, wqi->fence_id = rq->global_seqno; } +static void guc_reset_wq (struct i915_guc_client *client) +{ +struct guc_process_desc *desc = client->vaddr + + client->proc_desc_offset; + + desc->head =0 ; + desc->tail =0 ; + + client->wq_tail =0 ; +} +static int guc_ring_doorbell (struct i915_guc_client *client) {struct guc_process_desc *desc;
@@ -749,19 +780,6 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)return vma; } -static void guc_client_free (struct i915_guc_client *client) -{ -/* -* XXX: wait for any outstanding submissions before freeing memory. -* Be sure to drop any locks -*/ -guc_ctx_desc_fini (client->guc, client); -i915_gem_object_unpin_map (client->vma->obj); -i915_vma_unpin_and_release (&client->vma); -ida_simple_remove (&client->guc->ctx_ids, client->ctx_index); -kfree (client); -} -/* Check that a doorbell register is in the expected state */ static bool doorbell_ok (struct intel_guc *guc,u16 db_id) {
@@ -792,9 +810,8 @@ static int __reset_doorbell(struct i915_guc_client* client, u16 db_id) {int err; - err =__update_doorbell_desc (client, db_id); -if (!err) - err =__create_doorbell (client); +__update_doorbell_desc (client, db_id); + err =__create_doorbell (client);if (!err) err =__destroy_doorbell (client);
@@ -802,48 +819,61 @@ static int __reset_doorbell(struct i915_guc_client* client, u16 db_id) }/* -* Borrow the first client to set up & tear down each unused doorbell -* in turn, to ensure that all doorbell h/w is (re)initialised. +* Set up & tear down each unused doorbell in turn, to ensure that all doorbell +* HW is (re)initialised. For that end, we might have to borrow the first +* client. Also, tell GuC about all the doorbells in use by all clients. +* We do this because the KMD, the GuC and the doorbell HW can easily go out of +* sync (e.g. we can reset the GuC, but not the doorbel HW). */ static int guc_init_doorbell_hw (struct intel_guc *guc) {struct i915_guc_client *client = guc->execbuf_client; -int err; -int i; - -if (has_doorbell (client)) -destroy_doorbell (client); +bool recreate_first_client = false; +u16 db_id; +int ret; -for (i =0 ; i <GUC_NUM_DOORBELLS ; ++i) { -if (doorbell_ok (guc, i)) +/* For unused doorbells, make sure they are disabled */ +for_each_clear_bit (db_id, guc->doorbell_bitmap,GUC_NUM_DOORBELLS ) { +if (doorbell_ok (guc, db_id))continue ; - err =__reset_doorbell (client, i); -WARN (err,"Doorbell %d reset failed, err %d\n" , i, err); +if (has_doorbell (client)) { +/* Borrow execbuf_client (we will recreate it later) */ +destroy_doorbell (client); + recreate_first_client = true; + } + + ret =__reset_doorbell (client, db_id); +WARN (ret,"Doorbell %u reset failed, err %d\n" , db_id, ret); } -/* Read back & verify all doorbell registers */ -for (i =0 ; i <GUC_NUM_DOORBELLS ; ++i) -WARN_ON (!doorbell_ok (guc, i)); +if (recreate_first_client) { + ret =__reserve_doorbell (client); +if (unlikely (ret)) { +DRM_ERROR ("Couldn't re-reserve first client db: %d\n" , ret); +return ret; + } - err =__reserve_doorbell (client); -if (err) -return err; +__update_doorbell_desc (client, client->doorbell_id); + } - err =__update_doorbell_desc (client, client->doorbell_id); -if (err) - goto err_reserve; +/* Now for every client (and not only execbuf_client) make sure their +* doorbells are known by the GuC */ +//for (client = client_list; client != NULL; client = client->next) + { + ret =__create_doorbell (client); +if (ret) { +DRM_ERROR ("Couldn't recreate client %u doorbell: %d\n" , + client->ctx_index, ret); +return ret; + } + } - err =__create_doorbell (client); -if (err) - goto err_update; +/* Read back & verify all (used & unused) doorbell registers */ +for (db_id =0 ; db_id <GUC_NUM_DOORBELLS ; ++db_id) +WARN_ON (!doorbell_ok (guc, db_id));return 0 ; -err_reserve: -__unreserve_doorbell (client); -err_update: -__update_doorbell_desc (client,GUC_DOORBELL_INVALID ); -return err; }/**
@@ -923,11 +953,9 @@ static int guc_init_doorbell_hw(struct intel_guc *guc)guc_proc_desc_init (guc, client);guc_ctx_desc_init (guc, client); -/* FIXME: Runtime client allocation (which currently we don't do) will -* require that the doorbell gets created now. The static execbuf_client -* is now getting its doorbell later (on submission enable) but maybe we -* also want to reorder things in the future so that we don't have to -* special case the doorbell creation */ + ret =create_doorbell (client); +if (ret) + goto err_vaddr;DRM_DEBUG_DRIVER ("new priority %u client %p for engine(s) 0x%x: ctx_index %u\n" , priority, client, client->engines, client->ctx_index);
@@ -935,6 +963,9 @@ static int guc_init_doorbell_hw(struct intel_guc *guc) client->doorbell_id, client->doorbell_offset);return client; + +err_vaddr: +i915_gem_object_unpin_map (client->vma->obj); err_vma:i915_vma_unpin_and_release (&client->vma); err_id:
@@ -944,6 +975,24 @@ static int guc_init_doorbell_hw(struct intel_guc *guc)return ERR_PTR (ret); } +static void guc_client_free (struct i915_guc_client *client) +{ +/* +* XXX: wait for any outstanding submissions before freeing memory. +* Be sure to drop any locks +*/ + +/* FIXME: in many cases, by the time we get here the GuC has been +* reset, so we cannot destroy the doorbell properly. Ignore the +* error message for now */ +destroy_doorbell (client); +guc_ctx_desc_fini (client->guc, client); +i915_gem_object_unpin_map (client->vma->obj); +i915_vma_unpin_and_release (&client->vma); +ida_simple_remove (&client->guc->ctx_ids, client->ctx_index); +kfree (client); +} +static void guc_policies_init (struct guc_policies *policies) {struct guc_policy *policy;
@@ -1035,8 +1084,8 @@ static void guc_ads_destroy(struct intel_guc *guc) }/* -* Set up the memory resources to be shared with the GuC. At this point, -* we require just one object that can be mapped through the GGTT. +* Set up the memory resources to be shared with the GuC (via the GGTT) +* at firmware loading time. */ int i915_guc_submission_init (struct drm_i915_private *dev_priv) {
@@ -1048,16 +1097,6 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)void *vaddr;int ret; -if (!HAS_GUC_SCHED (dev_priv)) -return 0 ; - -/* Wipe bitmap & delete client in case of reinitialisation */ -bitmap_clear (guc->doorbell_bitmap,0 ,GUC_NUM_DOORBELLS ); -i915_guc_submission_disable (dev_priv); - -if (!i915.enable_guc_submission) -return 0 ; -if (guc->ctx_pool)return 0 ;
@@ -1085,20 +1124,8 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)ida_init (&guc->ctx_ids); - guc->execbuf_client =guc_client_alloc (dev_priv, -INTEL_INFO (dev_priv)->ring_mask, -GUC_CTX_PRIORITY_KMD_NORMAL , - dev_priv->kernel_context); -if (IS_ERR (guc->execbuf_client)) { -DRM_ERROR ("Failed to create GuC client for execbuf!\n" ); - ret =PTR_ERR (guc->execbuf_client); - goto err_ads; - } -return 0 ; -err_ads: -guc_ads_destroy (guc); err_log:intel_guc_log_destroy (guc); err_vaddr:
@@ -1112,11 +1139,6 @@ void i915_guc_submission_fini(struct drm_i915_private *dev_priv) {struct intel_guc *guc = &dev_priv->guc; -if (!i915.enable_guc_submission) -return 0 ; - -guc_client_free (guc->execbuf_client); - guc->execbuf_client =NULL ;ida_destroy (&guc->ctx_ids);guc_ads_destroy (guc);intel_guc_log_destroy (guc);
@@ -1124,17 +1146,6 @@ void i915_guc_submission_fini(struct drm_i915_private *dev_priv)i915_vma_unpin_and_release (&guc->ctx_pool); } -static void guc_reset_wq (struct i915_guc_client *client) -{ -struct guc_process_desc *desc = client->vaddr + - client->proc_desc_offset; - - desc->head =0 ; - desc->tail =0 ; - - client->wq_tail =0 ; -} -static void guc_interrupts_capture (struct drm_i915_private *dev_priv) {struct intel_engine_cs *engine;
@@ -1185,17 +1196,28 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)enum intel_engine_id id;int err; -if (!client) -return -ENODEV ; +if (!client) { + client =guc_client_alloc (dev_priv, +INTEL_INFO (dev_priv)->ring_mask, +GUC_CTX_PRIORITY_KMD_NORMAL , + dev_priv->kernel_context); +if (IS_ERR (client)) { +DRM_ERROR ("Failed to create GuC client for execbuf!\n" ); +return PTR_ERR (client); + } + + guc->execbuf_client = client; + } err =intel_guc_sample_forcewake (guc);if (err) -return err; + goto err_execbuf_client;guc_reset_wq (client); + err =guc_init_doorbell_hw (guc);if (err) -return err; + goto err_execbuf_client;/* Take over from manual control of ELSP (execlists) */ guc_interrupts_capture (dev_priv);
@@ -1222,6 +1244,11 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv) }return 0 ; + +err_execbuf_client: +guc_client_free (guc->execbuf_client); + guc->execbuf_client =NULL ; +return err; }static void guc_interrupts_release (struct drm_i915_private *dev_priv)
@@ -1254,16 +1281,11 @@ void i915_guc_submission_disable(struct drm_i915_private *dev_priv)guc_interrupts_release (dev_priv); -if (!guc->execbuf_client) -return ; - -/* FIXME: in many cases, by the time we get here the GuC has been -* reset, so we cannot destroy the doorbell properly. Ignore the -* error message for now */ -destroy_doorbell (guc->execbuf_client); -/* Revert back to manual ELSP submission */ intel_engines_reset_default_submission (dev_priv); + +guc_client_free (guc->execbuf_client); + guc->execbuf_client =NULL ; }/**
@@ -1292,7 +1314,6 @@ int intel_guc_suspend(struct drm_i915_private *dev_priv)return intel_guc_send (guc, data,ARRAY_SIZE (data)); } -/** * intel_guc_resume() - notify GuC resuming from suspend state * @dev_priv: i915 device private
drivers/gpu/drm/i915/intel_uc.c +12 -9
@@ -126,13 +126,15 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)/* We need to notify the guc whenever we change the GGTT */ i915_ggtt_enable_guc (dev_priv); -/* -* This is stuff we need to have available at fw load time -* if we are planning to enable submission later -*/ - ret =i915_guc_submission_init (dev_priv); -if (ret) - goto err_guc; +if (i915.enable_guc_submission) { +/* +* This is stuff we need to have available at fw load time +* if we are planning to enable submission later +*/ + ret =i915_guc_submission_init (dev_priv); +if (ret) + goto err_guc; + }/* WaEnableuKernelHeaderValidFix:skl */ /* WaEnableGuCBootHashCheckNotSet:skl,bxt,kbl */
@@ -187,7 +189,8 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv) err_interrupts:gen9_disable_guc_interrupts (dev_priv); err_submission: -i915_guc_submission_fini (dev_priv); +if (i915.enable_guc_submission) +i915_guc_submission_fini (dev_priv); err_guc:i915_ggtt_disable_guc (dev_priv);
@@ -210,8 +213,8 @@ void intel_uc_fini_hw(struct drm_i915_private *dev_priv)if (i915.enable_guc_submission) {i915_guc_submission_disable (dev_priv);gen9_disable_guc_interrupts (dev_priv); +i915_guc_submission_fini (dev_priv); } -i915_guc_submission_fini (dev_priv);i915_ggtt_disable_guc (dev_priv); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/12 drm/i915/guc: Refactor the concept "GuC context descriptor" into "GuC stage descriptor"
In reply to Oscar MateoA GuC context and a HW context are in no way related, so the name "GuC context descriptor" is very unfortunate, because a new reader of the code gets overwhelmed very quickly with a lot of things called "context" that refer to different things. We can improve legibility a lot by simply renaming a few objects in the GuC code.
v2:
- Rebased
- s/ctx_desc_pool/stage_desc_pool
- Move some explanations to the definition of the guc_stage_desc struct (Chris)
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 +- drivers/gpu/drm/i915/i915_guc_submission.c | 115 +++++++++++++++-------------- drivers/gpu/drm/i915/intel_guc_fwif.h | 48 +++++++----- drivers/gpu/drm/i915/intel_guc_loader.c | 4 +- drivers/gpu/drm/i915/intel_uc.h | 8 +- 5 files changed, 95 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -2474,8 +2474,8 @@ static void i915_guc_client_info(struct seq_file *m,enum intel_engine_id id;uint64_t tot =0 ; -seq_printf (m,"\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n" , - client->priority, client->ctx_index, client->proc_desc_offset); +seq_printf (m,"\tPriority %d, GuC stage index: %u, PD offset 0x%x\n" , + client->priority, client->stage_id, client->proc_desc_offset);seq_printf (m,"\tDoorbell id %d, offset: 0x%lx, cookie 0x%x\n" , client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
drivers/gpu/drm/i915/i915_guc_submission.c +59 -56
324 lines not on this page · raw message
drivers/gpu/drm/i915/intel_guc_fwif.h +28 -20
80 lines not on this page · raw message
drivers/gpu/drm/i915/intel_guc_loader.c +2 -2
@@ -151,8 +151,8 @@ static void guc_params_init(struct drm_i915_private *dev_priv)/* If GuC submission is enabled, set up additional parameters here */ if (i915.enable_guc_submission) {u32 ads =guc_ggtt_offset (guc->ads_vma) >>PAGE_SHIFT ; -u32 pgs =guc_ggtt_offset (dev_priv->guc.ctx_pool); -u32 ctx_in_16 =GUC_MAX_GPU_CONTEXTS /16 ; +u32 pgs =guc_ggtt_offset (dev_priv->guc.stage_desc_pool); +u32 ctx_in_16 =GUC_MAX_STAGE_DESCRIPTORS /16 ; params[GUC_CTL_DEBUG ] |= ads <<GUC_ADS_ADDR_SHIFT ; params[GUC_CTL_DEBUG ] |=GUC_ADS_ENABLED ;
drivers/gpu/drm/i915/intel_uc.h +4 -4
@@ -74,7 +74,7 @@ struct i915_guc_client {uint32_t engines;/* bitmap of (host) engine ids */ uint32_t priority; -u32 ctx_index; +u32 stage_id;uint32_t proc_desc_offset;u16 doorbell_id;
@@ -157,9 +157,9 @@ struct intel_guc {bool interrupts_enabled;struct i915_vma *ads_vma; -struct i915_vma *ctx_pool; -void *ctx_pool_vaddr; -struct ida ctx_ids; +struct i915_vma *stage_desc_pool; +void *stage_desc_pool_vaddr; +struct ida stage_ids;struct i915_guc_client *execbuf_client;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 10/12] drm/i915/guc: Refactor the concept "GuC context descriptor" into "GuC stage descriptor"
Quoted 10 lines · Oscar Mateo
A GuC context and a HW context are in no way related, so the name "GuC context descriptor" is very unfortunate, because a new reader of the code gets overwhelmed very quickly with a lot of things called "context" that refer to different things. We can improve legibility a lot by simply renaming a few objects in the GuC code.
v2:
- Rebased
- s/ctx_desc_pool/stage_desc_pool
- Move some explanations to the definition of theguc_stage_descstruct (Chris)
Quoted 4 lines
Cc Chris Wilson <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
<SNIP>
drivers/gpu/drm/i915/i915_guc_submission.c static void __unreserve_doorbell(struct i915_guc_client *client) · line 155
Quoted 7 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-1-static struct guc_context_desc *__get_context_desc (struct i915_guc_client *client) +static struct guc_stage_desc *__get_stage_desc (struct i915_guc_client *client){
drivers/gpu/drm/i915/i915_guc_submission.c +2
-2-return (struct guc_context_desc *)((char *)client->guc->ctx_pool_vaddr + -sizeof (struct guc_context_desc ) * client->ctx_index); +return (struct guc_stage_desc *)((char *)client->guc->stage_desc_pool_vaddr + +sizeof (struct guc_stage_desc ) * client->stage_id);
Am I missing something or isn't this just a hard way of doing;
struct guc_stage_desc *stage_descs = client->guc->stage_desc_pool_vaddr; return &stage_descs[client->stage_id];
(+/- fixing sparse warnings, if any)
Quoted 2 lines
}
<SNIP>
drivers/gpu/drm/i915/i915_guc_submission.c static void guc_ads_destroy(struct intel_guc *guc) · line 1095
Quoted 7 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-2@@ -1089,30 +1092,30 @@ static void guc_ads_destroy(struct intel_guc *guc)*/ int i915_guc_submission_init(struct drm_i915_private *dev_priv) { -const size_t ctxsize =sizeof (struct guc_context_desc ); -const size_t poolsize =GUC_MAX_GPU_CONTEXTS * ctxsize; +const size_t ctxsize =sizeof (struct guc_stage_desc );
I was about to comment to rename ctxsize -> stagesize, but;
drivers/gpu/drm/i915/i915_guc_submission.c static void guc_ads_destroy(struct intel_guc *guc) · line 1097
Quoted 2 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1
-0+const size_t poolsize =GUC_MAX_STAGE_DESCRIPTORS * ctxsize; const size_t gemsize = round_up(poolsize, PAGE_SIZE);
The above are only used once, so instead:
Quoted 10 lines
drivers/gpu/drm/i915/i915_guc_submission.c +0
-0struct intel_guc *guc = &dev_priv->guc; struct i915_vma *vma; void *vaddr; int ret;drivers/gpu/drm/i915/i915_guc_submission.c +1
-1-if (guc->ctx_pool) +if (guc->stage_desc_pool)return 0;
vma =intel_guc_allocate_vma(guc, gemsize);
Do
vma = intel_guc_allocate_vma(guc,
PAGE_ALIGN(sizeof(struct guc_stage_desc) *
GUC_MAX_GPU_CONTEXTS));
Quoted 2 lines
if (
IS_ERR(vma))
returnPTR_ERR(vma);
<SNIP>
Quoted 6 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +0
-6-#define GUC_CTX_DESC_ATTR_ACTIVE (1 << 0) -#define GUC_CTX_DESC_ATTR_PENDING_DB (1 << 1) -#define GUC_CTX_DESC_ATTR_KERNEL (1 << 2) -#define GUC_CTX_DESC_ATTR_PREEMPT (1 << 3) -#define GUC_CTX_DESC_ATTR_RESET (1 << 4) -#define GUC_CTX_DESC_ATTR_WQLOCKED (1 << 5)
drivers/gpu/drm/i915/intel_guc_fwif.h line 78
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +8
-2-#define GUC_CTX_DESC_ATTR_PCH (1 << 6) -#define GUC_CTX_DESC_ATTR_TERMINATED (1 << 7) +#define GUC_STAGE_DESC_ATTR_ACTIVE (1 << 0) +#define GUC_STAGE_DESC_ATTR_PENDING_DB (1 << 1) +#define GUC_STAGE_DESC_ATTR_KERNEL (1 << 2) +#define GUC_STAGE_DESC_ATTR_PREEMPT (1 << 3) +#define GUC_STAGE_DESC_ATTR_RESET (1 << 4) +#define GUC_STAGE_DESC_ATTR_WQLOCKED (1 << 5) +#define GUC_STAGE_DESC_ATTR_PCH (1 << 6) +#define GUC_STAGE_DESC_ATTR_TERMINATED (1 << 7)
While here, make 'em BIT()
With above, this is;
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/12 drm/i915/guc: Split out the mmio_white_list struct
In reply to Oscar MateoWe are going to need it for future platforms.
--- drivers/gpu/drm/i915/i915_guc_submission.c | 4 ++-- drivers/gpu/drm/i915/intel_guc_fwif.h | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +2 -2
@@ -1050,11 +1050,11 @@ static int guc_ads_create(struct intel_guc *guc)/* MMIO reg state */ for_each_engine (engine, dev_priv, id) { - blob->reg_state.mmio_white_list[engine->guc_id].mmio_start = + blob->reg_state.white_list[engine->guc_id].mmio_start = engine->mmio_base +GUC_MMIO_WHITE_LIST_START ;/* Nothing to be saved or restored for now. */ - blob->reg_state.mmio_white_list[engine->guc_id].count =0 ; + blob->reg_state.white_list[engine->guc_id].count =0 ; }/*
drivers/gpu/drm/i915/intel_guc_fwif.h +8 -7
@@ -409,16 +409,17 @@ struct guc_mmio_regset {u32 number_of_registers; } __packed; +/* MMIO registers that are set as non privileged */ +struct mmio_white_list { +u32 mmio_start; +u32 offsets[GUC_MMIO_WHITE_LIST_MAX ]; +u32 count; +} __packed; +struct guc_mmio_reg_state {struct guc_mmio_regset global_reg;struct guc_mmio_regset engine_reg[GUC_MAX_ENGINES_NUM ]; - -/* MMIO registers that are set as non privileged */ -struct __packed { -u32 mmio_start; -u32 offsets[GUC_MMIO_WHITE_LIST_MAX ]; -u32 count; - } mmio_white_list[GUC_MAX_ENGINES_NUM ]; +struct mmio_white_list white_list[GUC_MAX_ENGINES_NUM ]; } __packed;/* GuC Additional Data Struct */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/12] drm/i915/guc: Split out the mmio_white_list struct
Quoted 5 lines · Oscar Mateo
We are going to need it for future platforms.
Cc Daniele Ceraolo Spurio <[email protected]>Cc Joonas Lahtinen <[email protected]>Signed-off-by Oscar Mateo <[email protected]>
Thanks,
Daniele
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/12 drm/i915/guc: Move guc_interrupts_release next to guc_interrupts_capture
In reply to Oscar MateoThey go better together.
--- drivers/gpu/drm/i915/i915_guc_submission.c | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +24 -24
@@ -1191,6 +1191,30 @@ static void guc_interrupts_capture(struct drm_i915_private *dev_priv) dev_priv->rps.pm_intrmsk_mbz &= ~GEN8_PMINTR_DISABLE_REDIRECT_TO_GUC ; } +static void guc_interrupts_release (struct drm_i915_private *dev_priv) +{ +struct intel_engine_cs *engine; +enum intel_engine_id id; +int irqs; + +/* +* tell all command streamers NOT to forward interrupts or vblank +* to GuC. +*/ + irqs =_MASKED_FIELD (GFX_FORWARD_VBLANK_MASK ,GFX_FORWARD_VBLANK_NEVER ); + irqs |=_MASKED_BIT_DISABLE (GFX_INTERRUPT_STEERING ); +for_each_engine (engine, dev_priv, id) +I915_WRITE (RING_MODE_GEN7 (engine), irqs); + +/* route all GT interrupts to the host */ +I915_WRITE (GUC_BCS_RCS_IER ,0 ); +I915_WRITE (GUC_VCS2_VCS1_IER ,0 ); +I915_WRITE (GUC_WD_VECS_IER ,0 ); + + dev_priv->rps.pm_intrmsk_mbz |=GEN8_PMINTR_DISABLE_REDIRECT_TO_GUC ; + dev_priv->rps.pm_intrmsk_mbz &= ~ARAT_EXPIRED_INTRMSK ; +} +int i915_guc_submission_enable (struct drm_i915_private *dev_priv) {struct intel_guc *guc = &dev_priv->guc;
@@ -1254,30 +1278,6 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)return err; } -static void guc_interrupts_release (struct drm_i915_private *dev_priv) -{ -struct intel_engine_cs *engine; -enum intel_engine_id id; -int irqs; - -/* -* tell all command streamers NOT to forward interrupts or vblank -* to GuC. -*/ - irqs =_MASKED_FIELD (GFX_FORWARD_VBLANK_MASK ,GFX_FORWARD_VBLANK_NEVER ); - irqs |=_MASKED_BIT_DISABLE (GFX_INTERRUPT_STEERING ); -for_each_engine (engine, dev_priv, id) -I915_WRITE (RING_MODE_GEN7 (engine), irqs); - -/* route all GT interrupts to the host */ -I915_WRITE (GUC_BCS_RCS_IER ,0 ); -I915_WRITE (GUC_VCS2_VCS1_IER ,0 ); -I915_WRITE (GUC_WD_VECS_IER ,0 ); - - dev_priv->rps.pm_intrmsk_mbz |=GEN8_PMINTR_DISABLE_REDIRECT_TO_GUC ; - dev_priv->rps.pm_intrmsk_mbz &= ~ARAT_EXPIRED_INTRMSK ; -} -void i915_guc_submission_disable (struct drm_i915_private *dev_priv) {struct intel_guc *guc = &dev_priv->guc;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 12/12] drm/i915/guc: Move guc_interrupts_release next to guc_interrupts_capture
Quoted 1 line · Oscar Mateo
They go better together.
I agree :)
Thanks,
Daniele
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: warning for Various improvements around the GuC topic
In reply to Oscar Mateo== Series Details ==
== Series Details ==
Series: Various improvements around the GuC topic
URL : https://patchwork.freedesktop.org/series/21624/
State : warning
== Summary ==
Series 21624v1 Various improvements around the GuC topic
https://patchwork.freedesktop.org/api/1.0/series/21624/revisions/1/mbox/
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
fail -> PASS (fi-snb-2600) fdo#100007
Test gem_exec_suspend:
Subgroup basic-s4-devices:
dmesg-warn -> PASS (fi-bxt-t5700) fdo#100125
Test pm_rpm:
Subgroup basic-pci-d3-state:
pass -> DMESG-WARN (fi-bxt-j4205)fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fi-bdw-5557u total:278 pass:263 dwarn:0 dfail:0 fail:4 skip:11 time: 453s fi-bsw-n3050 total:278 pass:235 dwarn:0 dfail:0 fail:4 skip:39 time: 554s fi-bxt-j4205 total:278 pass:254 dwarn:1 dfail:0 fail:4 skip:19 time: 522s fi-bxt-t5700 total:278 pass:254 dwarn:0 dfail:0 fail:4 skip:20 time: 558s fi-byt-j1900 total:278 pass:247 dwarn:0 dfail:0 fail:4 skip:27 time: 494s fi-byt-n2820 total:278 pass:243 dwarn:0 dfail:0 fail:4 skip:31 time: 485s fi-hsw-4770 total:278 pass:258 dwarn:0 dfail:0 fail:4 skip:16 time: 432s fi-hsw-4770r total:278 pass:258 dwarn:0 dfail:0 fail:4 skip:16 time: 430s fi-ilk-650 total:278 pass:228 dwarn:0 dfail:0 fail:4 skip:46 time: 437s fi-ivb-3520m total:278 pass:256 dwarn:0 dfail:0 fail:4 skip:18 time: 516s fi-ivb-3770 total:278 pass:256 dwarn:0 dfail:0 fail:4 skip:18 time: 489s fi-kbl-7500u total:278 pass:256 dwarn:0 dfail:0 fail:4 skip:18 time: 481s fi-skl-6260u total:278 pass:264 dwarn:0 dfail:0 fail:4 skip:10 time: 469s fi-skl-6700hq total:278 pass:257 dwarn:0 dfail:0 fail:4 skip:17 time: 590s fi-skl-6700k total:278 pass:252 dwarn:4 dfail:0 fail:4 skip:18 time: 494s fi-skl-6770hq total:278 pass:264 dwarn:0 dfail:0 fail:4 skip:10 time: 513s fi-snb-2520m total:278 pass:246 dwarn:0 dfail:0 fail:4 skip:28 time: 542s fi-snb-2600 total:278 pass:245 dwarn:0 dfail:0 fail:4 skip:29 time: 412s
7035813558b7d9601c8fdda50498cf9f8d7f0f2b drm-tip: 2017y-03m-21d-15h-58m-46s UTC integration manifest 1b4ed14 drm/i915/guc: Move guc_interrupts_release next to guc_interrupts_capture b952000 drm/i915/guc: Split out the mmio_white_list struct
b8b653e drm/i915/guc: Refactor the concept "GuC context descriptor" into "GuC stage descriptor" 8ffda10 drm/i915/guc: A little bit more of doorbell sanitization
8f22f65 drm/i915/guc: Wait for doorbell to be inactive before deallocating
1362e1f drm/i915/guc: Improve the GuC documentation & comments about proxy submissions f3b3a7b drm/i915/guc: Make intel_guc_send a function pointer
68aaede drm/i915/guc: Break out the GuC log extras into their own "runtime" struct deb97d4 drm/i915/guc: The Additional Data Struct (ADS) should get enabled together with GuC submission c821db7 drm/i915/guc: Add onion teardown to the GuC setup
3abdc29 drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access
96f0f61 drm/i915/guc: Sanitize GuC client initialization
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4250/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: ✗ Fi.CI.BAT: warning for Various improvements around the GuC topic
Hi,
Do the small fixups I proposed (and correct patch 1 author ;) ) and resend this with the HAX patch at the end to enable GuC submission.
If it passes CI, it's good to merge assuming you did some sanity checking too.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx