Skip to contentSkip to conversation

Various improvements around the GuC topic

PATCH Superseded Oscar Mateo 3 participants 14 messages Feb 24, 2017 – Mar 8, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Various improvements around the GuC topic

They have been discussed in various threads, but I am putting them together as a series for clarity. These go on top of Joonas' "Sanitize GuC client initialization", so they cannot be merged until that patch goes thru (at that point, it is probably better if Joonas resends these as well).

Oscar Mateo (4):
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: s/ads_vma/addon
drm/i915/guc: Break out the GuC log "extras"

 drivers/gpu/drm/i915/i915_drv.c            |   7 +-
 drivers/gpu/drm/i915/i915_guc_submission.c | 181 +++++++-------
 drivers/gpu/drm/i915/i915_irq.c            |   4 +-
 drivers/gpu/drm/i915/intel_guc_loader.c    |  38 +--
 drivers/gpu/drm/i915/intel_guc_log.c       | 382 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_uc.h            |  25 +-
 6 files changed, 331 insertions(+), 306 deletions(-)
Signature · 6 lines
1.9.1

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

PATCH v3 1/4 drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access

The 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

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 95 +++++++++++++++---------------
 drivers/gpu/drm/i915/intel_guc_loader.c    |  2 +-
 drivers/gpu/drm/i915/intel_uc.h            |  3 +-
 3 files changed, 49 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +46 -49
index ed8d265..d5847e8 100644
@@ -134,6 +134,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 client->guc->ctx_pool_vaddr +
+		sizeof(struct guc_context_desc) * client->ctx_index;
+}
+
 /*
  * Initialise, update, or clear doorbell data shared with the GuC
  *
@@ -143,21 +149,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;
 }
@@ -270,29 +266,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
@@ -317,50 +312,41 @@ 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)client->vaddr + client->doorbell_offset;
-	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)client->vaddr +
+				client->doorbell_offset;
+	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;
+	struct guc_context_desc *desc;
 
-	memset(&desc, 0, sizeof(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));
 }
 
 /**
@@ -915,6 +901,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;
@@ -926,14 +913,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);
@@ -1025,9 +1019,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
index 9885f76..22f882d 100644
@@ -221,7 +221,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
index c80f470..511b96b 100644
@@ -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
maintainer Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH 1/4 v3] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access

Quoted 8 lines · Oscar Mateo

The 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/

Quoted 6 lines

v3: Zero out guc_context_desc before initialization

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

The first three patches would be rather ready for merging, right?

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
#3 lore raw

Re: [PATCH 1/4 v3] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access

Quoted 15 lines · Joonas Lahtinen
Quoted 8 lines · Oscar Mateo

The 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/

Quoted 6 lines

v3: Zero out guc_context_desc before initialization

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Quoted 5 lines

The first three patches would be rather ready for merging, right?

Regards, Joonas

Hmmmm... not really :(
They sit on top of your patch with the reworked doorbells, so there will be merge conflicts. Also, your comment regarding the log extras really belongs to the third patch (and while playing with GuC I have found another problem with this third patch). I believe I'll meet you IRL/AFK, so we can agree on a merge strategy then :)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH v2 2/4 drm/i915/guc: Add onion teardown to the GuC setup

In reply to Oscar Mateo

Starting 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)

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c            |   7 +-
 drivers/gpu/drm/i915/i915_guc_submission.c |  96 ++++----
 drivers/gpu/drm/i915/intel_guc_loader.c    |  32 +--
 drivers/gpu/drm/i915/intel_guc_log.c       | 360 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_uc.h            |   8 +-
 5 files changed, 262 insertions(+), 241 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +5 -2
index b76e8f7..0c2ee5f 100644
@@ -551,6 +551,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_submission)
+		intel_guc_cleanup(dev_priv);
 	i915_gem_cleanup_engines(dev_priv);
 	i915_gem_context_fini(dev_priv);
 	mutex_unlock(&dev_priv->drm.struct_mutex);
@@ -614,7 +616,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);
 
@@ -636,9 +638,10 @@ 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_irq:
+cleanup_uc:
 	intel_guc_fini(dev_priv);
 	intel_huc_fini(dev_priv);
+cleanup_irq:
 	drm_irq_uninstall(dev);
 	intel_teardown_gmbus(dev_priv);
 cleanup_csr:
drivers/gpu/drm/i915/i915_guc_submission.c +56 -40

178 lines not on this page · raw message

drivers/gpu/drm/i915/intel_guc_loader.c +17 -15
index 22f882d..1f9ec54 100644
@@ -489,7 +489,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 
 	err = i915_guc_submission_init(dev_priv);
 	if (err)
-		goto fail;
+		goto err_guc;
 
 	/*
 	 * WaEnableuKernelHeaderValidFix:skl,bxt
@@ -504,7 +504,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 		 */
 		err = guc_hw_reset(dev_priv);
 		if (err)
