drm/radeon/kms: check if vm is supported in VA ioctl
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Jan 2012 14:38:15 +0000 (09:38 -0500)
committerDave Airlie <airlied@redhat.com>
Mon, 9 Jan 2012 12:10:09 +0000 (12:10 +0000)
Add a VM manager enabled field and use it to check if
vm is enabled.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: jglisse@redhat.com
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_cs.c
drivers/gpu/drm/radeon/radeon_gart.c
drivers/gpu/drm/radeon/radeon_gem.c

index 7cb63cd2e738268500757458e4dc07dc35cbf6f8..73e05cb85eca03cd2c65461ce1af7ca3f82e0bfc 100644 (file)
@@ -668,6 +668,8 @@ struct radeon_vm_manager {
        unsigned                        nvm;
        /* vram base address for page table entry  */
        u64                             vram_base_offset;
+       /* is vm enabled? */
+       bool                            enabled;
 };
 
 /*
index 17af0e83c328503e395cd0437e384733c38b3079..435a3d970ab8b0ef39c45f45ea8c22bdec05abf4 100644 (file)
@@ -234,8 +234,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
        }
 
        if ((p->cs_flags & RADEON_CS_USE_VM) &&
-           (p->rdev->family < CHIP_CAYMAN)) {
-               DRM_ERROR("VM not supported on asic!\n");
+           !p->rdev->vm_manager.enabled) {
+               DRM_ERROR("VM not active on asic!\n");
                if (p->chunk_relocs_idx != -1)
                        kfree(p->chunks[p->chunk_relocs_idx].kdata);
                if (p->chunk_flags_idx != -1)
index 3ef58cab18c9d4a0f5ea780637f07512ba818dd8..8597d2c016e672fd2b127464a8adbd4285616276 100644 (file)
@@ -286,6 +286,8 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
 {
        int r;
 
+       rdev->vm_manager.enabled = false;
+
        /* mark first vm as always in use, it's the system one */
        r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager,
                                      rdev->vm_manager.max_pfn * 8,
@@ -295,7 +297,12 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
                        (rdev->vm_manager.max_pfn * 8) >> 10);
                return r;
        }
-       return rdev->vm_manager.funcs->init(rdev);
+
+       r = rdev->vm_manager.funcs->init(rdev);
+       if (r == 0)
+               rdev->vm_manager.enabled = true;
+
+       return r;
 }
 
 /* cs mutex must be lock */
@@ -334,6 +341,7 @@ void radeon_vm_manager_fini(struct radeon_device *rdev)
        radeon_vm_manager_suspend(rdev);
        rdev->vm_manager.funcs->fini(rdev);
        radeon_sa_bo_manager_fini(rdev, &rdev->vm_manager.sa_manager);
+       rdev->vm_manager.enabled = false;
 }
 
 int radeon_vm_manager_start(struct radeon_device *rdev)
index 003eeec1b688e12ef90cd114b443a2e6480c1916..7337850af2fa86cff62cd1104c127d65dc056328 100644 (file)
@@ -404,6 +404,11 @@ int radeon_gem_va_ioctl(struct drm_device *dev, void *data,
        u32 invalid_flags;
        int r = 0;
 
+       if (!rdev->vm_manager.enabled) {
+               args->operation = RADEON_VA_RESULT_ERROR;
+               return -ENOTTY;
+       }
+
        /* !! DONT REMOVE !!
         * We don't support vm_id yet, to be sure we don't have have broken
         * userspace, reject anyone trying to use non 0 value thus moving