]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/amd/amdgpu: Add bank selection for MMIO debugfs (v3)
authorTom St Denis <tom.stdenis@amd.com>
Mon, 27 Jun 2016 15:55:07 +0000 (11:55 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 7 Jul 2016 19:06:09 +0000 (15:06 -0400)
(v2) Added INSTANCE selector
(v3) Changed order of bank selectors

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index ce9a1dc7fc06279905a12fa81bdf7bede2db1517..c8b7b74a0d1f448be474ac70fea71a7170ed6879 100644 (file)
@@ -2181,20 +2181,43 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
        struct amdgpu_device *adev = f->f_inode->i_private;
        ssize_t result = 0;
        int r;
+       bool use_bank;
+       unsigned instance_bank, sh_bank, se_bank;
 
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
+       if (*pos & (1ULL << 62)) {
+               se_bank = (*pos >> 24) & 0x3FF;
+               sh_bank = (*pos >> 34) & 0x3FF;
+               instance_bank = (*pos >> 44) & 0x3FF;
+               use_bank = 1;
+               *pos &= 0xFFFFFF;
+       } else {
+               use_bank = 0;
+       }
+
+       if (use_bank) {
+               if (sh_bank >= adev->gfx.config.max_sh_per_se ||
+                   se_bank >= adev->gfx.config.max_shader_engines)
+                       return -EINVAL;
+               mutex_lock(&adev->grbm_idx_mutex);
+               amdgpu_gfx_select_se_sh(adev, se_bank,
+                                       sh_bank, instance_bank);
+       }
+
        while (size) {
                uint32_t value;
 
                if (*pos > adev->rmmio_size)
-                       return result;
+                       goto end;
 
                value = RREG32(*pos >> 2);
                r = put_user(value, (uint32_t *)buf);
-               if (r)
-                       return r;
+               if (r) {
+                       result = r;
+                       goto end;
+               }
 
                result += 4;
                buf += 4;
@@ -2202,6 +2225,12 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
                size -= 4;
        }
 
+end:
+       if (use_bank) {
+               amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
+               mutex_unlock(&adev->grbm_idx_mutex);
+       }
+
        return result;
 }