aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2016-09-06 11:36:42 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-09-12 18:12:22 -0400
commit6e9057a8f90f3a9d662d8c0a347850e1fa331a30 (patch)
treebe68eafa063e2ee0082b100baa69fc4f8e9d611d
parent77d318a6b9f2f8599d913b7b5013cdf0342c71ed (diff)
drm/amd/amdgpu: Tidy up SI IH code
Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> Reviewed-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/si_ih.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgpu/si_ih.c
index 994ff02db013..8fae3d4a2360 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c
@@ -57,7 +57,6 @@ static void si_ih_disable_interrupts(struct amdgpu_device *adev)
57 57
58static int si_ih_irq_init(struct amdgpu_device *adev) 58static int si_ih_irq_init(struct amdgpu_device *adev)
59{ 59{
60 int ret = 0;
61 int rb_bufsz; 60 int rb_bufsz;
62 u32 interrupt_cntl, ih_cntl, ih_rb_cntl; 61 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
63 u64 wptr_off; 62 u64 wptr_off;
@@ -72,18 +71,15 @@ static int si_ih_irq_init(struct amdgpu_device *adev)
72 WREG32(IH_RB_BASE, adev->irq.ih.gpu_addr >> 8); 71 WREG32(IH_RB_BASE, adev->irq.ih.gpu_addr >> 8);
73 rb_bufsz = order_base_2(adev->irq.ih.ring_size / 4); 72 rb_bufsz = order_base_2(adev->irq.ih.ring_size / 4);
74 73
75 ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE | 74 ih_rb_cntl = IH_WPTR_OVERFLOW_ENABLE |
76 IH_WPTR_OVERFLOW_CLEAR | 75 IH_WPTR_OVERFLOW_CLEAR |
77 (rb_bufsz << 1)); 76 (rb_bufsz << 1) |
78 77 IH_WPTR_WRITEBACK_ENABLE;
79 ih_rb_cntl |= IH_WPTR_WRITEBACK_ENABLE;
80 78
81 wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4); 79 wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4);
82 WREG32(IH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off)); 80 WREG32(IH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off));
83 WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF); 81 WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF);
84
85 WREG32(IH_RB_CNTL, ih_rb_cntl); 82 WREG32(IH_RB_CNTL, ih_rb_cntl);
86
87 WREG32(IH_RB_RPTR, 0); 83 WREG32(IH_RB_RPTR, 0);
88 WREG32(IH_RB_WPTR, 0); 84 WREG32(IH_RB_WPTR, 0);
89 85
@@ -93,10 +89,9 @@ static int si_ih_irq_init(struct amdgpu_device *adev)
93 WREG32(IH_CNTL, ih_cntl); 89 WREG32(IH_CNTL, ih_cntl);
94 90
95 pci_set_master(adev->pdev); 91 pci_set_master(adev->pdev);
96
97 si_ih_enable_interrupts(adev); 92 si_ih_enable_interrupts(adev);
98 93
99 return ret; 94 return 0;
100} 95}
101 96
102static void si_ih_irq_disable(struct amdgpu_device *adev) 97static void si_ih_irq_disable(struct amdgpu_device *adev)
@@ -165,9 +160,7 @@ static int si_ih_sw_init(void *handle)
165 if (r) 160 if (r)
166 return r; 161 return r;
167 162
168 r = amdgpu_irq_init(adev); 163 return amdgpu_irq_init(adev);
169
170 return r;
171} 164}
172 165
173static int si_ih_sw_fini(void *handle) 166static int si_ih_sw_fini(void *handle)
@@ -182,14 +175,9 @@ static int si_ih_sw_fini(void *handle)
182 175
183static int si_ih_hw_init(void *handle) 176static int si_ih_hw_init(void *handle)
184{ 177{
185 int r;
186 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 178 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
187 179
188 r = si_ih_irq_init(adev); 180 return si_ih_irq_init(adev);
189 if (r)
190 return r;
191
192 return 0;
193} 181}
194 182
195static int si_ih_hw_fini(void *handle) 183static int si_ih_hw_fini(void *handle)
@@ -229,12 +217,10 @@ static bool si_ih_is_idle(void *handle)
229static int si_ih_wait_for_idle(void *handle) 217static int si_ih_wait_for_idle(void *handle)
230{ 218{
231 unsigned i; 219 unsigned i;
232 u32 tmp;
233 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 220 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
234 221
235 for (i = 0; i < adev->usec_timeout; i++) { 222 for (i = 0; i < adev->usec_timeout; i++) {
236 tmp = RREG32(SRBM_STATUS) & SRBM_STATUS__IH_BUSY_MASK; 223 if (si_ih_is_idle(handle))
237 if (!tmp)
238 return 0; 224 return 0;
239 udelay(1); 225 udelay(1);
240 } 226 }