Skip to contentSkip to conversation

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

PATCH Koenig, Christian 1 participant 1 message Apr 25, 2019

lore
Share & tools
lore
#0 lore raw

Am 25.04.2019 10:35 schrieb Thomas Hellstrom <[email protected]>:
Hi, Christian,

Quoted 16 lines · Thomas Hellström
Quoted 15 lines · Christian

Am 24.04.19 um 14:00 schrieb Thomas Hellstrom:

Quoted 13 lines

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" <[email protected]>
Quoted 7 lines
Quoted 1 line

Going to pick those two TTM patches up for amd-staging-drm-next.

Will you be relying on either patch for related work? Otherwise it would be simpler for us to use vmwgfx-next for the whole series, targeting 5.3.

Thomas

Is this OK with you?

I wanted to base some cleanup work on this, but this can wait as well.

So fine with me to merge this through vmwgfx-next.

Regards,
Christian.

Thanks,
Thomas

Quoted 93 lines
Quoted 93 lines

Christian.

Quoted 90 lines
---
  drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
  include/drm/ttm/ttm_bo_driver.h | 6 ++++++
  3 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -0
index 3f56647cdb35..1c85bec00472 100644
@@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device
 *bdev,
   mutex_lock(&ttm_global_mutex);
   list_add_tail(&bdev->device_list, &glob->device_list);
   mutex_unlock(&ttm_global_mutex);
+ bdev->vm_ops = &ttm_bo_vm_ops;
 
   return 0;

out_no_sys:

drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
index e86a29a1e51f..bfb25b81fed7 100644
@@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct
 vm_area_struct *vma, unsigned long addr,
   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,
   .open = ttm_bo_vm_open,

.close = ttm_bo_vm_close,

drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
@@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct
 vm_area_struct *vma,
   if (unlikely(ret != 0))
           goto out_unref;
 
- vma->vm_ops = &ttm_bo_vm_ops;
+ vma->vm_ops = bdev->vm_ops;
 
   /*

* Note: We're transferring the bo reference to

drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
@@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct
 *vma,
 struct ttm_buffer_object *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_flags |= VM_MIXEDMAP;
   vma->vm_flags |= VM_IO | VM_DONTEXPAND;
include/drm/ttm/ttm_bo_driver.h +0 -0
index cbf3180cb612..cfeaff5d9706 100644
@@ -443,6 +443,9 @@ extern struct ttm_bo_global {
   * @driver: Pointer to a struct ttm_bo_driver struct setup by

the
driver.
* @man: An array of mem_type_managers.
* @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
* ddestroy lists.
* @dev_mapping: A pointer to the struct address_space
representing the

include/drm/ttm/ttm_bo_driver.h +1 -0
@@ -461,6 +464,7 @@ struct ttm_bo_device {
   struct ttm_bo_global *glob;
   struct ttm_bo_driver *driver;
   struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
+ const struct vm_operations_struct *vm_ops;
 
   /*
    * Protected by internal locks.
@@ -489,6 +493,8 @@ struct ttm_bo_device {
   bool no_retry;
  };
 
Quoted 5 lines
Quoted 5 lines

include/drm/ttm/ttm_bo_driver.h struct ttm_bo_device { · line 500

Quoted 5 lines
include/drm/ttm/ttm_bo_driver.h +2 -0
+extern const struct vm_operations_struct ttm_bo_vm_ops;
+
  /**
   * struct ttm_lru_bulk_move_pos
   *

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel