mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-26 03:00:18 +01:00
add ioctl to get back memory managed area sized - used for kernel inited areas
This commit is contained in:
parent
0d1cb1e840
commit
cdad850ebc
6 changed files with 64 additions and 0 deletions
|
|
@ -2883,6 +2883,21 @@ int drmMMUnlock(int fd, unsigned memType, int unlockBM)
|
|||
return drmIoctlTimeout(fd, DRM_IOCTL_MM_UNLOCK, &arg);
|
||||
}
|
||||
|
||||
int drmMMInfo(int fd, unsigned memType, uint64_t *size)
|
||||
{
|
||||
struct drm_mm_info_arg arg;
|
||||
|
||||
memset(&arg, 0, sizeof(arg));
|
||||
|
||||
arg.mem_type = memType;
|
||||
|
||||
if (ioctl(fd, DRM_IOCTL_MM_INFO, &arg))
|
||||
return -errno;
|
||||
|
||||
*size = arg.p_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmBOVersion(int fd, unsigned int *major,
|
||||
unsigned int *minor,
|
||||
unsigned int *patchlevel)
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ extern int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
|
|||
extern int drmMMTakedown(int fd, unsigned memType);
|
||||
extern int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict);
|
||||
extern int drmMMUnlock(int fd, unsigned memType, int unlockBM);
|
||||
extern int drmMMInfo(int fd, unsigned memType, uint64_t *size);
|
||||
extern int drmBOSetStatus(int fd, drmBO *buf,
|
||||
uint64_t flags, uint64_t mask,
|
||||
unsigned int hint,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -950,6 +950,12 @@ struct drm_mm_init_arg {
|
|||
uint64_t p_size;
|
||||
};
|
||||
|
||||
struct drm_mm_info_arg {
|
||||
unsigned int mem_type;
|
||||
uint64_t p_size;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Drm mode setting
|
||||
*/
|
||||
|
|
@ -1209,6 +1215,7 @@ struct drm_mode_hotplug {
|
|||
#define DRM_IOCTL_BO_INFO DRM_IOWR(0xd4, struct drm_bo_reference_info_arg)
|
||||
#define DRM_IOCTL_BO_WAIT_IDLE DRM_IOWR(0xd5, struct drm_bo_map_wait_idle_arg)
|
||||
#define DRM_IOCTL_BO_VERSION DRM_IOR(0xd6, struct drm_bo_version_arg)
|
||||
#define DRM_IOCTL_MM_INFO DRM_IOWR(0xd7, struct drm_mm_info_arg)
|
||||
|
||||
#define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res)
|
||||
#define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue