From patchwork Fri Mar 7 09:59:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sourab.gupta@intel.com X-Patchwork-Id: 3789001 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 36D0E9F1CD for ; Fri, 7 Mar 2014 09:59:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6ADA220274 for ; Fri, 7 Mar 2014 09:59:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 947B0201B4 for ; Fri, 7 Mar 2014 09:59:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56902FAD08; Fri, 7 Mar 2014 01:59:14 -0800 (PST) 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 4F209FAD08 for ; Fri, 7 Mar 2014 01:59:12 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 07 Mar 2014 01:59:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,606,1389772800"; d="scan'208";a="468301834" Received: from sourabgu-desktop.iind.intel.com ([10.223.82.69]) by orsmga001.jf.intel.com with ESMTP; 07 Mar 2014 01:59:09 -0800 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 7 Mar 2014 15:29:25 +0530 Message-Id: <1394186367-20339-2-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394186367-20339-1-git-send-email-sourab.gupta@intel.com> References: <1394186367-20339-1-git-send-email-sourab.gupta@intel.com> Cc: Daniel Vetter , Sourab Gupta , Akash Goel , Chris Wilson Subject: [Intel-gfx] [PATCH 1/3] drm/i915: Added a new 'I915_CPU_MAP_NOT_NEEDED' flag to gem_create ioctl. 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org 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 From: Sourab Gupta Adding the flag 'I915_CPU_MAP_NOT_NEEDED' to gem_create ioctl. This is to indicate the driver that direct cpu access to this buffer object is not needed and hence Driver can opt to use Stolen area as a backing store for it. When this flag is set, try to allocate the objects from Stolen area. Fallback to shmem in case of allocation failure. Signed-off-by: Sourab Gupta Signed-off-by: Akash Goel --- drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++----- include/uapi/drm/i915_drm.h | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 177c207..22b531a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -225,9 +225,11 @@ static int i915_gem_create(struct drm_file *file, struct drm_device *dev, uint64_t size, - uint32_t *handle_p) + uint32_t *handle_p, + uint32_t flags) + { - struct drm_i915_gem_object *obj; + struct drm_i915_gem_object *obj=NULL; int ret; u32 handle; @@ -236,7 +238,12 @@ i915_gem_create(struct drm_file *file, return -EINVAL; /* Allocate the new object */ - obj = i915_gem_alloc_object(dev, size); + if (flags & I915_CPU_MAP_NOT_NEEDED) + obj = i915_gem_object_create_stolen(dev, size); + + if (obj == NULL) + obj = i915_gem_alloc_object(dev, size); + if (obj == NULL) return -ENOMEM; @@ -259,7 +266,7 @@ i915_gem_dumb_create(struct drm_file *file, args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64); args->size = args->pitch * args->height; return i915_gem_create(file, dev, - args->size, &args->handle); + args->size, &args->handle, args->flags); } /** @@ -272,7 +279,7 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data, struct drm_i915_gem_create *args = data; return i915_gem_create(file, dev, - args->size, &args->handle); + args->size, &args->handle, args->flags); } static inline int diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 126bfaa..8625f54 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -431,7 +431,8 @@ struct drm_i915_gem_create { * Object handles are nonzero. */ __u32 handle; - __u32 pad; + __u32 flags; +#define I915_CPU_MAP_NOT_NEEDED 0x1 }; struct drm_i915_gem_pread {