Commit 91e55e54 authored by Daniele Ceraolo Spurio's avatar Daniele Ceraolo Spurio Committed by Chris Wilson
Browse files

drm/i915/uc: Unify uc_fw status tracking



We currently track fetch and load status separately, but the 2 are
actually sequential in the uc lifetime (fetch must complete before we
can attempt the load!). Unifying the 2 variables we can better follow
the sequential states and improve our trackng of the uC state.

Also, sprinkle some GEM_BUG_ON to make sure we transition correctly
between states.

v2: rename states, add the running state (Michal), drop some logs in
    the fetch path (Michal, Chris)

v3: re-rename states, extend early status check to all helpers (Michal)

Suggested-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190725001813.4740-5-daniele.ceraolospurio@intel.com
parent 21a27d1c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -172,9 +172,9 @@ int intel_guc_suspend(struct intel_guc *guc);
int intel_guc_resume(struct intel_guc *guc);
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);

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

static inline int intel_guc_sanitize(struct intel_guc *guc)
+5 −1
Original line number Diff line number Diff line
@@ -230,5 +230,9 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw)
 */
int intel_guc_fw_upload(struct intel_guc *guc)
{
	return intel_uc_fw_upload(&guc->fw, guc_fw_xfer);
	int ret = intel_uc_fw_upload(&guc->fw, guc_fw_xfer);
	if (!ret)
		guc->fw.status = INTEL_UC_FIRMWARE_RUNNING;

	return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -941,7 +941,7 @@ static void __guc_client_disable(struct intel_guc_client *client)
	 * the case, instead of trying (in vain) to communicate with it, let's
	 * just cleanup the doorbell HW and our internal state.
	 */
	if (intel_guc_is_loaded(client->guc))
	if (intel_guc_is_running(client->guc))
		destroy_doorbell(client);
	else
		__fini_doorbell(client);
+5 −3
Original line number Diff line number Diff line
@@ -117,8 +117,8 @@ int intel_huc_auth(struct intel_huc *huc)
	struct intel_guc *guc = &gt->uc.guc;
	int ret;

	if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
		return -ENOEXEC;
	GEM_BUG_ON(!intel_uc_fw_is_loaded(&huc->fw));
	GEM_BUG_ON(intel_huc_is_authenticated(huc));

	ret = intel_guc_auth_huc(guc,
				 intel_guc_ggtt_offset(guc, huc->rsa_data));
@@ -138,10 +138,12 @@ int intel_huc_auth(struct intel_huc *huc)
		goto fail;
	}

	huc->fw.status = INTEL_UC_FIRMWARE_RUNNING;

	return 0;

fail:
	huc->fw.load_status = INTEL_UC_FIRMWARE_FAIL;
	huc->fw.status = INTEL_UC_FIRMWARE_FAIL;

	DRM_ERROR("HuC: Authentication failed %d\n", ret);
	return ret;
+5 −0
Original line number Diff line number Diff line
@@ -56,4 +56,9 @@ static inline int intel_huc_sanitize(struct intel_huc *huc)
	return 0;
}

static inline bool intel_huc_is_authenticated(struct intel_huc *huc)
{
	return intel_uc_fw_is_running(&huc->fw);
}

#endif
Loading