drm/amdgpu: request/release full gpu access if device is vf
authorXiangliang Yu <Xiangliang.Yu@amd.com>
Thu, 12 Jan 2017 07:14:36 +0000 (15:14 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 27 Jan 2017 16:13:25 +0000 (11:13 -0500)
For gpu vf device, first need to request full gpu access before
accessing gpu registers, and release full gpu access after the
access is done.

Signed-off-by: Xiangliang Yu <Xiangliang.Yu@amd.com>
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 6eabeaaa3c3040fbeb175f47f81589bc03128b32..e0fcfea99328aede215e6e1f400e7f40acc68b43 100644 (file)
@@ -1345,6 +1345,12 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
                return -EINVAL;
        }
 
+       if (amdgpu_sriov_vf(adev)) {
+               r = amdgpu_virt_request_full_gpu(adev, true);
+               if (r)
+                       return r;
+       }
+
        for (i = 0; i < adev->num_ip_blocks; i++) {
                if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
                        DRM_ERROR("disabled ip block: %d\n", i);
@@ -1547,8 +1553,10 @@ static int amdgpu_fini(struct amdgpu_device *adev)
                adev->ip_blocks[i].status.late_initialized = false;
        }
 
-       if (amdgpu_sriov_vf(adev))
+       if (amdgpu_sriov_vf(adev)) {
                amdgpu_bo_free_kernel(&adev->virt.csa_obj, &adev->virt.csa_vmid0_addr, NULL);
+               amdgpu_virt_release_full_gpu(adev, false);
+       }
 
        return 0;
 }
index 8f852cb152f5445a16ffb0a5016efdbdccbdceec..61d94c7456723931cdeeabf044958d3f4096751c 100644 (file)
@@ -60,6 +60,9 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
        if (adev->rmmio == NULL)
                goto done_free;
 
+       if (amdgpu_sriov_vf(adev))
+               amdgpu_virt_request_full_gpu(adev, false);
+
        if (amdgpu_device_is_px(dev)) {
                pm_runtime_get_sync(dev->dev);
                pm_runtime_forbid(dev->dev);
@@ -138,6 +141,9 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
                pm_runtime_put_autosuspend(dev->dev);
        }
 
+       if (amdgpu_sriov_vf(adev))
+               amdgpu_virt_release_full_gpu(adev, true);
+
 out:
        if (r) {
                /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */