From: Ben Widawsky Subject: =?utf-8?q?_=5BRFC=5D_=5BPATCH_2/8=5D_drm/i915/context?= =?utf-8?q?=3A_Preliminary_context_support?= Date: Sat, 26 Feb 2011 10:30:12 -0800 Message-ID: <1298745018-5937-3-git-send-email-bwidawsk@gmail.com> References: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0747295834==" Return-path: Received: from mail-iy0-f177.google.com (mail-iy0-f177.google.com [209.85.210.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 887759E8B3 for ; Sat, 26 Feb 2011 10:30:35 -0800 (PST) Received: by mail-iy0-f177.google.com with SMTP id 40so1907628iyf.36 for ; Sat, 26 Feb 2011 10:30:35 -0800 (PST) In-Reply-To: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0747295834== Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Created a new file i915_context.c which will hold a majority of the context related code. This file has nulled functions that get called by the proper part of the i915 driver. This of course requires a Makefile addition, as well as calls to the new nulled functions from the other partsd of the driver (i915_dma.c). Created 2 new ioctls, one for creating a context, and one for destroying a context. These are defined in the necessary places, and again have null functionality --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_context.c | 69 +++++++++++++++++++++++++++++= ++++++ drivers/gpu/drm/i915/i915_dma.c | 8 ++++ drivers/gpu/drm/i915/i915_drv.h | 31 ++++++++++++++++ include/drm/i915_drm.h | 16 ++++++++ 5 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_context.c diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefil= e index 0ae6a7c..fa52bc0 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -6,6 +6,7 @@ ccflags-y :=3D -Iinclude/drm i915-y :=3D i915_drv.o i915_dma.o i915_irq.o i915_mem.o \ i915_debugfs.o \ i915_suspend.o \ + i915_context.o \ i915_gem.o \ i915_gem_debug.o \ i915_gem_evict.o \ diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i= 915_context.c new file mode 100644 index 0000000..bae7274 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_context.c @@ -0,0 +1,69 @@ +/* + * Copyright =A9 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining= a + * copy of this software and associated documentation files (the "Softwa= re"), + * to deal in the Software without restriction, including without limita= tion + * the rights to use, copy, modify, merge, publish, distribute, sublicen= se, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the = next + * paragraph) shall be included in all copies or substantial portions of= the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D= EALINGS + * IN THE SOFTWARE. + * + * Authors: + * Ben Widawsky + */ + +#include "drmP.h" +#include "i915_drm.h" + +int i915_context_create_ioctl(struct drm_device *dev, void *data, + struct drm_file *file) +{ + struct drm_i915_gem_context_create *args =3D data; + args->ctx_id =3D 0; + return -EIO; +} + +int i915_context_destroy_ioctl(struct drm_device *dev, void *data, + struct drm_file *file) +{ + struct drm_i915_gem_context_destroy *args =3D data; + return -EINVAL; +} + +void i915_context_load(struct drm_device *dev) +{ + +} + +void i915_context_unload(struct drm_device *dev) +{ + +} + +void i915_context_open(struct drm_device *dev, struct drm_file *file) +{ + +} + +void i915_context_close(struct drm_device *dev, struct drm_file *file) +{ + +} + +struct drm_i915_gem_context *i915_get_context(struct drm_file *file, + uint32_t id) +{ + return NULL; +} diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_= dma.c index ffa2196..5dd2fca 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -2041,6 +2041,8 @@ int i915_driver_load(struct drm_device *dev, unsign= ed long flags) =20 ips_ping_for_i915_load(); =20 + i915_context_load(dev); + return 0; =20 out_gem_unload: @@ -2066,6 +2068,8 @@ int i915_driver_unload(struct drm_device *dev) struct drm_i915_private *dev_priv =3D dev->dev_private; int ret; =20 + i915_context_unload(dev); + spin_lock(&mchdev_lock); i915_mch_dev =3D NULL; spin_unlock(&mchdev_lock); @@ -2166,6 +2170,7 @@ int i915_driver_open(struct drm_device *dev, struct= drm_file *file) spin_lock_init(&file_priv->mm.lock); INIT_LIST_HEAD(&file_priv->mm.request_list); =20 + i915_context_open(dev, file); return 0; } =20 @@ -2202,6 +2207,7 @@ void i915_driver_lastclose(struct drm_device * dev) void i915_driver_preclose(struct drm_device * dev, struct drm_file *file= _priv) { drm_i915_private_t *dev_priv =3D dev->dev_private; + i915_context_close(dev, file_priv); i915_gem_release(dev, file_priv); if (!drm_core_check_feature(dev, DRIVER_MODESET)) i915_mem_release(dev, file_priv, dev_priv->agp_heap); @@ -2255,6 +2261,8 @@ struct drm_ioctl_desc i915_ioctls[] =3D { DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKE= D), DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_= MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|D= RM_CONTROL_ALLOW|DRM_UNLOCKED), + DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_context_create_ioctl, D= RM_UNLOCKED), + DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_context_destroy_ioctl,= DRM_UNLOCKED), }; =20 int i915_max_ioctl =3D DRM_ARRAY_SIZE(i915_ioctls); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_= drv.h index 3d4fd01..3bd9875 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -892,6 +892,22 @@ struct drm_i915_file_private { struct spinlock lock; struct list_head request_list; } mm; + + struct spinlock context_idr_lock; + struct idr context_idr; +}; + +struct drm_i915_gem_context { + struct drm_device *dev; + struct drm_file *file; + + uint32_t id; + struct drm_gem_object *obj; + uint8_t ring_enable; + bool is_default; + + struct drm_gem_object **bufs; + int slot_count; }; =20 enum intel_chip_family { @@ -961,6 +977,9 @@ enum intel_chip_family { #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) =3D=3D PCH_CPT) #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) =3D=3D PCH_IBX) =20 +#define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)->gen >=3D 4) +#define HAS_PPGTT(dev) (INTEL_INFO(dev)->gen >=3D 7) + #include "i915_trace.h" =20 extern struct drm_ioctl_desc i915_ioctls[]; @@ -1123,6 +1142,18 @@ void i915_gem_object_move_to_active(struct drm_i91= 5_gem_object *obj, struct intel_ring_buffer *ring, u32 seqno); =20 +/* i915_context.c */ +int i915_context_create_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); +int i915_context_destroy_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); +extern void i915_context_load(struct drm_device *dev); +extern void i915_context_unload(struct drm_device *dev); +extern void i915_context_open(struct drm_device *dev, struct drm_file *f= ile); +extern void i915_context_close(struct drm_device *dev, struct drm_file *= file); +extern struct drm_i915_gem_context *i915_get_context(struct drm_file *fi= le, + uint32_t id); + /** * Returns true if seq1 is later than seq2. */ diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index 0039f1f..28e3c5f 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -198,6 +198,8 @@ typedef struct _drm_i915_sarea { #define DRM_I915_OVERLAY_PUT_IMAGE 0x27 #define DRM_I915_OVERLAY_ATTRS 0x28 #define DRM_I915_GEM_EXECBUFFER2 0x29 +#define DRM_I915_GEM_CONTEXT_CREATE 0x2a +#define DRM_I915_GEM_CONTEXT_DESTROY 0x2b =20 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, = drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH= ) @@ -239,6 +241,9 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_= GEM_MADVISE, struct drm_i915_gem_madvise) #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_= IOCTL_I915_OVERLAY_ATTRS, struct drm_intel_overlay_put_image) #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I91= 5_OVERLAY_ATTRS, struct drm_intel_overlay_attrs) +#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + D= RM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create) +#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + D= RM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy) + =20 /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. @@ -843,4 +848,15 @@ struct drm_intel_overlay_attrs { __u32 gamma5; }; =20 +struct drm_i915_gem_context_create { + /* input: number of slots to allocate */ + __s32 slot_count; + /* output: id of new context*/ + __u32 ctx_id; +}; + +struct drm_i915_gem_context_destroy { + __u32 ctx_id; +}; + #endif /* _I915_DRM_H_ */ --=20 1.7.3.4 --===============0747295834== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0747295834==--