From patchwork Thu Oct 28 06:16:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenyu Wang X-Patchwork-Id: 287012 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9S6GVkN006452 for ; Thu, 28 Oct 2010 06:16:51 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C74679EB09 for ; Wed, 27 Oct 2010 23:16:30 -0700 (PDT) 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 D46609EB1A for ; Wed, 27 Oct 2010 23:16:07 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 27 Oct 2010 23:16:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.58,249,1286175600"; d="scan'208";a="568091670" Received: from snb-beast.sh.intel.com ([10.239.36.39]) by orsmga002.jf.intel.com with ESMTP; 27 Oct 2010 23:16:07 -0700 From: Zhenyu Wang To: intel-gfx@lists.freedesktop.org Date: Thu, 28 Oct 2010 14:16:09 +0800 Message-Id: <1288246569-5720-1-git-send-email-zhenyuw@linux.intel.com> X-Mailer: git-send-email 1.7.1 Subject: [Intel-gfx] [PATCH v2] drm/i915: set scanout buffer as uncached on Sandybridge X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 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+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Oct 2010 06:16:51 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2c2c19b..5948e05 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1025,6 +1025,7 @@ void i915_gem_object_unpin(struct drm_gem_object *obj); int i915_gem_object_unbind(struct drm_gem_object *obj); void i915_gem_release_mmap(struct drm_gem_object *obj); void i915_gem_lastclose(struct drm_device *dev); +int i915_gem_object_enable_scanout(struct drm_gem_object *obj); /** * Returns true if seq1 is later than seq2. diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8eb8453..78f6789 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4028,6 +4028,26 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, } int +i915_gem_object_enable_scanout(struct drm_gem_object *obj) +{ + struct drm_device *dev = obj->dev; + struct drm_i915_gem_object *obj_priv = to_intel_bo(obj); + int type = IS_GEN6(dev) ? AGP_USER_UNCACHED_MEMORY : AGP_USER_MEMORY; + + if (obj_priv->agp_type == type) + return 0; + + if (obj_priv->gtt_space) { + int ret = i915_gem_object_unbind(obj); + if (ret) + return ret; + } + + obj_priv->agp_type = type; + return 0; +} + +int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment) { struct drm_device *dev = obj->dev; diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 990f065..a413db6 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -1461,6 +1461,10 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev, BUG(); } + ret = i915_gem_object_enable_scanout(obj); + if (ret) + return ret; + ret = i915_gem_object_pin(obj, alignment); if (ret) return ret; @@ -5482,6 +5486,12 @@ intel_user_framebuffer_create(struct drm_device *dev, if (!intel_fb) return ERR_PTR(-ENOMEM); + ret = i915_gem_object_enable_scanout(obj); + if (ret) { + kfree(intel_fb); + return ERR_PTR(ret); + } + ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); if (ret) {