From patchwork Thu Feb 4 21:05:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 77212 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o14L67f6009069 for ; Thu, 4 Feb 2010 21:06:47 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E71679F574; Thu, 4 Feb 2010 13:05:50 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.ffwll.ch (cable-static-49-187.intergga.ch [157.161.49.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 377299F574 for ; Thu, 4 Feb 2010 13:05:47 -0800 (PST) Received: by mail.ffwll.ch (Postfix, from userid 1000) id 6D2A520C2BE; Thu, 4 Feb 2010 22:05:46 +0100 (CET) X-Spam-ASN: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on orange.ffwll.ch X-Spam-Level: X-Spam-Hammy: 0.000-+--struct, 0.000-+--100644, 0.000-+--signed-off-by X-Spam-Status: No, score=-1.2 required=6.0 tests=ALL_TRUSTED,AWL,BAYES_00, FH_DATE_PAST_20XX autolearn=no version=3.2.5 X-Spam-Spammy: 0.993-1--6996, 0.970-+--H*m:ffwll, 0.965-+--H*Ad:U*daniel.vetter Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id ED28620C1B1; Thu, 4 Feb 2010 22:05:17 +0100 (CET) Received: from daniel by biene with local (Exim 4.71) (envelope-from ) id 1Nd8t7-0004hC-RN; Thu, 04 Feb 2010 22:05:21 +0100 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Thu, 4 Feb 2010 22:05:09 +0100 Message-Id: <1265317513-27723-10-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1265317513-27723-9-git-send-email-daniel.vetter@ffwll.ch> References: <1265317513-27723-1-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-2-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-3-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-4-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-5-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-6-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-7-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-8-git-send-email-daniel.vetter@ffwll.ch> <1265317513-27723-9-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 09/13] drm/i915: track gpu fence usage more precisely X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 21:06:47 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index b4e2f95..f26a037 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -128,6 +128,7 @@ struct drm_i915_master_private { struct drm_i915_fence_reg { struct drm_gem_object *obj; + uint32_t last_rendering_seqno; struct list_head lru_list; }; @@ -617,13 +618,38 @@ struct drm_i915_gem_object { * (has pending rendering), and is not set if it's on inactive (ready * to be unbound). */ - int active; + int active : 1; /** * This is set if the object has been written to since last bound * to the GTT */ - int dirty; + int dirty : 1; + + /** + * Used for checking the object doesn't appear more than once + * in an execbuffer object list. + */ + int in_execbuffer : 1; + + /** + * Used to decide whether to update fence lru and seqno when flushing + * gpu writes. + * */ + int fenced_gpu_access : 1; + + /** + * Fence register bits (if any) for this object. Will be set + * as needed when mapped into the GTT. + * Protected by dev->struct_mutex. + * Size: 16 fences + sign (for FENCE_REG_NONE): 5 bits + */ + int fence_reg : 5; + + /** + * Advice: are the backing pages purgeable? + */ + int madv : 3; /** AGP memory structure for our GTT binding. */ DRM_AGP_MEM *agp_mem; @@ -643,13 +669,6 @@ struct drm_i915_gem_object { */ uint64_t mmap_offset; - /** - * Fence register bits (if any) for this object. Will be set - * as needed when mapped into the GTT. - * Protected by dev->struct_mutex. - */ - int fence_reg; - /** How many users have pinned this object in GTT space */ int pin_count; @@ -680,17 +699,6 @@ struct drm_i915_gem_object { struct drm_i915_gem_phys_object *phys_obj; /** - * Used for checking the object doesn't appear more than once - * in an execbuffer object list. - */ - int in_execbuffer; - - /** - * Advice: are the backing pages purgeable? - */ - int madv; - - /** * Number of crtcs where this object is currently the fb, but * will be page flipped away on the next vblank. When it * reaches 0, dev_priv->pending_flip_queue will be woken up. diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 72a5308..9af6e9c 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1520,6 +1520,12 @@ i915_gem_object_move_to_active(struct drm_gem_object *obj) obj_priv->active = 1; } + if (obj_priv->fenced_gpu_access) { + struct drm_i915_fence_reg *reg = + &dev_priv->fence_regs[obj_priv->fence_reg]; + reg->last_rendering_seqno = obj_priv->last_rendering_seqno; + } + /* Move from whatever list we were on to the tail of execution. */ spin_lock(&dev_priv->mm.active_list_lock); list_move_tail(&obj_priv->list, @@ -1566,6 +1572,8 @@ i915_gem_object_move_to_inactive(struct drm_gem_object *obj) struct drm_device *dev = obj->dev; drm_i915_private_t *dev_priv = dev->dev_private; struct drm_i915_gem_object *obj_priv = obj->driver_private; + struct drm_i915_fence_reg *reg = + &dev_priv->fence_regs[obj_priv->fence_reg]; i915_verify_inactive(dev, __FILE__, __LINE__); if (obj_priv->pin_count != 0) @@ -1576,6 +1584,8 @@ i915_gem_object_move_to_inactive(struct drm_gem_object *obj) BUG_ON(!list_empty(&obj_priv->gpu_write_list)); obj_priv->last_rendering_seqno = 0; + obj_priv->fenced_gpu_access = 0; + reg->last_rendering_seqno = 0; if (obj_priv->active) { obj_priv->active = 0; drm_gem_object_unreference(obj); @@ -3320,7 +3330,9 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj, i915_gem_object_unpin(obj); return ret; } - } + obj_priv->fenced_gpu_access = 1; + } else + obj_priv->fenced_gpu_access = 0; entry->offset = obj_priv->gtt_offset; @@ -3722,7 +3734,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_i915_gem_object *obj_priv; struct drm_clip_rect *cliprects = NULL; struct drm_i915_gem_relocation_entry *relocs; - int ret = 0, ret2, i, pinned = 0; + int ret = 0, ret2, i, pinned = 0, fixup_pinned = 1; uint64_t exec_offset; uint32_t seqno, reloc_index; int pin_tries, flips; @@ -3987,7 +3999,20 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, i915_verify_inactive(dev, __FILE__, __LINE__); + fixup_pinned = 0; err: + if (fixup_pinned) { + for (i = 0; i < pinned; i++) { + obj_priv = object_list[i]->driver_private; + /* we have clobbered obj_priv->fenced_gpu_access + * set it to a save value */ + if (obj_priv->active) + obj_priv->fenced_gpu_access = 1; + else + obj_priv->fenced_gpu_access = 0; + } + } + for (i = 0; i < pinned; i++) i915_gem_object_unpin(object_list[i]);