Skip to content

Commit 52a187a

Browse files
AaronDotopsiff
authored andcommitted
drm/amdgpu: Fix wptr/rptr error in ih_fix_loongarch_pcie_order()
Fix the pointer error of wptr/rptr in ih_fix_loongarch_pcie_order(). Fixes: bcaf362 (drm/amdgpu: Fix pcie order dislocation) Signed-off-by: zhaotianrui <zhaotianrui@loongson.cn> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn> (cherry picked from commit c41045a) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 82eaa05 commit 52a187a

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ static int amdgpu_ih_fix_loongarch_pcie_order_start(struct amdgpu_ih_ring *ih,
169169
{
170170
int i, j;
171171
int check_cnt = 0;
172-
u32 ring_end = ih->ring_size >> 2;
172+
u32 old_wptr, ring_end = ih->ring_size >> 2;
173173

174174
if (rptr == wptr)
175175
return 0;
176176

177177
rptr = rptr >> 2;
178178
wptr = wptr >> 2;
179-
179+
old_wptr = wptr;
180180
wptr = (rptr > wptr) ? ring_end : wptr;
181181

182182
restart_check:
@@ -194,10 +194,10 @@ static int amdgpu_ih_fix_loongarch_pcie_order_start(struct amdgpu_ih_ring *ih,
194194
goto restart_check;
195195
}
196196

197-
if (rptr > wptr) {
198-
for (i = 0; i < wptr; i += 1) {
197+
if (rptr > old_wptr) {
198+
for (i = 0; i < old_wptr; i += 1) {
199199
j = i + 1;
200-
j = (j < wptr) ? j : 0;
200+
j = (j < old_wptr) ? j : 0;
201201
if (le32_to_cpu(ih->ring[i]) == 0xDEADBEFF &&
202202
le32_to_cpu(ih->ring[j]) == 0xDEADBEFF)
203203
goto restart_check;
@@ -211,21 +211,21 @@ static int amdgpu_ih_fix_loongarch_pcie_order_end(struct amdgpu_ih_ring *ih,
211211
u32 rptr, u32 wptr)
212212
{
213213
int i;
214-
u32 ring_end = ih->ring_size >> 2;
214+
u32 old_wptr, ring_end = ih->ring_size >> 2;
215215

216216
if (rptr == wptr)
217217
return 0;
218218

219219
rptr = rptr >> 2;
220220
wptr = wptr >> 2;
221-
221+
old_wptr = wptr;
222222
wptr = (rptr > wptr) ? ring_end : wptr;
223223

224224
for (i = rptr; i < wptr; i += 1)
225225
ih->ring[i] = 0xDEADBEFF;
226226

227-
if (rptr > wptr) {
228-
for (i = 0; i < wptr; i += 1)
227+
if (rptr > old_wptr) {
228+
for (i = 0; i < old_wptr; i += 1)
229229
ih->ring[i] = 0xDEADBEFF;
230230
}
231231
/* memory barrier for writing into ih ring */

0 commit comments

Comments
 (0)