aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 01a42b6a69a4..19943356cca7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -42,12 +42,12 @@ int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg)
42{ 42{
43 int i; 43 int i;
44 44
45 for (i = 0; i < adev->gfx.scratch.num_reg; i++) { 45 i = ffs(adev->gfx.scratch.free_mask);
46 if (adev->gfx.scratch.free[i]) { 46 if (i != 0 && i <= adev->gfx.scratch.num_reg) {
47 adev->gfx.scratch.free[i] = false; 47 i--;
48 *reg = adev->gfx.scratch.reg[i]; 48 adev->gfx.scratch.free_mask &= ~(1u << i);
49 return 0; 49 *reg = adev->gfx.scratch.reg_base + i;
50 } 50 return 0;
51 } 51 }
52 return -EINVAL; 52 return -EINVAL;
53} 53}
@@ -62,14 +62,7 @@ int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg)
62 */ 62 */
63void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg) 63void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg)
64{ 64{
65 int i; 65 adev->gfx.scratch.free_mask |= 1u << (reg - adev->gfx.scratch.reg_base);
66
67 for (i = 0; i < adev->gfx.scratch.num_reg; i++) {
68 if (adev->gfx.scratch.reg[i] == reg) {
69 adev->gfx.scratch.free[i] = true;
70 return;
71 }
72 }
73} 66}
74 67
75/** 68/**