From patchwork Sun May 19 21:50:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 10949767 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 C20EF912 for ; Sun, 19 May 2019 21:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A17902858E for ; Sun, 19 May 2019 21:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CC5C285C3; Sun, 19 May 2019 21:50:54 +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 BE89F2858E for ; Sun, 19 May 2019 21:50:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E06A88EF5; Sun, 19 May 2019 21:50:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id B50BF88EF5 for ; Sun, 19 May 2019 21:50:50 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 May 2019 14:50:49 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 19 May 2019 14:50:48 -0700 Received: from mwajdecz-MOBL1.ger.corp.intel.com (mwajdecz-mobl1.ger.corp.intel.com [10.249.139.42]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x4JLolUv017286; Sun, 19 May 2019 22:50:47 +0100 From: Michal Wajdeczko To: intel-gfx@lists.freedesktop.org Date: Sun, 19 May 2019 21:50:43 +0000 Message-Id: <20190519215043.10712-1-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.10.1.windows.1 Subject: [Intel-gfx] [PATCH v2] drm/i915/huc: Don't try to check HuC status if it's not loaded 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If we never attempted to load HuC firmware, or we already wedged or reset GuC/HuC, then there is no reason to wake up the device to check one bit in the register that will be for sure cleared. v2: check if HuC was enabled; subtle change in ABI reuse hus_is_load helper Suggested-by: Chris Wilson Signed-off-by: Michal Wajdeczko Cc: Chris Wilson Cc: Tony Ye --- drivers/gpu/drm/i915/intel_huc.c | 20 ++++++++++++-------- drivers/gpu/drm/i915/intel_huc.h | 5 +++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c index 1ff1fb015e58..bfdebec1cfc8 100644 --- a/drivers/gpu/drm/i915/intel_huc.c +++ b/drivers/gpu/drm/i915/intel_huc.c @@ -113,7 +113,7 @@ int intel_huc_auth(struct intel_huc *huc) u32 status; int ret; - if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) + if (!intel_huc_is_loaded(huc)) return -ENOEXEC; ret = intel_guc_auth_huc(guc, @@ -150,21 +150,25 @@ int intel_huc_auth(struct intel_huc *huc) * This function reads status register to verify if HuC * firmware was successfully loaded. * - * Returns: 1 if HuC firmware is loaded and verified, - * 0 if HuC firmware is not loaded and -ENODEV if HuC - * is not present on this platform. + * Returns: 1 if HuC firmware is loaded and verified, 0 if HuC firmware is not + * enabled, -ENOPKG if HuC firmware is not loaded and -ENODEV if HuC is not + * present on this platform. */ int intel_huc_check_status(struct intel_huc *huc) { struct drm_i915_private *dev_priv = huc_to_i915(huc); intel_wakeref_t wakeref; - bool status = false; + bool verified = false; if (!HAS_HUC(dev_priv)) return -ENODEV; - with_intel_runtime_pm(dev_priv, wakeref) - status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED; + if (!USES_HUC(dev_priv)) + return 0; - return status; + if (intel_huc_is_loaded(huc)) + with_intel_runtime_pm(dev_priv, wakeref) + verified = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED; + + return verified ? 1 : -ENOPKG; } diff --git a/drivers/gpu/drm/i915/intel_huc.h b/drivers/gpu/drm/i915/intel_huc.h index a0c21ae02a99..cde3d303718d 100644 --- a/drivers/gpu/drm/i915/intel_huc.h +++ b/drivers/gpu/drm/i915/intel_huc.h @@ -44,6 +44,11 @@ void intel_huc_fini(struct intel_huc *huc); int intel_huc_auth(struct intel_huc *huc); int intel_huc_check_status(struct intel_huc *huc); +static inline bool intel_huc_is_loaded(struct intel_huc *huc) +{ + return intel_uc_fw_is_loaded(&huc->fw); +} + static inline void intel_huc_fini_misc(struct intel_huc *huc) { intel_uc_fw_cleanup_fetch(&huc->fw);