[Intel-gfx] [RFC] [PATCH 2/8] drm/i915/context: Preliminary context support
Ben Widawsky
bwidawsk at gmail.com
Sat Feb 26 19:30:12 CET 2011
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/Makefile
index 0ae6a7c..fa52bc0 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -6,6 +6,7 @@ ccflags-y := -Iinclude/drm
i915-y := 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/i915_context.c
new file mode 100644
index 0000000..bae7274
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_context.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ben Widawsky <bwidawsk at gmail.com>
+ */
+
+#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 = data;
+ args->ctx_id = 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 = 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, unsigned long flags)
ips_ping_for_i915_load();
+ i915_context_load(dev);
+
return 0;
out_gem_unload:
@@ -2066,6 +2068,8 @@ int i915_driver_unload(struct drm_device *dev)
struct drm_i915_private *dev_priv = dev->dev_private;
int ret;
+ i915_context_unload(dev);
+
spin_lock(&mchdev_lock);
i915_mch_dev = 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);
+ i915_context_open(dev, file);
return 0;
}
@@ -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 = 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[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKED),
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|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_context_create_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_context_destroy_ioctl, DRM_UNLOCKED),
};
int i915_max_ioctl = 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;
};
enum intel_chip_family {
@@ -961,6 +977,9 @@ enum intel_chip_family {
#define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
#define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
+#define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)->gen >= 4)
+#define HAS_PPGTT(dev) (INTEL_INFO(dev)->gen >= 7)
+
#include "i915_trace.h"
extern struct drm_ioctl_desc i915_ioctls[];
@@ -1123,6 +1142,18 @@ void i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
struct intel_ring_buffer *ring,
u32 seqno);
+/* 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 *file);
+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 *file,
+ 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
#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_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
+#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
+#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
+
/* 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;
};
+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_ */
--
1.7.3.4
More information about the Intel-gfx
mailing list