From patchwork Fri Jan 29 20:57:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8167231 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF6879F440 for ; Fri, 29 Jan 2016 20:57:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2CD720389 for ; Fri, 29 Jan 2016 20:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C57CD20382 for ; Fri, 29 Jan 2016 20:57:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D0A072065; Fri, 29 Jan 2016 12:57:52 -0800 (PST) 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 ESMTP id 3025F6E018 for ; Fri, 29 Jan 2016 12:57:49 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 29 Jan 2016 12:57:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,366,1449561600"; d="scan'208";a="871990748" Received: from svosulli-mobl3.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.193.19]) by orsmga001.jf.intel.com with ESMTP; 29 Jan 2016 12:57:49 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Jan 2016 18:57:39 -0200 Message-Id: <1454101060-23198-2-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <1454101060-23198-1-git-send-email-paulo.r.zanoni@intel.com> References: <1454101060-23198-1-git-send-email-paulo.r.zanoni@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 2/3] drm/i915/fbc: unexport the HW level activation functions 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, 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 The recent introduction of a new caller of dev_priv->fbc.deactivate() is a good example of why we need unexport those functions. Anything outside intel_fbc.c should only call the functions exported by intel_fbc.c, so in order to enforce that, kill the function pointers stored inside dev_priv->fbc and replace them with functions that can't be called from outside intel_fbc.c. This should make it much harder for new code to call these functions from outside intel_fbc.c. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_drv.h | 4 --- drivers/gpu/drm/i915/intel_fbc.c | 65 ++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c921ad8..1cd4431 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -964,10 +964,6 @@ struct intel_fbc { } work; const char *no_fbc_reason; - - bool (*is_active)(struct drm_i915_private *dev_priv); - void (*activate)(struct drm_i915_private *dev_priv); - void (*deactivate)(struct drm_i915_private *dev_priv); }; /** diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c index 5adf6d7..8d3caf2 100644 --- a/drivers/gpu/drm/i915/intel_fbc.c +++ b/drivers/gpu/drm/i915/intel_fbc.c @@ -43,7 +43,7 @@ static inline bool fbc_supported(struct drm_i915_private *dev_priv) { - return dev_priv->fbc.activate != NULL; + return HAS_FBC(dev_priv); } static inline bool fbc_on_pipe_a_only(struct drm_i915_private *dev_priv) @@ -343,6 +343,38 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv) intel_fbc_recompress(dev_priv); } +static bool intel_fbc_hw_is_active(struct drm_i915_private *dev_priv) +{ + if (INTEL_INFO(dev_priv)->gen >= 5) + return ilk_fbc_is_active(dev_priv); + else if (IS_GM45(dev_priv)) + return g4x_fbc_is_active(dev_priv); + else + return i8xx_fbc_is_active(dev_priv); +} + +static void intel_fbc_hw_activate(struct drm_i915_private *dev_priv) +{ + if (INTEL_INFO(dev_priv)->gen >= 7) + gen7_fbc_activate(dev_priv); + else if (INTEL_INFO(dev_priv)->gen >= 5) + ilk_fbc_activate(dev_priv); + else if (IS_GM45(dev_priv)) + g4x_fbc_activate(dev_priv); + else + i8xx_fbc_activate(dev_priv); +} + +static void intel_fbc_hw_deactivate(struct drm_i915_private *dev_priv) +{ + if (INTEL_INFO(dev_priv)->gen >= 5) + ilk_fbc_deactivate(dev_priv); + else if (IS_GM45(dev_priv)) + g4x_fbc_deactivate(dev_priv); + else + i8xx_fbc_deactivate(dev_priv); +} + /** * intel_fbc_is_active - Is FBC active? * @dev_priv: i915 device instance @@ -405,7 +437,7 @@ retry: goto retry; } - fbc->activate(dev_priv); + intel_fbc_hw_activate(dev_priv); work->scheduled = false; @@ -451,7 +483,7 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv) fbc->work.scheduled = false; if (fbc->active) - fbc->deactivate(dev_priv); + intel_fbc_hw_deactivate(dev_priv); } static bool multiple_pipes_ok(struct intel_crtc *crtc) @@ -713,7 +745,7 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc) /* FIXME: We lack the proper locking here, so only run this on the * platforms that need. */ - if (dev_priv->fbc.activate == ilk_fbc_activate) + if (INTEL_INFO(dev_priv)->gen >= 5 && INTEL_INFO(dev_priv)->gen < 7) cache->fb.ilk_ggtt_offset = i915_gem_obj_ggtt_offset(obj); cache->fb.pixel_format = fb->pixel_format; cache->fb.stride = fb->pitches[0]; @@ -1223,30 +1255,13 @@ void intel_fbc_init(struct drm_i915_private *dev_priv) break; } - if (INTEL_INFO(dev_priv)->gen >= 7) { - fbc->is_active = ilk_fbc_is_active; - fbc->activate = gen7_fbc_activate; - fbc->deactivate = ilk_fbc_deactivate; - } else if (INTEL_INFO(dev_priv)->gen >= 5) { - fbc->is_active = ilk_fbc_is_active; - fbc->activate = ilk_fbc_activate; - fbc->deactivate = ilk_fbc_deactivate; - } else if (IS_GM45(dev_priv)) { - fbc->is_active = g4x_fbc_is_active; - fbc->activate = g4x_fbc_activate; - fbc->deactivate = g4x_fbc_deactivate; - } else { - fbc->is_active = i8xx_fbc_is_active; - fbc->activate = i8xx_fbc_activate; - fbc->deactivate = i8xx_fbc_deactivate; - - /* This value was pulled out of someone's hat */ + /* This value was pulled out of someone's hat */ + if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_GM45(dev_priv)) I915_WRITE(FBC_CONTROL, 500 << FBC_CTL_INTERVAL_SHIFT); - } /* We still don't have any sort of hardware state readout for FBC, so * deactivate it in case the BIOS activated it to make sure software * matches the hardware state. */ - if (fbc->is_active(dev_priv)) - fbc->deactivate(dev_priv); + if (intel_fbc_hw_is_active(dev_priv)) + intel_fbc_hw_deactivate(dev_priv); }