From patchwork Fri Aug 16 20:56:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 11098265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C51F14DB for ; Fri, 16 Aug 2019 20:57:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C502872A for ; Fri, 16 Aug 2019 20:57:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2077288D4; Fri, 16 Aug 2019 20:57:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2DC992872A for ; Fri, 16 Aug 2019 20:57:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 987FA6E2F8; Fri, 16 Aug 2019 20:57:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1773A6E2F8 for ; Fri, 16 Aug 2019 20:57:22 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2019 13:57:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,394,1559545200"; d="scan'208";a="178865826" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga007.fm.intel.com with ESMTP; 16 Aug 2019 13:57:20 -0700 Received: from mwajdecz-MOBL1.ger.corp.intel.com (mwajdecz-mobl1.ger.corp.intel.com [10.249.129.244]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x7GKvJQO002427; Fri, 16 Aug 2019 21:57:19 +0100 From: Michal Wajdeczko To: intel-gfx@lists.freedesktop.org Date: Fri, 16 Aug 2019 20:56:58 +0000 Message-Id: <20190816205658.15020-1-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v4] drm/i915/uc: Add explicit DISABLED state for firmware X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We really need to have separate NOT_SUPPORTED state (for lack of hardware support) and DISABLED state (to indicate user decision) as we will have to take special steps even if GuC firmware is now disabled but hardware exists and could have been previously used. v2: fix logic (Chris/CI) v3: use proper check to avoid probe failure (CI) v4: explain status transitions (Chris) Signed-off-by: Michal Wajdeczko Cc: Daniele Ceraolo Spurio Cc: Chris Wilson Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 7 +++- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 7 +++- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_uc.c | 37 ++++++++++--------- drivers/gpu/drm/i915/gt/uc/intel_uc.h | 17 ++++++++- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 5 +-- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 43 +++++++++++++++++++---- drivers/gpu/drm/i915/i915_drv.h | 4 +-- 8 files changed, 91 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h b/drivers/gpu/drm/i915/gt/uc/intel_guc.h index 4999db965685..2b2f046d3cc3 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h @@ -154,7 +154,12 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size); static inline bool intel_guc_is_supported(struct intel_guc *guc) { - return intel_uc_fw_supported(&guc->fw); + return intel_uc_fw_is_supported(&guc->fw); +} + +static inline bool intel_guc_is_enabled(struct intel_guc *guc) +{ + return intel_uc_fw_is_enabled(&guc->fw); } static inline bool intel_guc_is_running(struct intel_guc *guc) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc.h b/drivers/gpu/drm/i915/gt/uc/intel_huc.h index f8a4557c8d6d..644c059fe01d 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_huc.h +++ b/drivers/gpu/drm/i915/gt/uc/intel_huc.h @@ -38,7 +38,12 @@ static inline int intel_huc_sanitize(struct intel_huc *huc) static inline bool intel_huc_is_supported(struct intel_huc *huc) { - return intel_uc_fw_supported(&huc->fw); + return intel_uc_fw_is_supported(&huc->fw); +} + +static inline bool intel_huc_is_enabled(struct intel_huc *huc) +{ + return intel_uc_fw_is_enabled(&huc->fw); } static inline bool intel_huc_is_authenticated(struct intel_huc *huc) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c index 96feca99322a..74602487ed67 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c @@ -35,7 +35,7 @@ void intel_huc_fw_init_early(struct intel_huc *huc) struct drm_i915_private *i915 = gt->i915; intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC, - intel_uc_supports_guc(uc), + intel_uc_uses_guc(uc), INTEL_INFO(i915)->platform, INTEL_REVID(i915)); } diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c b/drivers/gpu/drm/i915/gt/uc/intel_uc.c index 0dc2b0cf4604..449c432dd768 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c @@ -45,17 +45,17 @@ static void __confirm_options(struct intel_uc *uc) DRM_DEV_DEBUG_DRIVER(i915->drm.dev, "enable_guc=%d (guc:%s submission:%s huc:%s)\n", i915_modparams.enable_guc, - yesno(intel_uc_supports_guc(uc)), - yesno(intel_uc_supports_guc_submission(uc)), - yesno(intel_uc_supports_huc(uc))); + yesno(intel_uc_uses_guc(uc)), + yesno(intel_uc_uses_guc_submission(uc)), + yesno(intel_uc_uses_huc(uc))); if (i915_modparams.enable_guc == -1) return; if (i915_modparams.enable_guc == 0) { - GEM_BUG_ON(intel_uc_supports_guc(uc)); - GEM_BUG_ON(intel_uc_supports_guc_submission(uc)); - GEM_BUG_ON(intel_uc_supports_huc(uc)); + GEM_BUG_ON(intel_uc_uses_guc(uc)); + GEM_BUG_ON(intel_uc_uses_guc_submission(uc)); + GEM_BUG_ON(intel_uc_uses_huc(uc)); return; } @@ -266,23 +266,23 @@ void intel_uc_fetch_firmwares(struct intel_uc *uc) struct drm_i915_private *i915 = uc_to_gt(uc)->i915; int err; - if (!intel_uc_supports_guc(uc)) + if (!intel_uc_uses_guc(uc)) return; err = intel_uc_fw_fetch(&uc->guc.fw, i915); if (err) return; - if (intel_uc_supports_huc(uc)) + if (intel_uc_uses_huc(uc)) intel_uc_fw_fetch(&uc->huc.fw, i915); } void intel_uc_cleanup_firmwares(struct intel_uc *uc) { - if (!intel_uc_supports_guc(uc)) + if (!intel_uc_uses_guc(uc)) return; - if (intel_uc_supports_huc(uc)) + if (intel_uc_uses_huc(uc)) intel_uc_fw_cleanup_fetch(&uc->huc.fw); intel_uc_fw_cleanup_fetch(&uc->guc.fw); @@ -294,7 +294,7 @@ int intel_uc_init(struct intel_uc *uc) struct intel_huc *huc = &uc->huc; int ret; - if (!intel_uc_supports_guc(uc)) + if (!intel_uc_uses_guc(uc)) return 0; /* XXX: GuC submission is unavailable for now */ @@ -304,7 +304,7 @@ int intel_uc_init(struct intel_uc *uc) if (ret) return ret; - if (intel_uc_supports_huc(uc)) { + if (intel_uc_uses_huc(uc)) { ret = intel_huc_init(huc); if (ret) goto out_huc; @@ -321,10 +321,10 @@ void intel_uc_fini(struct intel_uc *uc) { struct intel_guc *guc = &uc->guc; - if (!intel_uc_supports_guc(uc)) + if (!intel_uc_uses_guc(uc)) return; - if (intel_uc_supports_huc(uc)) + if (intel_uc_uses_huc(uc)) intel_huc_fini(&uc->huc); intel_guc_fini(guc); @@ -360,7 +360,7 @@ static int uc_init_wopcm(struct intel_uc *uc) struct intel_uncore *uncore = gt->uncore; u32 base = intel_wopcm_guc_base(>->i915->wopcm); u32 size = intel_wopcm_guc_size(>->i915->wopcm); - u32 huc_agent = intel_uc_supports_huc(uc) ? HUC_LOADING_AGENT_GUC : 0; + u32 huc_agent = intel_uc_uses_huc(uc) ? HUC_LOADING_AGENT_GUC : 0; u32 mask; int err; @@ -417,6 +417,9 @@ int intel_uc_init_hw(struct intel_uc *uc) if (!intel_uc_supports_guc(uc)) return 0; + if (!intel_uc_uses_guc(uc)) + return 0; + if (!intel_uc_fw_is_available(&guc->fw)) { ret = intel_uc_fw_status_to_error(guc->fw.status); goto err_out; @@ -444,7 +447,7 @@ int intel_uc_init_hw(struct intel_uc *uc) if (ret) goto err_out; - if (intel_uc_supports_huc(uc)) { + if (intel_uc_uses_huc(uc)) { ret = intel_huc_fw_upload(huc); if (ret && intel_uc_fw_is_overridden(&huc->fw)) goto err_out; @@ -490,7 +493,7 @@ int intel_uc_init_hw(struct intel_uc *uc) "submission", enableddisabled(intel_uc_supports_guc_submission(uc))); - if (intel_uc_supports_huc(uc)) { + if (intel_uc_uses_huc(uc)) { dev_info(i915->drm.dev, "%s firmware %s version %u.%u %s:%s\n", intel_uc_fw_type_repr(INTEL_UC_FW_TYPE_HUC), huc->fw.path, diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h b/drivers/gpu/drm/i915/gt/uc/intel_uc.h index bfb6f97578a5..1b9404a75ac0 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h @@ -39,14 +39,29 @@ static inline bool intel_uc_supports_guc(struct intel_uc *uc) return intel_guc_is_supported(&uc->guc); } +static inline bool intel_uc_uses_guc(struct intel_uc *uc) +{ + return intel_guc_is_enabled(&uc->guc); +} + static inline bool intel_uc_supports_guc_submission(struct intel_uc *uc) { return intel_guc_is_submission_supported(&uc->guc); } +static inline bool intel_uc_uses_guc_submission(struct intel_uc *uc) +{ + return intel_guc_is_submission_supported(&uc->guc); +} + static inline bool intel_uc_supports_huc(struct intel_uc *uc) { - return intel_huc_is_supported(&uc->huc); + return intel_uc_supports_guc(uc); +} + +static inline bool intel_uc_uses_huc(struct intel_uc *uc) +{ + return intel_huc_is_enabled(&uc->huc); } #endif diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c index f4a34ea579fd..890ae6b4a3d0 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c @@ -206,8 +206,9 @@ void intel_uc_fw_init_early(struct intel_uc_fw *uc_fw, __uc_fw_user_override(uc_fw); } - intel_uc_fw_change_status(uc_fw, uc_fw->path && *uc_fw->path ? + intel_uc_fw_change_status(uc_fw, uc_fw->path ? *uc_fw->path ? INTEL_UC_FIRMWARE_SELECTED : + INTEL_UC_FIRMWARE_DISABLED : INTEL_UC_FIRMWARE_NOT_SUPPORTED); } @@ -266,7 +267,7 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw, struct drm_i915_private *i915) int err; GEM_BUG_ON(!i915->wopcm.size); - GEM_BUG_ON(!intel_uc_fw_supported(uc_fw)); + GEM_BUG_ON(!intel_uc_fw_is_enabled(uc_fw)); err = i915_inject_load_error(i915, -ENXIO); if (err) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h index 6fa50273c2ce..bacee0d318c0 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h @@ -18,9 +18,30 @@ struct intel_gt; /* Home of GuC, HuC and DMC firmwares */ #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915" +/* + * +------------+---------------------------------------------------+ + * | PHASE | FIRMWARE STATUS TRANSITIONS | + * +============+===================================================+ + * | | UNINITIALIZED | + * +------------+- / | \ -+ + * | | DISABLED <--/ | \--> NOT_SUPPORTED | + * | init_early | V | + * | | SELECTED | + * +------------+- / | \ -+ + * | | MISSING <--/ | \--> ERROR | + * | fetch | | | + * | | /------> AVAILABLE <---<-----------\ | + * +------------+- \ / \ \ \ -+ + * | | FAIL <--< \--> TRANSFERRED \ | + * | upload | \ / \ / | + * | | \---------/ \--> RUNNING | + * +------------+---------------------------------------------------+ + */ + enum intel_uc_fw_status { - INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW or disabled */ + INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW */ INTEL_UC_FIRMWARE_UNINITIALIZED = 0, /* used to catch checks done too early */ + INTEL_UC_FIRMWARE_DISABLED, /* disabled */ INTEL_UC_FIRMWARE_SELECTED, /* selected the blob we want to load */ INTEL_UC_FIRMWARE_MISSING, /* blob not found on the system */ INTEL_UC_FIRMWARE_ERROR, /* invalid format or version */ @@ -84,6 +105,8 @@ const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) return "N/A"; case INTEL_UC_FIRMWARE_UNINITIALIZED: return "UNINITIALIZED"; + case INTEL_UC_FIRMWARE_DISABLED: + return "DISABLED"; case INTEL_UC_FIRMWARE_SELECTED: return "SELECTED"; case INTEL_UC_FIRMWARE_MISSING: @@ -106,7 +129,10 @@ static inline int intel_uc_fw_status_to_error(enum intel_uc_fw_status status) { switch (status) { case INTEL_UC_FIRMWARE_NOT_SUPPORTED: + return -ENODEV; case INTEL_UC_FIRMWARE_UNINITIALIZED: + return -EACCES; + case INTEL_UC_FIRMWARE_DISABLED: return -EPERM; case INTEL_UC_FIRMWARE_MISSING: return -ENOENT; @@ -142,6 +168,16 @@ __intel_uc_fw_status(struct intel_uc_fw *uc_fw) return uc_fw->status; } +static inline bool intel_uc_fw_is_supported(struct intel_uc_fw *uc_fw) +{ + return __intel_uc_fw_status(uc_fw) != INTEL_UC_FIRMWARE_NOT_SUPPORTED; +} + +static inline bool intel_uc_fw_is_enabled(struct intel_uc_fw *uc_fw) +{ + return __intel_uc_fw_status(uc_fw) > INTEL_UC_FIRMWARE_DISABLED; +} + static inline bool intel_uc_fw_is_available(struct intel_uc_fw *uc_fw) { return __intel_uc_fw_status(uc_fw) >= INTEL_UC_FIRMWARE_AVAILABLE; @@ -157,11 +193,6 @@ static inline bool intel_uc_fw_is_running(struct intel_uc_fw *uc_fw) return __intel_uc_fw_status(uc_fw) == INTEL_UC_FIRMWARE_RUNNING; } -static inline bool intel_uc_fw_supported(struct intel_uc_fw *uc_fw) -{ - return __intel_uc_fw_status(uc_fw) != INTEL_UC_FIRMWARE_NOT_SUPPORTED; -} - static inline bool intel_uc_fw_is_overridden(const struct intel_uc_fw *uc_fw) { return uc_fw->user_overridden; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0527ede6e0f2..514a63190cc1 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2214,8 +2214,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915, #define HAS_GT_UC(dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc) /* Having GuC is not the same as using GuC */ -#define USES_GUC(dev_priv) intel_uc_supports_guc(&(dev_priv)->gt.uc) -#define USES_GUC_SUBMISSION(dev_priv) intel_uc_supports_guc_submission(&(dev_priv)->gt.uc) +#define USES_GUC(dev_priv) intel_uc_uses_guc(&(dev_priv)->gt.uc) +#define USES_GUC_SUBMISSION(dev_priv) intel_uc_uses_guc_submission(&(dev_priv)->gt.uc) #define HAS_POOLED_EU(dev_priv) (INTEL_INFO(dev_priv)->has_pooled_eu)