-			goto fail;
+			goto err_submission;
 
 		intel_huc_load(dev_priv);
 		err = guc_ucode_xfer(dev_priv);
@@ -512,7 +512,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 			break;
 
 		if (--retries == 0)
-			goto fail;
+			goto err_submission;
 
 		DRM_INFO("GuC fw load failed: %d; will reset and "
 			 "retry %d more time(s)\n", err, retries);
@@ -528,7 +528,7 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 
 		err = i915_guc_submission_enable(dev_priv);
 		if (err)
-			goto fail;
+			goto err_interrupts;
 		guc_interrupts_capture(dev_priv);
 	}
 
@@ -539,15 +539,16 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 
 	return 0;
 
+err_interrupts:
+	gen9_disable_guc_interrupts(dev_priv);
+err_submission:
+	i915_guc_submission_fini(dev_priv);
+err_guc:
+	i915_ggtt_disable_guc(dev_priv);
 fail:
 	if (guc_fw->load_status == INTEL_UC_FIRMWARE_PENDING)
 		guc_fw->load_status = INTEL_UC_FIRMWARE_FAIL;
 
-	guc_interrupts_release(dev_priv);
-	i915_guc_submission_disable(dev_priv);
-	i915_guc_submission_fini(dev_priv);
-	i915_ggtt_disable_guc(dev_priv);
-
 	/*
 	 * We've failed to load the firmware :(
 	 *
@@ -587,6 +588,13 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 	return ret;
 }
 
+void intel_guc_cleanup(struct drm_i915_private *dev_priv)
+{
+	gen9_disable_guc_interrupts(dev_priv);
+	i915_guc_submission_fini(dev_priv);
+	i915_ggtt_disable_guc(dev_priv);
+}
+
 void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
 			 struct intel_uc_fw *uc_fw)
 {
@@ -792,12 +800,6 @@ 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);
-	guc_interrupts_release(dev_priv);
-	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);
drivers/gpu/drm/i915/intel_guc_log.c +179 -181

451 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc.h +5 -3
index 511b96b..330d08f 100644
@@ -198,8 +198,9 @@ static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 l
 
 /* intel_guc_loader.c */
 extern void intel_guc_init(struct drm_i915_private *dev_priv);
-extern int intel_guc_setup(struct drm_i915_private *dev_priv);
 extern void intel_guc_fini(struct drm_i915_private *dev_priv);
+extern int intel_guc_setup(struct drm_i915_private *dev_priv);
+extern void intel_guc_cleanup(struct drm_i915_private *dev_priv);
 extern const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status);
 extern int intel_guc_suspend(struct drm_i915_private *dev_priv);
 extern int intel_guc_resume(struct drm_i915_private *dev_priv);
@@ -217,10 +218,11 @@ void intel_uc_fw_fetch(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
maintainer Reviewed-by on v2 2/4
#5 lore raw

Re: [PATCH 2/4 v2] drm/i915/guc: Add onion teardown to the GuC setup

Quoted 20 lines · Oscar Mateo

Starting 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)

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

<SNIP>

drivers/gpu/drm/i915/intel_guc_log.c static void capture_logs_work(struct work_struct *work) · line 354

Quoted 8 lines
(quoted diff) +0 -0
@@ -404,120 +348,105 @@ static void capture_logs_work(struct work_struct *work)
  	guc_log_capture_logs(guc);
  }

drivers/gpu/drm/i915/intel_guc_log.c +4 -0
+static bool guc_log_has_extras(struct intel_guc *guc)
+{
+	return (guc->log.buf_addr != NULL);
+}

brackets not needed.

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
#6 lore raw

PATCH 3/4 drm/i915/guc: s/ads_vma/addon

In reply to Oscar Mateo

This vma contains much more than just the additional data struct (ads) and since we were already using the word "addon" as an object in guc_addon_create, make it the preffered one. No need for the vma suffix either, as that dependency is given by the type.

