From patchwork Tue Dec 16 15:20:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 5501241 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B8BC49F326 for ; Tue, 16 Dec 2014 15:30:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6002220A25 for ; Tue, 16 Dec 2014 15:30:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9446B20A22 for ; Tue, 16 Dec 2014 15:30:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E02886E8BC; Tue, 16 Dec 2014 07:30:55 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id A1DDD6E8BC for ; Tue, 16 Dec 2014 07:30:54 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 16 Dec 2014 07:16:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,587,1413270000"; d="scan'208";a="654923755" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.102]) by orsmga002.jf.intel.com with ESMTP; 16 Dec 2014 07:16:42 -0800 Received: by rosetta (Postfix, from userid 1000) id BB7F580086; Tue, 16 Dec 2014 17:21:01 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Tue, 16 Dec 2014 17:20:59 +0200 Message-Id: <1418743260-21146-8-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418743260-21146-1-git-send-email-mika.kuoppala@intel.com> References: <1418743260-21146-1-git-send-email-mika.kuoppala@intel.com> Cc: miku@iki.fi Subject: [Intel-gfx] [PATCH 8/9] drm/i915: Enum forcewake domains and domain identifiers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the domains and domain identifiers enums. To emphasize the difference in order to avoid mistakes. v2: s/fw_domain/forcewake_domain (Jani) v3: rebase Suggested-by: Daniel Vetter Signed-off-by: Mika Kuoppala Reviewed-by: Deepak S (v1) --- drivers/gpu/drm/i915/i915_drv.h | 45 ++++++++++++++++++----------------- drivers/gpu/drm/i915/intel_uncore.c | 47 ++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2dbaed1..dbd39de 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -574,11 +574,28 @@ struct drm_i915_display_funcs { void (*enable_backlight)(struct intel_connector *connector); }; +enum forcewake_domain_id { + FW_DOMAIN_ID_RENDER = 0, + FW_DOMAIN_ID_BLITTER, + FW_DOMAIN_ID_MEDIA, + + FW_DOMAIN_ID_COUNT +}; + +enum forcewake_domains { + FORCEWAKE_RENDER = (1 << FW_DOMAIN_ID_RENDER), + FORCEWAKE_BLITTER = (1 << FW_DOMAIN_ID_BLITTER), + FORCEWAKE_MEDIA = (1 << FW_DOMAIN_ID_MEDIA), + FORCEWAKE_ALL = (FORCEWAKE_RENDER | + FORCEWAKE_BLITTER | + FORCEWAKE_MEDIA) +}; + struct intel_uncore_funcs { void (*force_wake_get)(struct drm_i915_private *dev_priv, - int fw_engine); + enum forcewake_domains domains); void (*force_wake_put)(struct drm_i915_private *dev_priv, - int fw_engine); + enum forcewake_domains domains); uint8_t (*mmio_readb)(struct drm_i915_private *dev_priv, off_t offset, bool trace); uint16_t (*mmio_readw)(struct drm_i915_private *dev_priv, off_t offset, bool trace); @@ -595,25 +612,17 @@ struct intel_uncore_funcs { uint64_t val, bool trace); }; -enum { - FW_DOMAIN_ID_RENDER = 0, - FW_DOMAIN_ID_BLITTER, - FW_DOMAIN_ID_MEDIA, - - FW_DOMAIN_ID_COUNT -}; - struct intel_uncore { spinlock_t lock; /** lock is also taken in irq contexts. */ struct intel_uncore_funcs funcs; unsigned fifo_count; - unsigned fw_domains; + enum forcewake_domains fw_domains; struct intel_uncore_forcewake_domain { struct drm_i915_private *i915; - int id; + enum forcewake_domain_id id; unsigned wake_count; struct timer_list timer; u32 reg_set; @@ -623,12 +632,6 @@ struct intel_uncore { u32 reg_post; u32 val_reset; } fw_domain[FW_DOMAIN_ID_COUNT]; -#define FORCEWAKE_RENDER (1 << FW_DOMAIN_ID_RENDER) -#define FORCEWAKE_BLITTER (1 << FW_DOMAIN_ID_BLITTER) -#define FORCEWAKE_MEDIA (1 << FW_DOMAIN_ID_MEDIA) -#define FORCEWAKE_ALL (FORCEWAKE_RENDER | \ - FORCEWAKE_BLITTER | \ - FORCEWAKE_MEDIA) }; /* Iterate over initialised fw domains */ @@ -2506,11 +2509,11 @@ extern void intel_uncore_init(struct drm_device *dev); extern void intel_uncore_check_errors(struct drm_device *dev); extern void intel_uncore_fini(struct drm_device *dev); extern void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore); -const char *intel_uncore_forcewake_domain_to_str(const int domain_id); +const char *intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id); void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv, - unsigned fw_domains); + enum forcewake_domains domains); void intel_uncore_forcewake_put(struct drm_i915_private *dev_priv, - unsigned fw_domains); + enum forcewake_domains domains); void assert_forcewakes_inactive(struct drm_i915_private *dev_priv); void diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 4745645..de6c868 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -49,7 +49,7 @@ static const char * const forcewake_domain_names[] = { }; const char * -intel_uncore_forcewake_domain_to_str(const int id) +intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id) { BUILD_BUG_ON((sizeof(forcewake_domain_names)/sizeof(const char *)) != FW_DOMAIN_ID_COUNT); @@ -122,10 +122,10 @@ fw_domain_posting_read(const struct intel_uncore_forcewake_domain *d) } static void -fw_domains_get(struct drm_i915_private *dev_priv, int fw_domains) +fw_domains_get(struct drm_i915_private *dev_priv, enum forcewake_domains fw_domains) { struct intel_uncore_forcewake_domain *d; - int id; + enum forcewake_domain_id id; for_each_fw_domain_mask(d, fw_domains, dev_priv, id) { fw_domain_wait_ack_clear(d); @@ -136,10 +136,10 @@ fw_domains_get(struct drm_i915_private *dev_priv, int fw_domains) } static void -fw_domains_put(struct drm_i915_private *dev_priv, int fw_domains) +fw_domains_put(struct drm_i915_private *dev_priv, enum forcewake_domains fw_domains) { struct intel_uncore_forcewake_domain *d; - int id; + enum forcewake_domain_id id; for_each_fw_domain_mask(d, fw_domains, dev_priv, id) fw_domain_put(d); @@ -149,7 +149,7 @@ static void fw_domains_posting_read(struct drm_i915_private *dev_priv) { struct intel_uncore_forcewake_domain *d; - int id; + enum forcewake_domain_id id; /* No need to do for all, just do for first found */ for_each_fw_domain(d, dev_priv, id) { @@ -159,10 +159,10 @@ fw_domains_posting_read(struct drm_i915_private *dev_priv) } static void -fw_domains_reset(struct drm_i915_private *dev_priv, const unsigned fw_domains) +fw_domains_reset(struct drm_i915_private *dev_priv, enum forcewake_domains fw_domains) { struct intel_uncore_forcewake_domain *d; - int id; + enum forcewake_domain_id id; for_each_fw_domain_mask(d, fw_domains, dev_priv, id) fw_domain_reset(d); @@ -181,7 +181,7 @@ static void __gen6_gt_wait_for_thread_c0(struct drm_i915_private *dev_priv) } static void fw_domains_get_with_thread_status(struct drm_i915_private *dev_priv, - int fw_domains) + enum forcewake_domains fw_domains) { fw_domains_get(dev_priv, fw_domains); @@ -199,7 +199,7 @@ static void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv) } static void fw_domains_put_with_fifo(struct drm_i915_private *dev_priv, - int fw_domains) + enum forcewake_domains fw_domains) { fw_domains_put(dev_priv, fw_domains); gen6_gt_check_fifodbg(dev_priv); @@ -253,9 +253,11 @@ static void intel_uncore_fw_release_timer(unsigned long arg) void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore) { struct drm_i915_private *dev_priv = dev->dev_private; - unsigned long irqflags, fw = 0; + unsigned long irqflags; struct intel_uncore_forcewake_domain *domain; - int id, active_domains, retry_count = 100; + int retry_count = 100; + enum forcewake_domain_id id; + enum forcewake_domains fw = 0, active_domains; /* Hold uncore.lock across reset to prevent any register access * with forcewake not set correctly. Wait until all pending @@ -353,11 +355,11 @@ void intel_uncore_sanitize(struct drm_device *dev) * intel_uncore_forcewake_put() at the end of the sequence. */ void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv, - unsigned fw_domains) + enum forcewake_domains fw_domains) { unsigned long irqflags; struct intel_uncore_forcewake_domain *domain; - int id; + enum forcewake_domain_id id; if (!dev_priv->uncore.funcs.force_wake_get) return; @@ -383,11 +385,11 @@ void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv, * see intel_uncore_forcewake_get() */ void intel_uncore_forcewake_put(struct drm_i915_private *dev_priv, - unsigned fw_domains) + enum forcewake_domains fw_domains) { unsigned long irqflags; struct intel_uncore_forcewake_domain *domain; - int id; + enum forcewake_domain_id id; if (!dev_priv->uncore.funcs.force_wake_put) return; @@ -413,7 +415,7 @@ void intel_uncore_forcewake_put(struct drm_i915_private *dev_priv, void assert_forcewakes_inactive(struct drm_i915_private *dev_priv) { struct intel_uncore_forcewake_domain *domain; - int id; + enum forcewake_domain_id id; if (!dev_priv->uncore.funcs.force_wake_get) return; @@ -583,10 +585,10 @@ __gen2_read(64) return val static inline void __force_wake_get(struct drm_i915_private *dev_priv, - unsigned fw_domains) + enum forcewake_domains fw_domains) { struct intel_uncore_forcewake_domain *domain; - int id; + enum forcewake_domain_id id; if (WARN_ON(!fw_domains)) return; @@ -651,7 +653,7 @@ chv_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \ #define __gen9_read(x) \ static u##x \ gen9_read##x(struct drm_i915_private *dev_priv, off_t reg, bool trace) { \ - unsigned fw_engine; \ + enum forcewake_domains fw_engine; \ GEN6_READ_HEADER(x); \ if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg))) \ fw_engine = 0; \ @@ -851,7 +853,7 @@ static bool is_gen9_shadowed(struct drm_i915_private *dev_priv, u32 reg) static void \ gen9_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, \ bool trace) { \ - unsigned fw_engine; \ + enum forcewake_domains fw_engine; \ GEN6_WRITE_HEADER; \ if (!SKL_NEEDS_FORCE_WAKE((dev_priv), (reg)) || \ is_gen9_shadowed(dev_priv, reg)) \ @@ -917,7 +919,8 @@ do { \ static void fw_domain_init(struct drm_i915_private *dev_priv, - u32 domain_id, u32 reg_set, u32 reg_ack) + enum forcewake_domain_id domain_id, + u32 reg_set, u32 reg_ack) { struct intel_uncore_forcewake_domain *d;