Commit bf141a88 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Alex Deucher

drm: Use the same mmap-range offset and size for GEM and TTM

GEM defines DRM_FILE_PAGE_OFFSET_{START,SIZE} constants for the
mmap-able range of addresses. TTM can use them as well.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bed2dd84
...@@ -72,23 +72,6 @@ ...@@ -72,23 +72,6 @@
* up at a later date, and as our interface with shmfs for memory allocation. * up at a later date, and as our interface with shmfs for memory allocation.
*/ */
/*
* We make up offsets for buffer objects so we can recognize them at
* mmap time.
*/
/* pgoff in mmap is an unsigned long, so we need to make sure that
* the faked up offset will fit
*/
#if BITS_PER_LONG == 64
#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
#else
#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1)
#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16)
#endif
/** /**
* drm_gem_init - Initialize the GEM device fields * drm_gem_init - Initialize the GEM device fields
* @dev: drm_devic structure to initialize * @dev: drm_devic structure to initialize
......
...@@ -1646,8 +1646,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, ...@@ -1646,8 +1646,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
goto out_no_sys; goto out_no_sys;
drm_vma_offset_manager_init(&bdev->vma_manager, drm_vma_offset_manager_init(&bdev->vma_manager,
DRM_FILE_PAGE_OFFSET, DRM_FILE_PAGE_OFFSET_START,
0x10000000); DRM_FILE_PAGE_OFFSET_SIZE);
INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue); INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
INIT_LIST_HEAD(&bdev->ddestroy); INIT_LIST_HEAD(&bdev->ddestroy);
bdev->dev_mapping = mapping; bdev->dev_mapping = mapping;
......
...@@ -432,7 +432,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma, ...@@ -432,7 +432,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
struct ttm_buffer_object *bo; struct ttm_buffer_object *bo;
int ret; int ret;
if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
return -EINVAL; return -EINVAL;
bo = ttm_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma)); bo = ttm_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
......
...@@ -29,6 +29,18 @@ ...@@ -29,6 +29,18 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/types.h> #include <linux/types.h>
/* We make up offsets for buffer objects so we can recognize them at
* mmap time. pgoff in mmap is an unsigned long, so we need to make sure
* that the faked up offset will fit
*/
#if BITS_PER_LONG == 64
#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
#else
#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1)
#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16)
#endif
struct drm_file; struct drm_file;
struct drm_vma_offset_file { struct drm_vma_offset_file {
......
...@@ -49,8 +49,6 @@ ...@@ -49,8 +49,6 @@
#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */
#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */
#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
struct ttm_mem_type_manager; struct ttm_mem_type_manager;
struct ttm_mem_type_manager_func { struct ttm_mem_type_manager_func {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment