From patchwork Fri Oct 19 17:03:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 1619371 X-Patchwork-Delegate: ben@bwidawsk.net Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 8E889DFFAD for ; Fri, 19 Oct 2012 17:13:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 737C39EEEB for ; Fri, 19 Oct 2012 10:13:04 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (smtp.fireflyinternet.com [109.228.6.236]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D27DA0A0D for ; Fri, 19 Oct 2012 10:05:02 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.73.22; Received: from arrandale.alporthouse.com (unverified [78.156.73.22]) by fireflyinternet.com (Firefly Internet SMTP) with ESMTP id 124655239-1500050 for multiple; Fri, 19 Oct 2012 18:04:38 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 19 Oct 2012 18:03:15 +0100 Message-Id: <1350666204-8101-9-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1350666204-8101-1-git-send-email-chris@chris-wilson.co.uk> References: <1350666204-8101-1-git-send-email-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.73.22 Subject: [Intel-gfx] [PATCH 09/18] drm/i915: Differentiate between prime and stolen objects X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 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 Stolen objects also share the property that they have no backing shmemfs filp, but they can be used with pwrite/pread/gtt-mapping. Signed-off-by: Chris Wilson Reviewed-by: Jesse Barnes --- drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/i915_gem.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 055bd08..6b893c7 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1071,6 +1071,11 @@ struct drm_i915_gem_object { atomic_t pending_flip; }; +inline static bool i915_gem_object_is_prime(struct drm_i915_gem_object *obj) +{ + return obj->base.import_attach != NULL; +} + #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base) /** diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eb3316b..29402e3 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -553,7 +553,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, /* prime objects have no backing filp to GEM pread/pwrite * pages from. */ - if (!obj->base.filp) { + if (i915_gem_object_is_prime(obj)) { ret = -EINVAL; goto out; } @@ -902,7 +902,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, /* prime objects have no backing filp to GEM pread/pwrite * pages from. */ - if (!obj->base.filp) { + if (i915_gem_object_is_prime(obj)) { ret = -EINVAL; goto out; }