summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/Makefile.kernel2
-rw-r--r--linux-core/drmP.h4
-rw-r--r--linux-core/drm_memrange.c25
-rw-r--r--shared-core/i915_dma.c2
-rw-r--r--shared-core/i915_drm.h85
-rw-r--r--shared-core/i915_drv.h9
6 files changed, 126 insertions, 1 deletions
diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index 5b309bc1..97d53622 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -20,7 +20,7 @@ r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o
mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
i810-objs := i810_drv.o i810_dma.o
i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_fence.o \
- i915_buffer.o i915_compat.o i915_execbuf.o
+ i915_buffer.o i915_compat.o i915_execbuf.o i915_mm.o
nouveau-objs := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
nouveau_object.o nouveau_irq.o nouveau_notifier.o nouveau_swmthd.o \
nouveau_sgdma.o nouveau_dma.o nouveau_bo.o nouveau_fence.o \
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 29dd4321..113cbecb 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1278,6 +1278,10 @@ extern int drm_memrange_remove_space_from_tail(struct drm_memrange *mm,
unsigned long size);
extern int drm_memrange_add_space_to_tail(struct drm_memrange *mm,
unsigned long size);
+extern int drm_memrange_for_each(struct drm_memrange *mm,
+ int (*callback)(struct drm_memrange_node *node,
+ void *data),
+ void *data);
static inline struct drm_memrange *drm_get_mm(struct drm_memrange_node *block)
{
diff --git a/linux-core/drm_memrange.c b/linux-core/drm_memrange.c
index 0ae03655..e1d2233b 100644
--- a/linux-core/drm_memrange.c
+++ b/linux-core/drm_memrange.c
@@ -273,6 +273,31 @@ int drm_memrange_init(struct drm_memrange * mm, unsigned long start, unsigned lo
return drm_memrange_create_tail_node(mm, start, size);
}
+/**
+ * Walks the list of allocated memory ranges and calls the callback on
+ * one.
+ */
+int drm_memrange_for_each(struct drm_memrange *mm,
+ int (*callback)(struct drm_memrange_node *node,
+ void *data),
+ void *data)
+{
+ struct list_head *list, *next;
+
+ list_for_each_safe(list, next, &mm->ml_entry) {
+ struct drm_memrange_node *cur;
+ int ret;
+
+ cur = list_entry(list, struct drm_memrange_node, ml_entry);
+
+ ret = callback(cur, data);
+ if (ret != 0)
+ return ret;
+ }
+
+ return 0;
+}
+
EXPORT_SYMBOL(drm_memrange_init);
void drm_memrange_takedown(struct drm_memrange * mm)
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 7ccd185c..6c6fd435 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -1124,6 +1124,8 @@ struct drm_ioctl_desc i915_ioctls[] = {
#ifdef I915_HAVE_BUFFER
DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH),
#endif
+ DRM_IOCTL_DEF(DRM_I915_MM_INIT, intel_mm_init_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_I915_MM_EXECBUFFER, intel_mm_execbuffer, DRM_AUTH),
};
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h
index de463614..1a70010b 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -176,6 +176,8 @@ typedef struct drm_i915_sarea {
#define DRM_I915_MMIO 0x10
#define DRM_I915_HWS_ADDR 0x11
#define DRM_I915_EXECBUFFER 0x12
+#define DRM_I915_MM_INIT 0x13
+#define DRM_I915_MM_EXECBUFFER 0x14
#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)
@@ -195,6 +197,8 @@ typedef struct drm_i915_sarea {
#define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
#define DRM_IOCTL_I915_MMIO DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_MMIO, drm_i915_mmio)
#define DRM_IOCTL_I915_EXECBUFFER DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_EXECBUFFER, struct drm_i915_execbuffer)
+#define DRM_IOCTL_I915_MM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_MM_INIT, struct drm_i915_mm_init)
+#define DRM_IOCTL_I915_MM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_MM_INIT, struct drm_i915_mm_execbuffer)
/* Asynchronous page flipping:
*/
@@ -394,4 +398,85 @@ struct drm_i915_execbuffer {
struct drm_fence_arg fence_arg;
};
+struct drm_i915_mm_init {
+ /**
+ * Beginning offset in the GTT to be managed by the DRM memory
+ * manager.
+ */
+ off_t gtt_start;
+ /**
+ * Ending offset in the GTT to be managed by the DRM memory
+ * manager.
+ */
+ off_t gtt_end;
+};
+
+struct drm_i915_relocation_entry {
+ /**
+ * Handle of the buffer being pointed to by this relocation entry.
+ *
+ * It's appealing to make this be an index into the mm_validate_entry
+ * list to refer to the buffer, but handle lookup should be O(1) anyway,
+ * and prevents O(n) search in userland to find what that index is.
+ */
+ uint32_t target_buffer;
+
+ /** Offset in the buffer the relocation entry will be written into */
+ uint32_t offset;
+
+ /**
+ * Value to be added to the offset of the target buffer to make up
+ * the relocation entry.
+ */
+ uint32_t delta;
+
+ /**
+ * Offset value of the target buffer that the relocation entry was last
+ * written as.
+ *
+ * If the buffer has the same offset as last time, we can skip syncing
+ * and writing the relocation. This value is written back out by
+ * the execbuffer ioctl when the relocation is written.
+ */
+ uint32_t presumed_offset;
+};
+
+struct drm_i915_mm_validate_entry {
+ /**
+ * User's handle for a buffer to be bound into the GTT for this
+ * operation.
+ */
+ uint32_t buffer_handle;
+ /**
+ * Returned value of the updated offset of the buffer, for future
+ * presumed_offset writes.
+ */
+ uint32_t buffer_offset;
+ /** List of relocations to be performed on this buffer */
+ struct drm_i915_relocation_entry *relocs;
+ uint32_t relocation_count;
+};
+
+struct drm_i915_mm_execbuffer {
+ /**
+ * List of buffers to be validated wit their relocations to be
+ * performend on them.
+ *
+ * These buffers must be listed in an order such that all relocations
+ * a buffer is performing refer to buffers that have already appeared
+ * in the validate list.
+ */
+ struct drm_i915_mm_validate_entry *buffers;
+ uint32_t buffer_count;
+
+ /** Offset in the batchbuffer to start execution from. */
+ uint32_t batch_start_offset;
+ /** Bytes used in batchbuffer from batch_start_offset */
+ uint32_t batch_len;
+ uint32_t DR1;
+ uint32_t DR4;
+ uint32_t num_cliprects;
+ struct drm_clip_rect *cliprects;
+};
+
#endif /* _I915_DRM_H_ */
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 412a2594..0c6ec588 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -241,6 +241,10 @@ typedef struct drm_i915_private {
u8 saveDACMASK;
u8 saveDACDATA[256*3]; /* 256 3-byte colors */
u8 saveCR[36];
+
+ struct {
+ struct drm_memrange gtt_space;
+ } mm;
} drm_i915_private_t;
enum intel_chip_family {
@@ -329,6 +333,11 @@ void i915_flush_ttm(struct drm_ttm *ttm);
/* i915_execbuf.c */
int i915_execbuffer(struct drm_device *dev, void *data,
struct drm_file *file_priv);
+/* i915_mm.c */
+int intel_mm_init_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+int intel_mm_execbuffer(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
#endif