Commit 32d1f698 authored by Thomas Hellstrom's avatar Thomas Hellstrom

drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct

Add a pointer to the struct vm_operations_struct in the bo_device, and
assign that pointer to the default value currently used.

The driver can then optionally modify that pointer and the new value
can be used for each new vma created.

Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
parent 4fe51e9e
...@@ -1739,6 +1739,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, ...@@ -1739,6 +1739,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
mutex_lock(&ttm_global_mutex); mutex_lock(&ttm_global_mutex);
list_add_tail(&bdev->device_list, &glob->device_list); list_add_tail(&bdev->device_list, &glob->device_list);
mutex_unlock(&ttm_global_mutex); mutex_unlock(&ttm_global_mutex);
bdev->vm_ops = &ttm_bo_vm_ops;
return 0; return 0;
out_no_sys: out_no_sys:
......
...@@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr, ...@@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
return ret; return ret;
} }
static const struct vm_operations_struct ttm_bo_vm_ops = { const struct vm_operations_struct ttm_bo_vm_ops = {
.fault = ttm_bo_vm_fault, .fault = ttm_bo_vm_fault,
.open = ttm_bo_vm_open, .open = ttm_bo_vm_open,
.close = ttm_bo_vm_close, .close = ttm_bo_vm_close,
...@@ -448,7 +448,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma, ...@@ -448,7 +448,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out_unref; goto out_unref;
vma->vm_ops = &ttm_bo_vm_ops; vma->vm_ops = bdev->vm_ops;
/* /*
* Note: We're transferring the bo reference to * Note: We're transferring the bo reference to
...@@ -480,7 +480,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo) ...@@ -480,7 +480,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
ttm_bo_get(bo); ttm_bo_get(bo);
vma->vm_ops = &ttm_bo_vm_ops; vma->vm_ops = bo->bdev->vm_ops;
vma->vm_private_data = bo; vma->vm_private_data = bo;
vma->vm_flags |= VM_MIXEDMAP; vma->vm_flags |= VM_MIXEDMAP;
vma->vm_flags |= VM_IO | VM_DONTEXPAND; vma->vm_flags |= VM_IO | VM_DONTEXPAND;
......
...@@ -442,6 +442,9 @@ extern struct ttm_bo_global { ...@@ -442,6 +442,9 @@ extern struct ttm_bo_global {
* @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
* @man: An array of mem_type_managers. * @man: An array of mem_type_managers.
* @vma_manager: Address space manager * @vma_manager: Address space manager
* @vm_ops: Pointer to the struct vm_operations_struct used for this
* device's VM operations. The driver may override this before the first
* mmap() call.
* lru_lock: Spinlock that protects the buffer+device lru lists and * lru_lock: Spinlock that protects the buffer+device lru lists and
* ddestroy lists. * ddestroy lists.
* @dev_mapping: A pointer to the struct address_space representing the * @dev_mapping: A pointer to the struct address_space representing the
...@@ -460,6 +463,7 @@ struct ttm_bo_device { ...@@ -460,6 +463,7 @@ struct ttm_bo_device {
struct ttm_bo_global *glob; struct ttm_bo_global *glob;
struct ttm_bo_driver *driver; struct ttm_bo_driver *driver;
struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
const struct vm_operations_struct *vm_ops;
/* /*
* Protected by internal locks. * Protected by internal locks.
...@@ -488,6 +492,8 @@ struct ttm_bo_device { ...@@ -488,6 +492,8 @@ struct ttm_bo_device {
bool no_retry; bool no_retry;
}; };
extern const struct vm_operations_struct ttm_bo_vm_ops;
/** /**
* struct ttm_lru_bulk_move_pos * struct ttm_lru_bulk_move_pos
* *
......
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