All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load
@ 2018-10-01 20:17 Daniele Ceraolo Spurio
  2018-10-01 20:17 ` [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy Daniele Ceraolo Spurio
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-10-01 20:17 UTC (permalink / raw)
  To: intel-gfx

GuC stores some data in there, which might be stale after a reset.
We already reset the WQ head and tail, but more things are being moved
to the descriptor with the interface updates. Instead of trying to track
them one by one, always memset and init the descriptors from scratch
after GuC is loaded.
The code is also reorganized so that the above operations and the
doorbell creation are grouped as "client enabling"

Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/intel_guc_submission.c | 127 ++++++++++----------
 drivers/gpu/drm/i915/intel_uc_fw.h          |   7 +-
 drivers/gpu/drm/i915/selftests/intel_guc.c  |  17 ++-
 3 files changed, 78 insertions(+), 73 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c b/drivers/gpu/drm/i915/intel_guc_submission.c
index ac862b42f6a1..0806adbaa864 100644
--- a/drivers/gpu/drm/i915/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/intel_guc_submission.c
@@ -282,8 +282,7 @@ __get_process_desc(struct intel_guc_client *client)
 /*
  * Initialise the process descriptor shared with the GuC firmware.
  */
-static void guc_proc_desc_init(struct intel_guc *guc,
-			       struct intel_guc_client *client)
+static void guc_proc_desc_init(struct intel_guc_client *client)
 {
 	struct guc_process_desc *desc;
 
@@ -341,9 +340,9 @@ static void guc_stage_desc_pool_destroy(struct intel_guc *guc)
  * data structures relating to this client (doorbell, process descriptor,
  * write queue, etc).
  */
-static void guc_stage_desc_init(struct intel_guc *guc,
-				struct intel_guc_client *client)
+static void guc_stage_desc_init(struct intel_guc_client *client)
 {
+	struct intel_guc *guc = client->guc;
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	struct intel_engine_cs *engine;
 	struct i915_gem_context *ctx = client->owner;
@@ -424,8 +423,7 @@ static void guc_stage_desc_init(struct intel_guc *guc,
 	desc->desc_private = ptr_to_u64(client);
 }
 
-static void guc_stage_desc_fini(struct intel_guc *guc,
-				struct intel_guc_client *client)
+static void guc_stage_desc_fini(struct intel_guc_client *client)
 {
 	struct guc_stage_desc *desc;
 
@@ -486,14 +484,6 @@ static void guc_wq_item_append(struct intel_guc_client *client,
 	WRITE_ONCE(desc->tail, (wq_off + wqi_size) & (GUC_WQ_SIZE - 1));
 }
 
-static void guc_reset_wq(struct intel_guc_client *client)
-{
-	struct guc_process_desc *desc = __get_process_desc(client);
-
-	desc->head = 0;
-	desc->tail = 0;
-}
-
 static void guc_ring_doorbell(struct intel_guc_client *client)
 {
 	struct guc_doorbell_info *db;
@@ -898,45 +888,6 @@ static bool guc_verify_doorbells(struct intel_guc *guc)
 	return true;
 }
 
-static int guc_clients_doorbell_init(struct intel_guc *guc)
-{
-	int ret;
-
-	ret = create_doorbell(guc->execbuf_client);
-	if (ret)
-		return ret;
-
-	if (guc->preempt_client) {
-		ret = create_doorbell(guc->preempt_client);
-		if (ret) {
-			destroy_doorbell(guc->execbuf_client);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static void guc_clients_doorbell_fini(struct intel_guc *guc)
-{
-	/*
-	 * By the time we're here, GuC has already been reset.
-	 * Instead of trying (in vain) to communicate with it, let's just
-	 * cleanup the doorbell HW and our internal state.
-	 */
-	if (guc->preempt_client) {
-		__destroy_doorbell(guc->preempt_client);
-		__update_doorbell_desc(guc->preempt_client,
-				       GUC_DOORBELL_INVALID);
-	}
-
-	if (guc->execbuf_client) {
-		__destroy_doorbell(guc->execbuf_client);
-		__update_doorbell_desc(guc->execbuf_client,
-				       GUC_DOORBELL_INVALID);
-	}
-}
-
 /**
  * guc_client_alloc() - Allocate an intel_guc_client
  * @dev_priv:	driver private data structure
@@ -1009,9 +960,6 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
 	else
 		client->proc_desc_offset = (GUC_DB_SIZE / 2);
 
-	guc_proc_desc_init(guc, client);
-	guc_stage_desc_init(guc, client);
-
 	ret = reserve_doorbell(client);
 	if (ret)
 		goto err_vaddr;
@@ -1037,7 +985,6 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
 static void guc_client_free(struct intel_guc_client *client)
 {
 	unreserve_doorbell(client);
-	guc_stage_desc_fini(client->guc, client);
 	i915_vma_unpin_and_release(&client->vma, I915_VMA_RELEASE_MAP);
 	ida_simple_remove(&client->guc->stage_ids, client->stage_id);
 	kfree(client);
@@ -1104,6 +1051,64 @@ static void guc_clients_destroy(struct intel_guc *guc)
 		guc_client_free(client);
 }
 
+static int __guc_client_enable(struct intel_guc_client *client)
+{
+	int ret = 0;
+
+	guc_proc_desc_init(client);
+	guc_stage_desc_init(client);
+
+	ret = create_doorbell(client);
+	if (ret)
+		guc_stage_desc_fini(client);
+
+	return ret;
+}
+
+static void __guc_client_disable(struct intel_guc_client *client)
+{
+	/*
+	 * By the time we're here, GuC may have already been reset. if that is
+	 * the case, instead of trying (in vain) to communicate with it, let's
+	 * just cleanup the doorbell HW and our internal state.
+	 */
+
+	if (intel_uc_fw_is_loaded(&client->guc->fw))
+		destroy_doorbell(client);
+	else
+		__destroy_doorbell(client);
+
+	guc_stage_desc_fini(client);
+}
+
+static int guc_clients_enable(struct intel_guc *guc)
+{
+	int ret = 0;
+
+	ret = __guc_client_enable(guc->execbuf_client);
+	if (ret)
+		return ret;
+
+	if (guc->preempt_client) {
+		ret = __guc_client_enable(guc->preempt_client);
+		if (ret) {
+			__guc_client_disable(guc->execbuf_client);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static void guc_clients_disable(struct intel_guc *guc)
+{
+	if (guc->preempt_client)
+		__guc_client_disable(guc->preempt_client);
+
+	if (guc->execbuf_client)
+		__guc_client_disable(guc->execbuf_client);
+}
+
 /*
  * Set up the memory resources to be shared with the GuC (via the GGTT)
  * at firmware loading time.
@@ -1287,15 +1292,11 @@ int intel_guc_submission_enable(struct intel_guc *guc)
 
 	GEM_BUG_ON(!guc->execbuf_client);
 
-	guc_reset_wq(guc->execbuf_client);
-	if (guc->preempt_client)
-		guc_reset_wq(guc->preempt_client);
-
 	err = intel_guc_sample_forcewake(guc);
 	if (err)
 		return err;
 
-	err = guc_clients_doorbell_init(guc);
+	err = guc_clients_enable(guc);
 	if (err)
 		return err;
 
@@ -1317,7 +1318,7 @@ void intel_guc_submission_disable(struct intel_guc *guc)
 	GEM_BUG_ON(dev_priv->gt.awake); /* GT should be parked first */
 
 	guc_interrupts_release(dev_priv);
-	guc_clients_doorbell_fini(guc);
+	guc_clients_disable(guc);
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
diff --git a/drivers/gpu/drm/i915/intel_uc_fw.h b/drivers/gpu/drm/i915/intel_uc_fw.h
index 87910aa83267..0e3bd580e267 100644
--- a/drivers/gpu/drm/i915/intel_uc_fw.h
+++ b/drivers/gpu/drm/i915/intel_uc_fw.h
@@ -115,9 +115,14 @@ static inline bool intel_uc_fw_is_selected(struct intel_uc_fw *uc_fw)
 	return uc_fw->path != NULL;
 }
 
+static inline bool intel_uc_fw_is_loaded(struct intel_uc_fw *uc_fw)
+{
+	return uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS;
+}
+
 static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw)
 {
-	if (uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS)
+	if (intel_uc_fw_is_loaded(uc_fw))
 		uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING;
 }
 
diff --git a/drivers/gpu/drm/i915/selftests/intel_guc.c b/drivers/gpu/drm/i915/selftests/intel_guc.c
index 0c0ab82b6228..bf27162fb327 100644
--- a/drivers/gpu/drm/i915/selftests/intel_guc.c
+++ b/drivers/gpu/drm/i915/selftests/intel_guc.c
@@ -159,6 +159,7 @@ static int igt_guc_clients(void *args)
 	 * Get rid of clients created during driver load because the test will
 	 * recreate them.
 	 */
+	guc_clients_disable(guc);
 	guc_clients_destroy(guc);
 	if (guc->execbuf_client || guc->preempt_client) {
 		pr_err("guc_clients_destroy lied!\n");
@@ -197,8 +198,8 @@ static int igt_guc_clients(void *args)
 		goto out;
 	}
 
-	/* Now create the doorbells */
-	guc_clients_doorbell_init(guc);
+	/* Now enable the clients */
+	guc_clients_enable(guc);
 
 	/* each client should now have received a doorbell */
 	if (!client_doorbell_in_sync(guc->execbuf_client) ||
@@ -212,7 +213,7 @@ static int igt_guc_clients(void *args)
 	 * Basic test - an attempt to reallocate a valid doorbell to the
 	 * client it is currently assigned should not cause a failure.
 	 */
-	err = guc_clients_doorbell_init(guc);
+	err = create_doorbell(guc->execbuf_client);
 	if (err)
 		goto out;
 
@@ -263,12 +264,10 @@ static int igt_guc_clients(void *args)
 	 * Leave clean state for other test, plus the driver always destroy the
 	 * clients during unload.
 	 */
-	destroy_doorbell(guc->execbuf_client);
-	if (guc->preempt_client)
-		destroy_doorbell(guc->preempt_client);
+	guc_clients_disable(guc);
 	guc_clients_destroy(guc);
 	guc_clients_create(guc);
-	guc_clients_doorbell_init(guc);
+	guc_clients_enable(guc);
 unlock:
 	intel_runtime_pm_put(dev_priv);
 	mutex_unlock(&dev_priv->drm.struct_mutex);
@@ -352,7 +351,7 @@ static int igt_guc_doorbells(void *arg)
 
 		db_id = clients[i]->doorbell_id;
 
-		err = create_doorbell(clients[i]);
+		err = __guc_client_enable(clients[i]);
 		if (err) {
 			pr_err("[%d] Failed to create a doorbell\n", i);
 			goto out;
@@ -378,7 +377,7 @@ static int igt_guc_doorbells(void *arg)
 out:
 	for (i = 0; i < ATTEMPTS; i++)
 		if (!IS_ERR_OR_NULL(clients[i])) {
-			destroy_doorbell(clients[i]);
+			__guc_client_disable(clients[i]);
 			guc_client_free(clients[i]);
 		}
 unlock:
-- 
2.19.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy
  2018-10-01 20:17 [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load Daniele Ceraolo Spurio
@ 2018-10-01 20:17 ` Daniele Ceraolo Spurio
  2018-10-02  9:17   ` Michal Wajdeczko
  2018-10-01 22:27 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load Patchwork
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-10-01 20:17 UTC (permalink / raw)
  To: intel-gfx

If the HW has not processed the db invalidation request yet, clearing
the cookie can generate a db ring. We clear the cookie when we
(re-)allocate the doorbell so no need to do it on destroy as well as no
one is going to look at it while the doorbell is inactive

Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/intel_guc_submission.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c b/drivers/gpu/drm/i915/intel_guc_submission.c
index 0806adbaa864..cc52fe76c0f0 100644
--- a/drivers/gpu/drm/i915/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/intel_guc_submission.c
@@ -209,7 +209,6 @@ static void __destroy_doorbell(struct intel_guc_client *client)
 
 	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
-- 
2.19.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load
  2018-10-01 20:17 [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load Daniele Ceraolo Spurio
  2018-10-01 20:17 ` [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy Daniele Ceraolo Spurio
@ 2018-10-01 22:27 ` Patchwork
  2018-10-02  2:23 ` ✓ Fi.CI.IGT: " Patchwork
  2018-10-02 11:02 ` [PATCH 1/2] " Michal Wajdeczko
  3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-10-01 22:27 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load
URL   : https://patchwork.freedesktop.org/series/50410/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4911 -> Patchwork_10314 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/50410/revisions/1/mbox/

== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_suspend@basic-s3:
      fi-blb-e6850:       PASS -> INCOMPLETE (fdo#107718)

    igt@kms_frontbuffer_tracking@basic:
      fi-byt-clapper:     PASS -> FAIL (fdo#103167)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-byt-clapper:     PASS -> FAIL (fdo#107362, fdo#103191) +1

    
    ==== Possible fixes ====

    igt@kms_pipe_crc_basic@hang-read-crc-pipe-b:
      fi-byt-clapper:     FAIL (fdo#107362, fdo#103191) -> PASS

    
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718


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

  Additional (3): fi-gdg-551 fi-snb-2520m fi-pnv-d510 
  Missing    (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-ctg-p8600 fi-icl-u fi-bdw-samus 


== Build changes ==

    * Linux: CI_DRM_4911 -> Patchwork_10314

  CI_DRM_4911: e46b4809753a2e3d3d73c5a9e028cd030bea60e5 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4659: 7f41adfbfd17027b71c332d6ae997f1364f73731 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10314: da1d0bdfa91d91916a69647e59cd721db70249bd @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

da1d0bdfa91d drm/i915/guc: Don't clear the cookie on dorbell destroy
96c98341d09e drm/i915/guc: init GuC descriptors after GuC load

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10314/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ✓ Fi.CI.IGT: success for series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load
  2018-10-01 20:17 [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load Daniele Ceraolo Spurio
  2018-10-01 20:17 ` [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy Daniele Ceraolo Spurio
  2018-10-01 22:27 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load Patchwork
@ 2018-10-02  2:23 ` Patchwork
  2018-10-02 11:02 ` [PATCH 1/2] " Michal Wajdeczko
  3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-10-02  2:23 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load
URL   : https://patchwork.freedesktop.org/series/50410/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4911_full -> Patchwork_10314_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_10314_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_10314_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

== Possible new issues ==

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

  === IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          PASS -> SKIP +1

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-a:
      shard-hsw:          PASS -> DMESG-WARN (fdo#107956)

    igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
      shard-kbl:          PASS -> DMESG-WARN (fdo#107956) +1

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-hsw:          PASS -> INCOMPLETE (fdo#103540)

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)
      shard-kbl:          PASS -> FAIL (fdo#99912)

    
    ==== Possible fixes ====

    igt@kms_busy@extended-pageflip-hang-newfb-render-c:
      shard-glk:          DMESG-WARN (fdo#107956) -> PASS

    igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
      shard-glk:          FAIL (fdo#105363) -> PASS +1

    igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend:
      shard-apl:          DMESG-WARN (fdo#103558, fdo#105602) -> PASS +4

    
  fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
  fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (6 -> 5) ==

  Missing    (1): shard-skl 


== Build changes ==

    * Linux: CI_DRM_4911 -> Patchwork_10314

  CI_DRM_4911: e46b4809753a2e3d3d73c5a9e028cd030bea60e5 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4659: 7f41adfbfd17027b71c332d6ae997f1364f73731 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10314: da1d0bdfa91d91916a69647e59cd721db70249bd @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10314/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy
  2018-10-01 20:17 ` [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy Daniele Ceraolo Spurio
@ 2018-10-02  9:17   ` Michal Wajdeczko
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Wajdeczko @ 2018-10-02  9:17 UTC (permalink / raw)
  To: intel-gfx, Daniele Ceraolo Spurio

On Mon, 01 Oct 2018 22:17:54 +0200, Daniele Ceraolo Spurio  
<daniele.ceraolospurio@intel.com> wrote:

> If the HW has not processed the db invalidation request yet, clearing
> the cookie can generate a db ring. We clear the cookie when we
> (re-)allocate the doorbell so no need to do it on destroy as well as no
> one is going to look at it while the doorbell is inactive
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---

With fixed typo in patch title,

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load
  2018-10-01 20:17 [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load Daniele Ceraolo Spurio
                   ` (2 preceding siblings ...)
  2018-10-02  2:23 ` ✓ Fi.CI.IGT: " Patchwork
@ 2018-10-02 11:02 ` Michal Wajdeczko
  3 siblings, 0 replies; 6+ messages in thread
From: Michal Wajdeczko @ 2018-10-02 11:02 UTC (permalink / raw)
  To: intel-gfx, Daniele Ceraolo Spurio

On Mon, 01 Oct 2018 22:17:53 +0200, Daniele Ceraolo Spurio  
<daniele.ceraolospurio@intel.com> wrote:

> GuC stores some data in there, which might be stale after a reset.
> We already reset the WQ head and tail, but more things are being moved
> to the descriptor with the interface updates. Instead of trying to track
> them one by one, always memset and init the descriptors from scratch
> after GuC is loaded.
> The code is also reorganized so that the above operations and the
> doorbell creation are grouped as "client enabling"
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_guc_submission.c | 127 ++++++++++----------
>  drivers/gpu/drm/i915/intel_uc_fw.h          |   7 +-
>  drivers/gpu/drm/i915/selftests/intel_guc.c  |  17 ++-
>  3 files changed, 78 insertions(+), 73 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c  
> b/drivers/gpu/drm/i915/intel_guc_submission.c
> index ac862b42f6a1..0806adbaa864 100644
> --- a/drivers/gpu/drm/i915/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/intel_guc_submission.c
> @@ -282,8 +282,7 @@ __get_process_desc(struct intel_guc_client *client)
>  /*
>   * Initialise the process descriptor shared with the GuC firmware.
>   */
> -static void guc_proc_desc_init(struct intel_guc *guc,
> -			       struct intel_guc_client *client)
> +static void guc_proc_desc_init(struct intel_guc_client *client)
>  {
>  	struct guc_process_desc *desc;
> @@ -341,9 +340,9 @@ static void guc_stage_desc_pool_destroy(struct  
> intel_guc *guc)
>   * data structures relating to this client (doorbell, process  
> descriptor,
>   * write queue, etc).
>   */
> -static void guc_stage_desc_init(struct intel_guc *guc,
> -				struct intel_guc_client *client)
> +static void guc_stage_desc_init(struct intel_guc_client *client)
>  {
> +	struct intel_guc *guc = client->guc;
>  	struct drm_i915_private *dev_priv = guc_to_i915(guc);
>  	struct intel_engine_cs *engine;
>  	struct i915_gem_context *ctx = client->owner;
> @@ -424,8 +423,7 @@ static void guc_stage_desc_init(struct intel_guc  
> *guc,
>  	desc->desc_private = ptr_to_u64(client);
>  }
> -static void guc_stage_desc_fini(struct intel_guc *guc,
> -				struct intel_guc_client *client)
> +static void guc_stage_desc_fini(struct intel_guc_client *client)
>  {
>  	struct guc_stage_desc *desc;
> @@ -486,14 +484,6 @@ static void guc_wq_item_append(struct  
> intel_guc_client *client,
>  	WRITE_ONCE(desc->tail, (wq_off + wqi_size) & (GUC_WQ_SIZE - 1));
>  }
> -static void guc_reset_wq(struct intel_guc_client *client)
> -{
> -	struct guc_process_desc *desc = __get_process_desc(client);
> -
> -	desc->head = 0;
> -	desc->tail = 0;
> -}
> -
>  static void guc_ring_doorbell(struct intel_guc_client *client)
>  {
>  	struct guc_doorbell_info *db;
> @@ -898,45 +888,6 @@ static bool guc_verify_doorbells(struct intel_guc  
> *guc)
>  	return true;
>  }
> -static int guc_clients_doorbell_init(struct intel_guc *guc)
> -{
> -	int ret;
> -
> -	ret = create_doorbell(guc->execbuf_client);
> -	if (ret)
> -		return ret;
> -
> -	if (guc->preempt_client) {
> -		ret = create_doorbell(guc->preempt_client);
> -		if (ret) {
> -			destroy_doorbell(guc->execbuf_client);
> -			return ret;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
> -static void guc_clients_doorbell_fini(struct intel_guc *guc)
> -{
> -	/*
> -	 * By the time we're here, GuC has already been reset.
> -	 * Instead of trying (in vain) to communicate with it, let's just
> -	 * cleanup the doorbell HW and our internal state.
> -	 */
> -	if (guc->preempt_client) {
> -		__destroy_doorbell(guc->preempt_client);
> -		__update_doorbell_desc(guc->preempt_client,
> -				       GUC_DOORBELL_INVALID);
> -	}
> -
> -	if (guc->execbuf_client) {
> -		__destroy_doorbell(guc->execbuf_client);
> -		__update_doorbell_desc(guc->execbuf_client,
> -				       GUC_DOORBELL_INVALID);
> -	}
> -}
> -
>  /**
>   * guc_client_alloc() - Allocate an intel_guc_client
>   * @dev_priv:	driver private data structure
> @@ -1009,9 +960,6 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
>  	else
>  		client->proc_desc_offset = (GUC_DB_SIZE / 2);
> -	guc_proc_desc_init(guc, client);
> -	guc_stage_desc_init(guc, client);
> -
>  	ret = reserve_doorbell(client);
>  	if (ret)
>  		goto err_vaddr;
> @@ -1037,7 +985,6 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
>  static void guc_client_free(struct intel_guc_client *client)
>  {
>  	unreserve_doorbell(client);
> -	guc_stage_desc_fini(client->guc, client);
>  	i915_vma_unpin_and_release(&client->vma, I915_VMA_RELEASE_MAP);
>  	ida_simple_remove(&client->guc->stage_ids, client->stage_id);
>  	kfree(client);
> @@ -1104,6 +1051,64 @@ static void guc_clients_destroy(struct intel_guc  
> *guc)
>  		guc_client_free(client);
>  }
> +static int __guc_client_enable(struct intel_guc_client *client)
> +{
> +	int ret = 0;

initialization is not needed here

> +
> +	guc_proc_desc_init(client);
> +	guc_stage_desc_init(client);
> +
> +	ret = create_doorbell(client);
> +	if (ret)
> +		guc_stage_desc_fini(client);
> +
> +	return ret;
> +}
> +
> +static void __guc_client_disable(struct intel_guc_client *client)
> +{
> +	/*
> +	 * By the time we're here, GuC may have already been reset. if that is
> +	 * the case, instead of trying (in vain) to communicate with it, let's
> +	 * just cleanup the doorbell HW and our internal state.
> +	 */
> +

extra new line

> +	if (intel_uc_fw_is_loaded(&client->guc->fw))

what about adding one more helper in intel_guc.h:

static inline bool intel_guc_is_alive(struct intel_guc *guc)
{
	return intel_uc_fw_is_loaded(&guc->fw);
}

and use it here as:

	if (intel_guc_is_alive(client->guc))

> +		destroy_doorbell(client);
> +	else
> +		__destroy_doorbell(client);
> +
> +	guc_stage_desc_fini(client);
> +}
> +
> +static int guc_clients_enable(struct intel_guc *guc)
> +{
> +	int ret = 0;

initialization is not needed here

> +
> +	ret = __guc_client_enable(guc->execbuf_client);
> +	if (ret)
> +		return ret;
> +
> +	if (guc->preempt_client) {
> +		ret = __guc_client_enable(guc->preempt_client);
> +		if (ret) {
> +			__guc_client_disable(guc->execbuf_client);
> +			return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void guc_clients_disable(struct intel_guc *guc)
> +{
> +	if (guc->preempt_client)
> +		__guc_client_disable(guc->preempt_client);
> +
> +	if (guc->execbuf_client)
> +		__guc_client_disable(guc->execbuf_client);
> +}
> +
>  /*
>   * Set up the memory resources to be shared with the GuC (via the GGTT)
>   * at firmware loading time.
> @@ -1287,15 +1292,11 @@ int intel_guc_submission_enable(struct intel_guc  
> *guc)
> 	GEM_BUG_ON(!guc->execbuf_client);
> -	guc_reset_wq(guc->execbuf_client);
> -	if (guc->preempt_client)
> -		guc_reset_wq(guc->preempt_client);
> -
>  	err = intel_guc_sample_forcewake(guc);
>  	if (err)
>  		return err;
> -	err = guc_clients_doorbell_init(guc);
> +	err = guc_clients_enable(guc);
>  	if (err)
>  		return err;
> @@ -1317,7 +1318,7 @@ void intel_guc_submission_disable(struct intel_guc  
> *guc)
>  	GEM_BUG_ON(dev_priv->gt.awake); /* GT should be parked first */
> 	guc_interrupts_release(dev_priv);
> -	guc_clients_doorbell_fini(guc);
> +	guc_clients_disable(guc);
>  }
> #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
> diff --git a/drivers/gpu/drm/i915/intel_uc_fw.h  
> b/drivers/gpu/drm/i915/intel_uc_fw.h
> index 87910aa83267..0e3bd580e267 100644
> --- a/drivers/gpu/drm/i915/intel_uc_fw.h
> +++ b/drivers/gpu/drm/i915/intel_uc_fw.h
> @@ -115,9 +115,14 @@ static inline bool intel_uc_fw_is_selected(struct  
> intel_uc_fw *uc_fw)
>  	return uc_fw->path != NULL;
>  }
> +static inline bool intel_uc_fw_is_loaded(struct intel_uc_fw *uc_fw)
> +{
> +	return uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS;
> +}
> +
>  static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw)
>  {
> -	if (uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS)
> +	if (intel_uc_fw_is_loaded(uc_fw))
>  		uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING;
>  }
> diff --git a/drivers/gpu/drm/i915/selftests/intel_guc.c  
> b/drivers/gpu/drm/i915/selftests/intel_guc.c
> index 0c0ab82b6228..bf27162fb327 100644
> --- a/drivers/gpu/drm/i915/selftests/intel_guc.c
> +++ b/drivers/gpu/drm/i915/selftests/intel_guc.c
> @@ -159,6 +159,7 @@ static int igt_guc_clients(void *args)
>  	 * Get rid of clients created during driver load because the test will
>  	 * recreate them.
>  	 */
> +	guc_clients_disable(guc);
>  	guc_clients_destroy(guc);
>  	if (guc->execbuf_client || guc->preempt_client) {
>  		pr_err("guc_clients_destroy lied!\n");
> @@ -197,8 +198,8 @@ static int igt_guc_clients(void *args)
>  		goto out;
>  	}
> -	/* Now create the doorbells */
> -	guc_clients_doorbell_init(guc);
> +	/* Now enable the clients */
> +	guc_clients_enable(guc);
> 	/* each client should now have received a doorbell */
>  	if (!client_doorbell_in_sync(guc->execbuf_client) ||
> @@ -212,7 +213,7 @@ static int igt_guc_clients(void *args)
>  	 * Basic test - an attempt to reallocate a valid doorbell to the
>  	 * client it is currently assigned should not cause a failure.
>  	 */
> -	err = guc_clients_doorbell_init(guc);
> +	err = create_doorbell(guc->execbuf_client);
>  	if (err)
>  		goto out;
> @@ -263,12 +264,10 @@ static int igt_guc_clients(void *args)
>  	 * Leave clean state for other test, plus the driver always destroy the
>  	 * clients during unload.
>  	 */
> -	destroy_doorbell(guc->execbuf_client);
> -	if (guc->preempt_client)
> -		destroy_doorbell(guc->preempt_client);
> +	guc_clients_disable(guc);
>  	guc_clients_destroy(guc);
>  	guc_clients_create(guc);
> -	guc_clients_doorbell_init(guc);
> +	guc_clients_enable(guc);
>  unlock:
>  	intel_runtime_pm_put(dev_priv);
>  	mutex_unlock(&dev_priv->drm.struct_mutex);
> @@ -352,7 +351,7 @@ static int igt_guc_doorbells(void *arg)
> 		db_id = clients[i]->doorbell_id;
> -		err = create_doorbell(clients[i]);
> +		err = __guc_client_enable(clients[i]);
>  		if (err) {
>  			pr_err("[%d] Failed to create a doorbell\n", i);
>  			goto out;
> @@ -378,7 +377,7 @@ static int igt_guc_doorbells(void *arg)
>  out:
>  	for (i = 0; i < ATTEMPTS; i++)
>  		if (!IS_ERR_OR_NULL(clients[i])) {
> -			destroy_doorbell(clients[i]);
> +			__guc_client_disable(clients[i]);
>  			guc_client_free(clients[i]);
>  		}
>  unlock:

with above small updates,

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>

Michal
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-02 11:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 20:17 [PATCH 1/2] drm/i915/guc: init GuC descriptors after GuC load Daniele Ceraolo Spurio
2018-10-01 20:17 ` [PATCH 2/2] drm/i915/guc: Don't clear the cookie on dorbell destroy Daniele Ceraolo Spurio
2018-10-02  9:17   ` Michal Wajdeczko
2018-10-01 22:27 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/guc: init GuC descriptors after GuC load Patchwork
2018-10-02  2:23 ` ✓ Fi.CI.IGT: " Patchwork
2018-10-02 11:02 ` [PATCH 1/2] " Michal Wajdeczko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.