while at it, add an explanation of what things go inside the addon object.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 12 ++++++++----
 drivers/gpu/drm/i915/intel_guc_loader.c    |  4 ++--
 drivers/gpu/drm/i915/intel_uc.h            |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +8 -4
index 7562343c..e1922fe 100644
@@ -834,9 +834,13 @@ static int guc_addon_create(struct intel_guc *guc)
 	struct page *page;
 	u32 size;
 
-	GEM_BUG_ON(guc->ads_vma);
+	GEM_BUG_ON(guc->addon);
 
-	/* The ads obj includes the struct itself and buffers passed to GuC */
+	/* The additional data struct (ADS) has pointers for different buffers
+	 * used by the GuC. The addon object contains the ADS 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 */
 	size = sizeof(struct guc_ads) + sizeof(struct guc_policies) +
 			sizeof(struct guc_mmio_reg_state) +
 			GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE;
@@ -845,7 +849,7 @@ static int guc_addon_create(struct intel_guc *guc)
 	if (IS_ERR(vma))
 		return PTR_ERR(vma);
 
-	guc->ads_vma = vma;
+	guc->addon = vma;
 
 	page = i915_vma_first_page(vma);
 	ads = kmap(page);
@@ -894,7 +898,7 @@ static int guc_addon_create(struct intel_guc *guc)
 
 static void guc_addon_destroy(struct intel_guc *guc)
 {
-	i915_vma_unpin_and_release(&guc->ads_vma);
+	i915_vma_unpin_and_release(&guc->addon);
 }
 
 /*
drivers/gpu/drm/i915/intel_guc_loader.c +2 -2
index 1f9ec54..1eb0c51 100644
@@ -213,8 +213,8 @@ 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;
+	if (guc->addon) {
+		u32 ads = guc_ggtt_offset(guc->addon) >> PAGE_SHIFT;
 		params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT;
 		params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED;
 	}
drivers/gpu/drm/i915/intel_uc.h +1 -1
index 330d08f..d8897b5 100644
@@ -152,7 +152,7 @@ struct intel_guc {
 	/* intel_guc_recv interrupt related state */
 	bool interrupts_enabled;
 
-	struct i915_vma *ads_vma;
+	struct i915_vma *addon;
 	struct i915_vma *ctx_pool;
 	void *ctx_pool_vaddr;
 	struct ida ctx_ids;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v1 3/4
#7 lore raw

Re: [PATCH 3/4] drm/i915/guc: s/ads_vma/addon

Quoted 10 lines · Oscar Mateo

This vma contains much more than just the additional data struct (ads) and since we were already using the word "addon" as an object in guc_addon_create, make it the preffered one. No need for the vma suffix either, as that dependency is given by the type.

while at it, add an explanation of what things go inside the addon object.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

<SNIP>

drivers/gpu/drm/i915/i915_guc_submission.c static int guc_addon_create(struct intel_guc *guc) · line 843

Quoted 13 lines
drivers/gpu/drm/i915/i915_guc_submission.c +0 -0
@@ -834,9 +834,13 @@ static int guc_addon_create(struct intel_guc *guc)
  	struct page *page;
  	u32 size;

drivers/gpu/drm/i915/i915_guc_submission.c +1 -1
-	GEM_BUG_ON(guc->ads_vma);
+	GEM_BUG_ON(guc->addon);

drivers/gpu/drm/i915/i915_guc_submission.c +5 -1
-	/* The ads obj includes the struct itself and buffers passed to GuC */
+	/* The additional data struct (ADS) has pointers for different buffers
+	 * used by the GuC. The addon object contains the ADS 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 */

Put this comment in the header and this is;

Quoted 3 lines

  size = sizeof(struct guc_ads) + sizeof(struct guc_policies) + sizeof(struct guc_mmio_reg_state) + GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE;

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
#8 lore raw

Re: [PATCH 3/4] drm/i915/guc: s/ads_vma/addon

In reply to Oscar Mateo
Quoted 4 lines · Oscar Mateo

This vma contains much more than just the additional data struct (ads) and since we were already using the word "addon" as an object in guc_addon_create, make it the preffered one. No need for the vma suffix either, as that dependency is given by the type.

Hmm, but almost all over the driver we're using "vma" as a name or suffix. Why do you want to change this here ?

Also, GUC still is using term "ADS" for this blob so I'm not convinced that we need new name here.

-Michal

Quoted 85 lines

