From patchwork Fri Mar 27 11:09:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonas Lahtinen X-Patchwork-Id: 6105541 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 473089F399 for ; Fri, 27 Mar 2015 11:09:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20DBA203ED for ; Fri, 27 Mar 2015 11:09:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DF359203B7 for ; Fri, 27 Mar 2015 11:09:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7811B7A038; Fri, 27 Mar 2015 04:09:34 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 772BB7A038 for ; Fri, 27 Mar 2015 04:09:32 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 27 Mar 2015 04:09:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,478,1422950400"; d="scan'208";a="686505399" Received: from jlahtine-mobl1.ger.corp.intel.com (HELO [10.252.25.233]) ([10.252.25.233]) by fmsmga001.fm.intel.com with ESMTP; 27 Mar 2015 04:09:23 -0700 Message-ID: <1427454562.4966.10.camel@jlahtine-mobl1> From: Joonas Lahtinen To: intel-gfx@lists.freedesktop.org, Tvrtko Ursulin Date: Fri, 27 Mar 2015 13:09:22 +0200 In-reply-to: <551533CD.8000506@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Subject: [Intel-gfx] [PATCH v4] drm/i915: Compare GGTT view structs instead of types 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: , 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 To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view. This allows including parameters like offset to be included in the view which is useful for eg. partial views. v3: - Rely on ggtt_view type being 0 for non-GGTT vma's, which equals to I915_GGTT_VIEW_NORMAL. (Daniel Vetter) - Do not use potentially slower comparison when we only want to know if something is or is not a normal view. - Rebase on top of rotated view patches. Add rotated view singleton. - If one view is missing in comparison they're equal only if both are missing. v4: - Use comparison helper in obj_to_ggtt_view too. (Tvrtko Ursulin) - Do WARN_ON if one view is NULL. (Tvrtko Ursulin) Cc: Daniel Vetter Reviewed-by: Tvrtko Ursulin (v2) Signed-off-by: Joonas Lahtinen Reviewed-by: Tvrtko Ursulin Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com) --- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 16 +++++++++------- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ drivers/gpu/drm/i915/i915_gem_gtt.h | 11 +++++++++++ drivers/gpu/drm/i915/intel_display.c | 8 +++----- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 256369f..5aeba60 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2794,19 +2794,19 @@ void i915_gem_restore_fences(struct drm_device *dev); unsigned long i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o, - enum i915_ggtt_view_type view); + const struct i915_ggtt_view *view); unsigned long i915_gem_obj_offset(struct drm_i915_gem_object *o, struct i915_address_space *vm); static inline unsigned long i915_gem_obj_ggtt_offset(struct drm_i915_gem_object *o) { - return i915_gem_obj_ggtt_offset_view(o, I915_GGTT_VIEW_NORMAL); + return i915_gem_obj_ggtt_offset_view(o, &i915_ggtt_view_normal); } bool i915_gem_obj_bound_any(struct drm_i915_gem_object *o); bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o, - enum i915_ggtt_view_type view); + const struct i915_ggtt_view *view); bool i915_gem_obj_bound(struct drm_i915_gem_object *o, struct i915_address_space *vm); @@ -2854,7 +2854,7 @@ i915_vm_to_ppgtt(struct i915_address_space *vm) static inline bool i915_gem_obj_ggtt_bound(struct drm_i915_gem_object *obj) { - return i915_gem_obj_ggtt_bound_view(obj, I915_GGTT_VIEW_NORMAL); + return i915_gem_obj_ggtt_bound_view(obj, &i915_ggtt_view_normal); } static inline unsigned long diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 3300963..5a4b564 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4131,7 +4131,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj, if (i915_vma_misplaced(vma, alignment, flags)) { unsigned long offset; - offset = ggtt_view ? i915_gem_obj_ggtt_offset_view(obj, ggtt_view->type) : + offset = ggtt_view ? i915_gem_obj_ggtt_offset_view(obj, ggtt_view) : i915_gem_obj_offset(obj, vm); WARN(vma->pin_count, "bo is already pinned in %s with incorrect alignment:" @@ -4230,7 +4230,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj, BUG_ON(!vma); WARN_ON(vma->pin_count == 0); - WARN_ON(!i915_gem_obj_ggtt_bound_view(obj, view->type)); + WARN_ON(!i915_gem_obj_ggtt_bound_view(obj, view)); if (--vma->pin_count == 0 && view->type == I915_GGTT_VIEW_NORMAL) obj->pin_mappable = false; @@ -4552,7 +4552,8 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj, return ERR_PTR(-EINVAL); list_for_each_entry(vma, &obj->vma_list, vma_link) - if (vma->vm == ggtt && vma->ggtt_view.type == view->type) + if (vma->vm == ggtt && + i915_ggtt_view_equal(&vma->ggtt_view, view)) return vma; return NULL; } @@ -5109,13 +5110,14 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o, unsigned long i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o, - enum i915_ggtt_view_type view) + const struct i915_ggtt_view *view) { struct i915_address_space *ggtt = i915_obj_to_ggtt(o); struct i915_vma *vma; list_for_each_entry(vma, &o->vma_list, vma_link) - if (vma->vm == ggtt && vma->ggtt_view.type == view) + if (vma->vm == ggtt && + i915_ggtt_view_equal(&vma->ggtt_view, view)) return vma->node.start; WARN(1, "global vma for this object not found.\n"); @@ -5139,14 +5141,14 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, } bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o, - enum i915_ggtt_view_type view) + const struct i915_ggtt_view *view) { struct i915_address_space *ggtt = i915_obj_to_ggtt(o); struct i915_vma *vma; list_for_each_entry(vma, &o->vma_list, vma_link) if (vma->vm == ggtt && - vma->ggtt_view.type == view && + i915_ggtt_view_equal(&vma->ggtt_view, view) && drm_mm_node_allocated(&vma->node)) return true; diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 9903bb0..13eb769 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -93,6 +93,9 @@ */ const struct i915_ggtt_view i915_ggtt_view_normal; +const struct i915_ggtt_view i915_ggtt_view_rotated = { + .type = I915_GGTT_VIEW_ROTATED +}; static void bdw_setup_private_ppat(struct drm_i915_private *dev_priv); static void chv_setup_private_ppat(struct drm_i915_private *dev_priv); diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h index 0dad426..d559b23 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.h +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h @@ -138,6 +138,7 @@ struct i915_ggtt_view { }; extern const struct i915_ggtt_view i915_ggtt_view_normal; +extern const struct i915_ggtt_view i915_ggtt_view_rotated; enum i915_cache_level; @@ -422,4 +423,14 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev); int __must_check i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj); void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj); +static inline bool +i915_ggtt_view_equal(const struct i915_ggtt_view *a, + const struct i915_ggtt_view *b) +{ + if (WARN_ON(!a || !b)) + return false; + + return a->type == b->type; +} + #endif diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index cb50854..d6c2e34 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2293,8 +2293,6 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, const struct drm_plane_state *plane_state) { struct intel_rotation_info *info = &view->rotation_info; - static const struct i915_ggtt_view rotated_view = - { .type = I915_GGTT_VIEW_ROTATED }; *view = i915_ggtt_view_normal; @@ -2304,7 +2302,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, if (!intel_rotation_90_or_270(plane_state->rotation)) return 0; - *view = rotated_view; + *view = i915_ggtt_view_rotated; info->height = fb->height; info->pixel_format = fb->pixel_format; @@ -2904,10 +2902,10 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier, unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane, struct drm_i915_gem_object *obj) { - enum i915_ggtt_view_type view = I915_GGTT_VIEW_NORMAL; + const struct i915_ggtt_view *view = &i915_ggtt_view_normal; if (intel_rotation_90_or_270(intel_plane->base.state->rotation)) - view = I915_GGTT_VIEW_ROTATED; + view = &i915_ggtt_view_rotated; return i915_gem_obj_ggtt_offset_view(obj, view); }