mutex_init(&adev->gfx.gpu_clock_mutex);
mutex_init(&adev->srbm_mutex);
mutex_init(&adev->grbm_idx_mutex);
- init_rwsem(&adev->pm.mclk_lock);
init_rwsem(&adev->exclusive_lock);
mutex_init(&adev->mn_lock);
hash_init(adev->mn_hash);
bo->flags = flags;
amdgpu_fill_placement_to_bo(bo, placement);
/* Kernel allocation are uninterruptible */
- down_read(&adev->pm.mclk_lock);
r = ttm_bo_init(&adev->mman.bdev, &bo->tbo, size, type,
&bo->placement, page_align, !kernel, NULL,
acc_size, sg, NULL, &amdgpu_ttm_bo_destroy);
- up_read(&adev->pm.mclk_lock);
if (unlikely(r != 0)) {
return r;
}
}
mutex_lock(&adev->ddev->struct_mutex);
- down_write(&adev->pm.mclk_lock);
mutex_lock(&adev->ring_lock);
/* update whether vce is active */
done:
mutex_unlock(&adev->ring_lock);
- up_write(&adev->pm.mclk_lock);
mutex_unlock(&adev->ddev->struct_mutex);
}
man->size = size >> PAGE_SHIFT;
}
-static struct vm_operations_struct amdgpu_ttm_vm_ops;
-static const struct vm_operations_struct *ttm_vm_ops = NULL;
-
-static int amdgpu_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
- struct ttm_buffer_object *bo;
- struct amdgpu_device *adev;
- int r;
-
- bo = (struct ttm_buffer_object *)vma->vm_private_data;
- if (bo == NULL) {
- return VM_FAULT_NOPAGE;
- }
- adev = amdgpu_get_adev(bo->bdev);
- down_read(&adev->pm.mclk_lock);
- r = ttm_vm_ops->fault(vma, vmf);
- up_read(&adev->pm.mclk_lock);
- return r;
-}
-
int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct drm_file *file_priv;
struct amdgpu_device *adev;
- int r;
- if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) {
+ if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
return -EINVAL;
- }
file_priv = filp->private_data;
adev = file_priv->minor->dev->dev_private;
- if (adev == NULL) {
+ if (adev == NULL)
return -EINVAL;
- }
- r = ttm_bo_mmap(filp, vma, &adev->mman.bdev);
- if (unlikely(r != 0)) {
- return r;
- }
- if (unlikely(ttm_vm_ops == NULL)) {
- ttm_vm_ops = vma->vm_ops;
- amdgpu_ttm_vm_ops = *ttm_vm_ops;
- amdgpu_ttm_vm_ops.fault = &amdgpu_ttm_fault;
- }
- vma->vm_ops = &amdgpu_ttm_vm_ops;
- return 0;
+
+ return ttm_bo_mmap(filp, vma, &adev->mman.bdev);
}
int amdgpu_copy_buffer(struct amdgpu_ring *ring,