diff options
Diffstat (limited to 'drivers/gpu/drm/drm_gem.c')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 4761adedad2a..5bbad873c798 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -91,19 +91,19 @@ | |||
91 | int | 91 | int |
92 | drm_gem_init(struct drm_device *dev) | 92 | drm_gem_init(struct drm_device *dev) |
93 | { | 93 | { |
94 | struct drm_gem_mm *mm; | 94 | struct drm_vma_offset_manager *vma_offset_manager; |
95 | 95 | ||
96 | mutex_init(&dev->object_name_lock); | 96 | mutex_init(&dev->object_name_lock); |
97 | idr_init(&dev->object_name_idr); | 97 | idr_init(&dev->object_name_idr); |
98 | 98 | ||
99 | mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL); | 99 | vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL); |
100 | if (!mm) { | 100 | if (!vma_offset_manager) { |
101 | DRM_ERROR("out of memory\n"); | 101 | DRM_ERROR("out of memory\n"); |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | } | 103 | } |
104 | 104 | ||
105 | dev->mm_private = mm; | 105 | dev->vma_offset_manager = vma_offset_manager; |
106 | drm_vma_offset_manager_init(&mm->vma_manager, | 106 | drm_vma_offset_manager_init(vma_offset_manager, |
107 | DRM_FILE_PAGE_OFFSET_START, | 107 | DRM_FILE_PAGE_OFFSET_START, |
108 | DRM_FILE_PAGE_OFFSET_SIZE); | 108 | DRM_FILE_PAGE_OFFSET_SIZE); |
109 | 109 | ||
@@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev) | |||
113 | void | 113 | void |
114 | drm_gem_destroy(struct drm_device *dev) | 114 | drm_gem_destroy(struct drm_device *dev) |
115 | { | 115 | { |
116 | struct drm_gem_mm *mm = dev->mm_private; | ||
117 | 116 | ||
118 | drm_vma_offset_manager_destroy(&mm->vma_manager); | 117 | drm_vma_offset_manager_destroy(dev->vma_offset_manager); |
119 | kfree(mm); | 118 | kfree(dev->vma_offset_manager); |
120 | dev->mm_private = NULL; | 119 | dev->vma_offset_manager = NULL; |
121 | } | 120 | } |
122 | 121 | ||
123 | /** | 122 | /** |
@@ -129,11 +128,12 @@ int drm_gem_object_init(struct drm_device *dev, | |||
129 | { | 128 | { |
130 | struct file *filp; | 129 | struct file *filp; |
131 | 130 | ||
131 | drm_gem_private_object_init(dev, obj, size); | ||
132 | |||
132 | filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); | 133 | filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); |
133 | if (IS_ERR(filp)) | 134 | if (IS_ERR(filp)) |
134 | return PTR_ERR(filp); | 135 | return PTR_ERR(filp); |
135 | 136 | ||
136 | drm_gem_private_object_init(dev, obj, size); | ||
137 | obj->filp = filp; | 137 | obj->filp = filp; |
138 | 138 | ||
139 | return 0; | 139 | return 0; |
@@ -175,11 +175,6 @@ drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp) | |||
175 | mutex_unlock(&filp->prime.lock); | 175 | mutex_unlock(&filp->prime.lock); |
176 | } | 176 | } |
177 | 177 | ||
178 | static void drm_gem_object_ref_bug(struct kref *list_kref) | ||
179 | { | ||
180 | BUG(); | ||
181 | } | ||
182 | |||
183 | /** | 178 | /** |
184 | * Called after the last handle to the object has been closed | 179 | * Called after the last handle to the object has been closed |
185 | * | 180 | * |
@@ -195,13 +190,6 @@ static void drm_gem_object_handle_free(struct drm_gem_object *obj) | |||
195 | if (obj->name) { | 190 | if (obj->name) { |
196 | idr_remove(&dev->object_name_idr, obj->name); | 191 | idr_remove(&dev->object_name_idr, obj->name); |
197 | obj->name = 0; | 192 | obj->name = 0; |
198 | /* | ||
199 | * The object name held a reference to this object, drop | ||
200 | * that now. | ||
201 | * | ||
202 | * This cannot be the last reference, since the handle holds one too. | ||
203 | */ | ||
204 | kref_put(&obj->refcount, drm_gem_object_ref_bug); | ||
205 | } | 193 | } |
206 | } | 194 | } |
207 | 195 | ||
@@ -374,9 +362,8 @@ void | |||
374 | drm_gem_free_mmap_offset(struct drm_gem_object *obj) | 362 | drm_gem_free_mmap_offset(struct drm_gem_object *obj) |
375 | { | 363 | { |
376 | struct drm_device *dev = obj->dev; | 364 | struct drm_device *dev = obj->dev; |
377 | struct drm_gem_mm *mm = dev->mm_private; | ||
378 | 365 | ||
379 | drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node); | 366 | drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node); |
380 | } | 367 | } |
381 | EXPORT_SYMBOL(drm_gem_free_mmap_offset); | 368 | EXPORT_SYMBOL(drm_gem_free_mmap_offset); |
382 | 369 | ||
@@ -398,9 +385,8 @@ int | |||
398 | drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size) | 385 | drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size) |
399 | { | 386 | { |
400 | struct drm_device *dev = obj->dev; | 387 | struct drm_device *dev = obj->dev; |
401 | struct drm_gem_mm *mm = dev->mm_private; | ||
402 | 388 | ||
403 | return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node, | 389 | return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node, |
404 | size / PAGE_SIZE); | 390 | size / PAGE_SIZE); |
405 | } | 391 | } |
406 | EXPORT_SYMBOL(drm_gem_create_mmap_offset_size); | 392 | EXPORT_SYMBOL(drm_gem_create_mmap_offset_size); |
@@ -602,9 +588,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data, | |||
602 | goto err; | 588 | goto err; |
603 | 589 | ||
604 | obj->name = ret; | 590 | obj->name = ret; |
605 | |||
606 | /* Allocate a reference for the name table. */ | ||
607 | drm_gem_object_reference(obj); | ||
608 | } | 591 | } |
609 | 592 | ||
610 | args->name = (uint64_t) obj->name; | 593 | args->name = (uint64_t) obj->name; |
@@ -833,7 +816,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) | |||
833 | { | 816 | { |
834 | struct drm_file *priv = filp->private_data; | 817 | struct drm_file *priv = filp->private_data; |
835 | struct drm_device *dev = priv->minor->dev; | 818 | struct drm_device *dev = priv->minor->dev; |
836 | struct drm_gem_mm *mm = dev->mm_private; | ||
837 | struct drm_gem_object *obj; | 819 | struct drm_gem_object *obj; |
838 | struct drm_vma_offset_node *node; | 820 | struct drm_vma_offset_node *node; |
839 | int ret = 0; | 821 | int ret = 0; |
@@ -843,7 +825,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) | |||
843 | 825 | ||
844 | mutex_lock(&dev->struct_mutex); | 826 | mutex_lock(&dev->struct_mutex); |
845 | 827 | ||
846 | node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff, | 828 | node = drm_vma_offset_exact_lookup(dev->vma_offset_manager, |
829 | vma->vm_pgoff, | ||
847 | vma_pages(vma)); | 830 | vma_pages(vma)); |
848 | if (!node) { | 831 | if (!node) { |
849 | mutex_unlock(&dev->struct_mutex); | 832 | mutex_unlock(&dev->struct_mutex); |