mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 08:10:11 +01:00
Make the user_token 44-bit for TTMs, and have them occupy a unique file space
starting at 0x00100000000. This will hopefully allow us to use unmap_mapping_range(). Note that user-space will need 64-bit file offset support.
This commit is contained in:
parent
a31046b873
commit
eacedf41a6
3 changed files with 30 additions and 8 deletions
|
|
@ -30,6 +30,7 @@ AC_PROG_LIBTOOL
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
pkgconfigdir=${libdir}/pkgconfig
|
pkgconfigdir=${libdir}/pkgconfig
|
||||||
AC_SUBST(pkgconfigdir)
|
AC_SUBST(pkgconfigdir)
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
|
# ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
# endif
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|
@ -2804,7 +2807,7 @@ int drmBOUnReference(int fd, drmBO *buf)
|
||||||
|
|
||||||
|
|
||||||
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
||||||
(void) drmUnmap(buf->mapVirtual, buf->start + buf->size);
|
(void) munmap(buf->mapVirtual, buf->start + buf->size);
|
||||||
buf->mapVirtual = NULL;
|
buf->mapVirtual = NULL;
|
||||||
buf->virtual = NULL;
|
buf->virtual = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2847,8 +2850,12 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
|
|
||||||
if (!buf->virtual && buf->type != drm_bo_type_fake) {
|
if (!buf->virtual && buf->type != drm_bo_type_fake) {
|
||||||
drmAddress virtual;
|
drmAddress virtual;
|
||||||
ret = drmMap(fd, buf->mapHandle, buf->size + buf->start, &virtual);
|
virtual = mmap(0, buf->size + buf->start,
|
||||||
if (ret)
|
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
|
fd, buf->mapHandle);
|
||||||
|
if (virtual == MAP_FAILED)
|
||||||
|
ret = -errno;
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
buf->mapVirtual = virtual;
|
buf->mapVirtual = virtual;
|
||||||
buf->virtual = ((char *) virtual) + buf->start;
|
buf->virtual = ((char *) virtual) + buf->start;
|
||||||
|
|
|
||||||
|
|
@ -817,6 +817,11 @@ static void drm_ttm_object_remove(drm_device_t * dev, drm_ttm_object_t * object)
|
||||||
if (list->user_token)
|
if (list->user_token)
|
||||||
drm_ht_remove_item(&dev->map_hash, &list->hash);
|
drm_ht_remove_item(&dev->map_hash, &list->hash);
|
||||||
|
|
||||||
|
if (list->file_offset_node) {
|
||||||
|
drm_mm_put_block(&dev->offset_manager, list->file_offset_node);
|
||||||
|
list->file_offset_node = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
map = list->map;
|
map = list->map;
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
|
|
@ -901,15 +906,24 @@ int drm_ttm_object_create(drm_device_t * dev, unsigned long size,
|
||||||
map->size = ttm->num_pages * PAGE_SIZE;
|
map->size = ttm->num_pages * PAGE_SIZE;
|
||||||
map->handle = (void *)object;
|
map->handle = (void *)object;
|
||||||
|
|
||||||
if (drm_ht_just_insert_please(&dev->map_hash, &list->hash,
|
list->file_offset_node = drm_mm_search_free(&dev->offset_manager,
|
||||||
(unsigned long)map->handle,
|
ttm->num_pages,
|
||||||
32 - PAGE_SHIFT - 3, 0,
|
0,0);
|
||||||
DRM_MAP_HASH_OFFSET >> PAGE_SHIFT)) {
|
if (!list->file_offset_node) {
|
||||||
|
drm_ttm_object_remove(dev, object);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
list->file_offset_node = drm_mm_get_block(list->file_offset_node,
|
||||||
|
ttm->num_pages,0);
|
||||||
|
|
||||||
|
list->hash.key = list->file_offset_node->start;
|
||||||
|
|
||||||
|
if (drm_ht_insert_item(&dev->map_hash, &list->hash)) {
|
||||||
drm_ttm_object_remove(dev, object);
|
drm_ttm_object_remove(dev, object);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
list->user_token = list->hash.key << PAGE_SHIFT;
|
list->user_token = ((drm_u64_t) list->hash.key) << PAGE_SHIFT;
|
||||||
|
|
||||||
atomic_set(&object->usage, 1);
|
atomic_set(&object->usage, 1);
|
||||||
*ttm_object = object;
|
*ttm_object = object;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue