drm/radeon: replace vmram_mutex with mclk_lock v2
authorChristian König <deathsimple@vodafone.de>
Fri, 11 May 2012 12:57:18 +0000 (14:57 +0200)
committerChristian König <deathsimple@vodafone.de>
Thu, 21 Jun 2012 07:38:43 +0000 (09:38 +0200)
It is a rw_semaphore now and only write locked
while changing the clock. Also the lock is renamed
to better reflect what it is protecting.

v2: Keep the ttm_vm_ops on IGPs

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/radeon_ttm.c

index 4563e50..586f30e 100644 (file)
@@ -1059,6 +1059,8 @@ struct radeon_power_state {
 
 struct radeon_pm {
        struct mutex            mutex;
+       /* write locked while reprogramming mclk */
+       struct rw_semaphore     mclk_lock;
        u32                     active_crtcs;
        int                     active_crtc_count;
        int                     req_vblank;
@@ -1554,7 +1556,6 @@ struct radeon_device {
        struct work_struct audio_work;
        int num_crtc; /* number of crtcs */
        struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
-       struct mutex vram_mutex;
        bool audio_enabled;
        struct r600_audio audio_status; /* audio stuff */
        struct notifier_block acpi_nb;
index 066c98b..7667184 100644 (file)
@@ -735,7 +735,7 @@ int radeon_device_init(struct radeon_device *rdev,
                spin_lock_init(&rdev->ih.lock);
        mutex_init(&rdev->gem.mutex);
        mutex_init(&rdev->pm.mutex);
-       mutex_init(&rdev->vram_mutex);
+       init_rwsem(&rdev->pm.mclk_lock);
        init_waitqueue_head(&rdev->irq.vblank_queue);
        init_waitqueue_head(&rdev->irq.idle_queue);
        r = radeon_gem_init(rdev);
index 830f1a7..6ecb200 100644 (file)
@@ -154,11 +154,11 @@ retry:
        INIT_LIST_HEAD(&bo->va);
        radeon_ttm_placement_from_domain(bo, domain);
        /* Kernel allocation are uninterruptible */
-       mutex_lock(&rdev->vram_mutex);
+       down_read(&rdev->pm.mclk_lock);
        r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
                        &bo->placement, page_align, 0, !kernel, NULL,
                        acc_size, sg, &radeon_ttm_bo_destroy);
-       mutex_unlock(&rdev->vram_mutex);
+       up_read(&rdev->pm.mclk_lock);
        if (unlikely(r != 0)) {
                if (r != -ERESTARTSYS) {
                        if (domain == RADEON_GEM_DOMAIN_VRAM) {
@@ -219,9 +219,9 @@ void radeon_bo_unref(struct radeon_bo **bo)
                return;
        rdev = (*bo)->rdev;
        tbo = &((*bo)->tbo);
-       mutex_lock(&rdev->vram_mutex);
+       down_read(&rdev->pm.mclk_lock);
        ttm_bo_unref(&tbo);
-       mutex_unlock(&rdev->vram_mutex);
+       up_read(&rdev->pm.mclk_lock);
        if (tbo == NULL)
                *bo = NULL;
 }
index 5b37e28..9dc0b54 100644 (file)
@@ -251,7 +251,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
                return;
 
        mutex_lock(&rdev->ddev->struct_mutex);
-       mutex_lock(&rdev->vram_mutex);
+       down_write(&rdev->pm.mclk_lock);
        mutex_lock(&rdev->ring_lock);
 
        /* gui idle int has issues on older chips it seems */
@@ -303,7 +303,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
        rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE;
 
        mutex_unlock(&rdev->ring_lock);
-       mutex_unlock(&rdev->vram_mutex);
+       up_write(&rdev->pm.mclk_lock);
        mutex_unlock(&rdev->ddev->struct_mutex);
 }
 
index c43035c..0881131 100644 (file)
@@ -797,9 +797,9 @@ static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                return VM_FAULT_NOPAGE;
        }
        rdev = radeon_get_rdev(bo->bdev);
-       mutex_lock(&rdev->vram_mutex);
+       down_read(&rdev->pm.mclk_lock);
        r = ttm_vm_ops->fault(vma, vmf);
-       mutex_unlock(&rdev->vram_mutex);
+       up_read(&rdev->pm.mclk_lock);
        return r;
 }