summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-02-20 13:27:10 +1000
committerDave Airlie <airlied@redhat.com>2008-02-22 13:49:51 +1000
commitcdad850ebc3570e5ff5a0996f36832c965aa8a1d (patch)
tree4e084d4a2be9ba4c3ac90f708c32255b4f823f64 /linux-core
parent0d1cb1e8408d497fec66d9f31603f93800049c75 (diff)
add ioctl to get back memory managed area sized - used for kernel inited areas
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/drm_bo.c37
-rw-r--r--linux-core/drm_drv.c2
-rw-r--r--linux-core/drm_objects.h2
3 files changed, 41 insertions, 0 deletions
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index 54b8baf8..ebba2fa7 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -2289,6 +2289,7 @@ int drm_bo_init_mm(struct drm_device *dev, unsigned type,
man->has_type = 1;
man->use_type = 1;
man->kern_init_type = kern_init;
+ man->size = p_size;
INIT_LIST_HEAD(&man->lru);
INIT_LIST_HEAD(&man->pinned);
@@ -2562,6 +2563,42 @@ int drm_mm_unlock_ioctl(struct drm_device *dev,
return 0;
}
+int drm_mm_info_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
+{
+ struct drm_mm_info_arg *arg = data;
+ struct drm_buffer_manager *bm = &dev->bm;
+ struct drm_bo_driver *driver = dev->driver->bo_driver;
+ struct drm_mem_type_manager *man;
+ int ret = 0;
+ int mem_type = arg->mem_type;
+
+ if (!driver) {
+ DRM_ERROR("Buffer objects are not supported by this driver\n");
+ return -EINVAL;
+ }
+
+ if (mem_type >= DRM_BO_MEM_TYPES) {
+ DRM_ERROR("Illegal memory type %d\n", arg->mem_type);
+ return -EINVAL;
+ }
+
+ mutex_lock(&dev->struct_mutex);
+ if (!bm->initialized) {
+ DRM_ERROR("DRM memory manager was not initialized\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+
+ man = &bm->man[arg->mem_type];
+
+ arg->p_size = man->size;
+
+out:
+ mutex_unlock(&dev->struct_mutex);
+
+ return ret;
+}
/*
* buffer object vm functions.
*/
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 4f5b364e..4932ea59 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -164,6 +164,8 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_BO_INFO, drm_bo_info_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_WAIT_IDLE, drm_bo_wait_idle_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_VERSION, drm_bo_version_ioctl, 0),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_MM_INFO, drm_mm_info_ioctl, 0),
};
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h
index 71da4b27..cce58178 100644
--- a/linux-core/drm_objects.h
+++ b/linux-core/drm_objects.h
@@ -525,6 +525,7 @@ struct drm_mem_type_manager {
unsigned long io_offset;
unsigned long io_size;
void *io_addr;
+ uint64_t size; /* size of managed area for reporting to userspace */
};
struct drm_bo_lock {
@@ -651,6 +652,7 @@ extern int drm_mm_init_ioctl(struct drm_device *dev, void *data, struct drm_file
extern int drm_mm_takedown_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int drm_mm_lock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int drm_mm_unlock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
+extern int drm_mm_info_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int drm_bo_version_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int drm_bo_driver_finish(struct drm_device *dev);
extern int drm_bo_driver_init(struct drm_device *dev);