while at it, add an explanation of what things go inside the addon object.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 12 ++++++++----
 drivers/gpu/drm/i915/intel_guc_loader.c    |  4 ++--
 drivers/gpu/drm/i915/intel_uc.h            |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +8 -4
index 7562343c..e1922fe 100644
@@ -834,9 +834,13 @@ static int guc_addon_create(struct intel_guc *guc)
 	struct page *page;
 	u32 size;
 
-	GEM_BUG_ON(guc->ads_vma);
+	GEM_BUG_ON(guc->addon);
 
-	/* The ads obj includes the struct itself and buffers passed to GuC */
+	/* The additional data struct (ADS) has pointers for different buffers
+	 * used by the GuC. The addon object contains the ADS 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 */
 	size = sizeof(struct guc_ads) + sizeof(struct guc_policies) +
 			sizeof(struct guc_mmio_reg_state) +
 			GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE;
@@ -845,7 +849,7 @@ static int guc_addon_create(struct intel_guc *guc)
 	if (IS_ERR(vma))
 		return PTR_ERR(vma);
 
-	guc->ads_vma = vma;
+	guc->addon = vma;
 
 	page = i915_vma_first_page(vma);
 	ads = kmap(page);
@@ -894,7 +898,7 @@ static int guc_addon_create(struct intel_guc *guc)
 
 static void guc_addon_destroy(struct intel_guc *guc)
 {
-	i915_vma_unpin_and_release(&guc->ads_vma);
+	i915_vma_unpin_and_release(&guc->addon);
 }
 
 /*
drivers/gpu/drm/i915/intel_guc_loader.c +2 -2
index 1f9ec54..1eb0c51 100644
@@ -213,8 +213,8 @@ 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;
+	if (guc->addon) {
+		u32 ads = guc_ggtt_offset(guc->addon) >> PAGE_SHIFT;
 		params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT;
 		params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED;
 	}
drivers/gpu/drm/i915/intel_uc.h +1 -1
index 330d08f..d8897b5 100644
@@ -152,7 +152,7 @@ struct intel_guc {
 	/* intel_guc_recv interrupt related state */
 	bool interrupts_enabled;
 
-	struct i915_vma *ads_vma;
+	struct i915_vma *addon;
 	struct i915_vma *ctx_pool;
 	void *ctx_pool_vaddr;
 	struct ida ctx_ids;
Signature · 6 lines
1.9.1

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

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

#9 lore raw

Re: [PATCH 3/4] drm/i915/guc: s/ads_vma/addon

Quoted 7 lines · Michal Wajdeczko
Quoted 4 lines · Oscar Mateo

This vma contains much more than just the additional data struct (ads) and since we were already using the word "addon" as an object in guc_addon_create, make it the preffered one. No need for the vma suffix either, as that dependency is given by the type.

Hmm, but almost all over the driver we're using "vma" as a name or suffix. Why do you want to change this here ?

Same reason why I changed ctx_pool_vma to ctx_pool: because the type (i915_vma) already tells you everything you need to know (suggestion by Joonas).

Quoted 5 lines

Also, GUC still is using term "ADS" for this blob so I'm not convinced that we need new name here.

-Michal

We still keep the name "ads" in this patch, but we use it to refer to the struct the GuC expects, while "addon" is the GEM object that contains both the ads struct and all the additional stuff the GuC needs. But I could equally keep the ads name and s/guc_addon_create/guc_ads_create (after all, blue or red, a shed is a shed).

Quoted 80 lines
Quoted 80 lines

while at it, add an explanation of what things go inside the addon object.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
  drivers/gpu/drm/i915/i915_guc_submission.c | 12 ++++++++----
  drivers/gpu/drm/i915/intel_guc_loader.c    |  4 ++--
  drivers/gpu/drm/i915/intel_uc.h            |  2 +-
  3 files changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +8 -4
index 7562343c..e1922fe 100644
@@ -834,9 +834,13 @@ static int guc_addon_create(struct intel_guc *guc)
  	struct page *page;
  	u32 size;
 
-	GEM_BUG_ON(guc->ads_vma);
+	GEM_BUG_ON(guc->addon);
 
-	/* The ads obj includes the struct itself and buffers passed to GuC */
+	/* The additional data struct (ADS) has pointers for different buffers
+	 * used by the GuC. The addon object contains the ADS 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 */
  	size = sizeof(struct guc_ads) + sizeof(struct guc_policies) +
  			sizeof(struct guc_mmio_reg_state) +
  			GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE;
