drm/radeon/kms: Avoid crash when trying to cleanup uninitialized structure
Add boolean to record if some part of the driver are initialized or not this allow to avoid a crash when trying to cleanup uninitialized structure members. Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
d2efdf6d6f
commit
0a0c7596c6
|
@ -162,6 +162,7 @@ struct radeon_fence_driver {
|
||||||
struct list_head created;
|
struct list_head created;
|
||||||
struct list_head emited;
|
struct list_head emited;
|
||||||
struct list_head signaled;
|
struct list_head signaled;
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct radeon_fence {
|
struct radeon_fence {
|
||||||
|
@ -202,8 +203,9 @@ struct radeon_surface_reg {
|
||||||
struct radeon_mman {
|
struct radeon_mman {
|
||||||
struct ttm_bo_global_ref bo_global_ref;
|
struct ttm_bo_global_ref bo_global_ref;
|
||||||
struct ttm_global_reference mem_global_ref;
|
struct ttm_global_reference mem_global_ref;
|
||||||
bool mem_global_referenced;
|
|
||||||
struct ttm_bo_device bdev;
|
struct ttm_bo_device bdev;
|
||||||
|
bool mem_global_referenced;
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct radeon_bo {
|
struct radeon_bo {
|
||||||
|
|
|
@ -324,7 +324,7 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
|
||||||
write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
|
write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
|
||||||
r = radeon_scratch_get(rdev, &rdev->fence_drv.scratch_reg);
|
r = radeon_scratch_get(rdev, &rdev->fence_drv.scratch_reg);
|
||||||
if (r) {
|
if (r) {
|
||||||
DRM_ERROR("Fence failed to get a scratch register.");
|
dev_err(rdev->dev, "fence failed to get scratch register\n");
|
||||||
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -335,9 +335,10 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
|
||||||
INIT_LIST_HEAD(&rdev->fence_drv.signaled);
|
INIT_LIST_HEAD(&rdev->fence_drv.signaled);
|
||||||
rdev->fence_drv.count_timeout = 0;
|
rdev->fence_drv.count_timeout = 0;
|
||||||
init_waitqueue_head(&rdev->fence_drv.queue);
|
init_waitqueue_head(&rdev->fence_drv.queue);
|
||||||
|
rdev->fence_drv.initialized = true;
|
||||||
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
||||||
if (radeon_debugfs_fence_init(rdev)) {
|
if (radeon_debugfs_fence_init(rdev)) {
|
||||||
DRM_ERROR("Failed to register debugfs file for fence !\n");
|
dev_err(rdev->dev, "fence debugfs file creation failed\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -346,11 +347,13 @@ void radeon_fence_driver_fini(struct radeon_device *rdev)
|
||||||
{
|
{
|
||||||
unsigned long irq_flags;
|
unsigned long irq_flags;
|
||||||
|
|
||||||
|
if (!rdev->fence_drv.initialized)
|
||||||
|
return;
|
||||||
wake_up_all(&rdev->fence_drv.queue);
|
wake_up_all(&rdev->fence_drv.queue);
|
||||||
write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
|
write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
|
||||||
radeon_scratch_free(rdev, rdev->fence_drv.scratch_reg);
|
radeon_scratch_free(rdev, rdev->fence_drv.scratch_reg);
|
||||||
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
|
||||||
DRM_INFO("radeon: fence finalized\n");
|
rdev->fence_drv.initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
|
||||||
DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
|
DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
rdev->mman.initialized = true;
|
||||||
r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
|
r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
|
||||||
rdev->mc.real_vram_size >> PAGE_SHIFT);
|
rdev->mc.real_vram_size >> PAGE_SHIFT);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
@ -541,6 +542,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
if (!rdev->mman.initialized)
|
||||||
|
return;
|
||||||
if (rdev->stollen_vga_memory) {
|
if (rdev->stollen_vga_memory) {
|
||||||
r = radeon_bo_reserve(rdev->stollen_vga_memory, false);
|
r = radeon_bo_reserve(rdev->stollen_vga_memory, false);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
@ -554,6 +557,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
|
||||||
ttm_bo_device_release(&rdev->mman.bdev);
|
ttm_bo_device_release(&rdev->mman.bdev);
|
||||||
radeon_gart_fini(rdev);
|
radeon_gart_fini(rdev);
|
||||||
radeon_ttm_global_fini(rdev);
|
radeon_ttm_global_fini(rdev);
|
||||||
|
rdev->mman.initialized = false;
|
||||||
DRM_INFO("radeon: ttm finalized\n");
|
DRM_INFO("radeon: ttm finalized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue