]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Merge tag 'net-next-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_debugfs.c
index 79b397800cbc1e450b5acfbdf711ae7aa93fe17b..2d125b8b15ee1962f2569087c0b8d006512fca52 100644 (file)
@@ -69,8 +69,8 @@ int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
        adev->debugfs_count = i;
 #if defined(CONFIG_DEBUG_FS)
        drm_debugfs_create_files(files, nfiles,
-                                adev->ddev->primary->debugfs_root,
-                                adev->ddev->primary);
+                                adev_to_drm(adev)->primary->debugfs_root,
+                                adev_to_drm(adev)->primary);
 #endif
        return 0;
 }
@@ -101,14 +101,18 @@ static int amdgpu_debugfs_autodump_open(struct inode *inode, struct file *file)
 
        file->private_data = adev;
 
-       mutex_lock(&adev->lock_reset);
+       ret = down_read_killable(&adev->reset_sem);
+       if (ret)
+               return ret;
+
        if (adev->autodump.dumping.done) {
                reinit_completion(&adev->autodump.dumping);
                ret = 0;
        } else {
                ret = -EBUSY;
        }
-       mutex_unlock(&adev->lock_reset);
+
+       up_read(&adev->reset_sem);
 
        return ret;
 }
@@ -147,7 +151,7 @@ static void amdgpu_debugfs_autodump_init(struct amdgpu_device *adev)
        init_waitqueue_head(&adev->autodump.gpu_hang);
 
        debugfs_create_file("amdgpu_autodump", 0600,
-               adev->ddev->primary->debugfs_root,
+               adev_to_drm(adev)->primary->debugfs_root,
                adev, &autodump_debug_fops);
 }
 
@@ -223,23 +227,23 @@ static int  amdgpu_debugfs_process_reg_op(bool read, struct file *f,
 
        *pos &= (1UL << 22) - 1;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        if (use_bank) {
                if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) ||
                    (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return -EINVAL;
                }
@@ -263,7 +267,7 @@ static int  amdgpu_debugfs_process_reg_op(bool read, struct file *f,
                } else {
                        r = get_user(value, (uint32_t *)buf);
                        if (!r)
-                               amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value, 0);
+                               amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value);
                }
                if (r) {
                        result = r;
@@ -288,8 +292,8 @@ end:
        if (pm_pg_lock)
                mutex_unlock(&adev->pm.mutex);
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -336,15 +340,15 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -354,8 +358,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
                value = RREG32_PCIE(*pos >> 2);
                r = put_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -366,8 +370,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -395,15 +399,15 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -412,8 +416,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
 
                r = get_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -426,8 +430,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -455,15 +459,15 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -473,8 +477,8 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
                value = RREG32_DIDT(*pos >> 2);
                r = put_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -485,8 +489,8 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -514,15 +518,15 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -531,8 +535,8 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
 
                r = get_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -545,8 +549,8 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -574,15 +578,15 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -592,8 +596,8 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
                value = RREG32_SMC(*pos);
                r = put_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -604,8 +608,8 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -633,15 +637,15 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -650,8 +654,8 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *
 
                r = get_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        amdgpu_virt_disable_access_debugfs(adev);
                        return r;
                }
@@ -664,8 +668,8 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        amdgpu_virt_disable_access_debugfs(adev);
        return result;
@@ -792,22 +796,22 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf,
 
        valuesize = sizeof(values);
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_dpm_read_sensor(adev, idx, &values[0], &valuesize);
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        if (r) {
                amdgpu_virt_disable_access_debugfs(adev);
@@ -874,15 +878,15 @@ static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf,
        wave = (*pos & GENMASK_ULL(36, 31)) >> 31;
        simd = (*pos & GENMASK_ULL(44, 37)) >> 37;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        r = amdgpu_virt_enable_access_debugfs(adev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -897,8 +901,8 @@ static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf,
        amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
        mutex_unlock(&adev->grbm_idx_mutex);
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        if (!x) {
                amdgpu_virt_disable_access_debugfs(adev);
@@ -972,7 +976,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
        if (!data)
                return -ENOMEM;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0)
                goto err;
 
@@ -995,8 +999,8 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
        amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
        mutex_unlock(&adev->grbm_idx_mutex);
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        while (size) {
                uint32_t value;
@@ -1018,7 +1022,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
        return result;
 
 err:
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
        kfree(data);
        return r;
 }
@@ -1043,9 +1047,9 @@ static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *bu
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -1054,8 +1058,8 @@ static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *bu
 
                r = get_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        return r;
                }
 
@@ -1067,8 +1071,8 @@ static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *bu
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        return result;
 }
@@ -1092,7 +1096,7 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
-       r = pm_runtime_get_sync(adev->ddev->dev);
+       r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0)
                return r;
 
@@ -1101,15 +1105,15 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,
 
                r = amdgpu_get_gfx_off_status(adev, &value);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        return r;
                }
 
                r = put_user(value, (uint32_t *)buf);
                if (r) {
-                       pm_runtime_mark_last_busy(adev->ddev->dev);
-                       pm_runtime_put_autosuspend(adev->ddev->dev);
+                       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+                       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                        return r;
                }
 
@@ -1119,8 +1123,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,
                size -= 4;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        return result;
 }
@@ -1212,7 +1216,7 @@ static const char *debugfs_regs_names[] = {
  */
 int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 {
-       struct drm_minor *minor = adev->ddev->primary;
+       struct drm_minor *minor = adev_to_drm(adev)->primary;
        struct dentry *ent, *root = minor->debugfs_root;
        unsigned int i;
 
@@ -1232,17 +1236,19 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
-       struct amdgpu_device *adev = dev->dev_private;
+       struct amdgpu_device *adev = drm_to_adev(dev);
        int r = 0, i;
 
        r = pm_runtime_get_sync(dev->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
        /* Avoid accidently unparking the sched thread during GPU reset */
-       mutex_lock(&adev->lock_reset);
+       r = down_read_killable(&adev->reset_sem);
+       if (r)
+               return r;
 
        /* hold on the scheduler */
        for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
@@ -1269,7 +1275,7 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
                kthread_unpark(ring->sched.thread);
        }
 
-       mutex_unlock(&adev->lock_reset);
+       up_read(&adev->reset_sem);
 
        pm_runtime_mark_last_busy(dev->dev);
        pm_runtime_put_autosuspend(dev->dev);
@@ -1281,7 +1287,7 @@ static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
-       struct amdgpu_device *adev = dev->dev_private;
+       struct amdgpu_device *adev = drm_to_adev(dev);
 
        seq_write(m, adev->bios, adev->bios_size);
        return 0;
@@ -1291,12 +1297,12 @@ static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *)m->private;
        struct drm_device *dev = node->minor->dev;
-       struct amdgpu_device *adev = dev->dev_private;
+       struct amdgpu_device *adev = drm_to_adev(dev);
        int r;
 
        r = pm_runtime_get_sync(dev->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -1312,12 +1318,12 @@ static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *)m->private;
        struct drm_device *dev = node->minor->dev;
-       struct amdgpu_device *adev = dev->dev_private;
+       struct amdgpu_device *adev = drm_to_adev(dev);
        int r;
 
        r = pm_runtime_get_sync(dev->dev);
        if (r < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return r;
        }
 
@@ -1459,7 +1465,9 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
                return -ENOMEM;
 
        /* Avoid accidently unparking the sched thread during GPU reset */
-       mutex_lock(&adev->lock_reset);
+       r = down_read_killable(&adev->reset_sem);
+       if (r)
+               goto pro_end;
 
        /* stop the scheduler */
        kthread_park(ring->sched.thread);
@@ -1500,13 +1508,14 @@ failure:
        /* restart the scheduler */
        kthread_unpark(ring->sched.thread);
 
-       mutex_unlock(&adev->lock_reset);
+       up_read(&adev->reset_sem);
 
        ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
 
+pro_end:
        kfree(fences);
 
-       return 0;
+       return r;
 }
 
 static int amdgpu_debugfs_sclk_set(void *data, u64 val)
@@ -1518,9 +1527,9 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)
        if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
                return -EINVAL;
 
-       ret = pm_runtime_get_sync(adev->ddev->dev);
+       ret = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (ret < 0) {
-               pm_runtime_put_autosuspend(adev->ddev->dev);
+               pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
                return ret;
        }
 
@@ -1533,8 +1542,8 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)
                return 0;
        }
 
-       pm_runtime_mark_last_busy(adev->ddev->dev);
-       pm_runtime_put_autosuspend(adev->ddev->dev);
+       pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+       pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 
        if (ret)
                return -EINVAL;
@@ -1554,7 +1563,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 
        adev->debugfs_preempt =
                debugfs_create_file("amdgpu_preempt_ib", 0600,
-                                   adev->ddev->primary->debugfs_root, adev,
+                                   adev_to_drm(adev)->primary->debugfs_root, adev,
                                    &fops_ib_preempt);
        if (!(adev->debugfs_preempt)) {
                DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");
@@ -1563,7 +1572,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 
        adev->smu.debugfs_sclk =
                debugfs_create_file("amdgpu_force_sclk", 0200,
-                                   adev->ddev->primary->debugfs_root, adev,
+                                   adev_to_drm(adev)->primary->debugfs_root, adev,
                                    &fops_sclk_set);
        if (!(adev->smu.debugfs_sclk)) {
                DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
This page took 0.069409 seconds and 4 git commands to generate.