@@ -845,7 +849,7 @@ static int guc_addon_create(struct intel_guc *guc)
  	if (IS_ERR(vma))
  		return PTR_ERR(vma);
 
-	guc->ads_vma = vma;
+	guc->addon = vma;
 
  	page = i915_vma_first_page(vma);
  	ads = kmap(page);
@@ -894,7 +898,7 @@ static int guc_addon_create(struct intel_guc *guc)
 
  static void guc_addon_destroy(struct intel_guc *guc)
  {
-	i915_vma_unpin_and_release(&guc->ads_vma);
+	i915_vma_unpin_and_release(&guc->addon);
  }
 
  /*
drivers/gpu/drm/i915/intel_guc_loader.c +2 -2
index 1f9ec54..1eb0c51 100644
@@ -213,8 +213,8 @@ 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;
+	if (guc->addon) {
+		u32 ads = guc_ggtt_offset(guc->addon) >> PAGE_SHIFT;
  		params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT;
  		params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED;
  	}
drivers/gpu/drm/i915/intel_uc.h +1 -1
index 330d08f..d8897b5 100644
@@ -152,7 +152,7 @@ struct intel_guc {
  	/* intel_guc_recv interrupt related state */
  	bool interrupts_enabled;
 
-	struct i915_vma *ads_vma;
+	struct i915_vma *addon;
  	struct i915_vma *ctx_pool;
  	void *ctx_pool_vaddr;
  	struct ida ctx_ids;
Signature · 1 line
1.9.1
Quoted 4 lines
Quoted 4 lines

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

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

#10 lore raw

PATCH 4/4 drm/i915/guc: Break out the GuC log "extras"

In reply to Oscar Mateo

When 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 are "extras", in the sense that we only need them if we actually enable GuC logging. Make that distinction explicit by subdividing further the intel_guc_log struct.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_irq.c      |  4 +--
 drivers/gpu/drm/i915/intel_guc_log.c | 54 ++++++++++++++++++------------------
 drivers/gpu/drm/i915/intel_uc.h      | 12 ++++----
 3 files changed, 36 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +2 -2
index bc70e2c..c826aa8 100644
@@ -1724,8 +1724,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.extras.flush_wq,
+				   &dev_priv->guc.log.extras.flush_work);
 
 			dev_priv->guc.log.flush_interrupt_count++;
 		} else {
drivers/gpu/drm/i915/intel_guc_log.c +27 -27

174 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uc.h +7 -5
index d8897b5..c198ca7 100644
@@ -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;
-
+	/* These extras get 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;
+	} extras;
 	/* 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
maintainer
#11 lore raw

Re: [PATCH 4/4] drm/i915/guc: Break out the GuC log "extras"

Quoted 9 lines · Oscar Mateo

When 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 are "extras", in the sense that we only need them if we actually enable GuC logging. Make that distinction explicit by subdividing further the intel_guc_log struct.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

I'm not sure about calling them extras. How about runtime?

Also, I'm not quite sure if the abstractions are currently correct (despite the names), logging seems to control overall guc interrups, for example (i915_guc_log_unregister func).

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
#12 lore raw

Re: [PATCH 4/4] drm/i915/guc: Break out the GuC log "extras"

Quoted 11 lines · Joonas Lahtinen
Quoted 9 lines · Oscar Mateo

When 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 are "extras", in the sense that we only need them if we actually enable GuC logging. Make that distinction explicit by subdividing further the intel_guc_log struct.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

I'm not sure about calling them extras. How about runtime?

Agree, runtime sounds much better. I'll refresh the patch.

Quoted 4 lines

Also, I'm not quite sure if the abstractions are currently correct (despite the names), logging seems to control overall guc interrups, for example (i915_guc_log_unregister func).

Hmmm... GuC interrupts are a mess, I agree (for the moment the only Guc2Host interrupts we handle are log-related ones, so I imagine that's the reason, but this could very easily change in the future). I'll try to fix this either as part of patch 3 or in a separate patch.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 4/4
#13 lore raw

Re: [PATCH 4/4] drm/i915/guc: Break out the GuC log "extras"

In reply to Oscar Mateo
Quoted 10 lines · Oscar Mateo

When 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 are "extras", in the sense that we only need them if we actually enable GuC logging. Make that distinction explicit by subdividing further the intel_guc_log struct.

Cc Daniele Ceraolo Spurio <[email protected]>
Cc Joonas Lahtinen <[email protected]>

---

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