Skip to content

Commit 88687a9

Browse files
Coreforgegeerlingguy
authored andcommitted
memory access fixes/workarounds for the pi5
1 parent 3edaa38 commit 88687a9

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ static int amdgpu_device_wb_init(struct amdgpu_device *adev)
10481048
memset(&adev->wb.used, 0, sizeof(adev->wb.used));
10491049

10501050
/* clear wb memory */
1051-
memset((char *)adev->wb.wb, 0, AMDGPU_MAX_WB * sizeof(uint32_t) * 8);
1051+
memset_io((char *)adev->wb.wb, 0, AMDGPU_MAX_WB * sizeof(uint32_t) * 8);
10521052
}
10531053

10541054
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ int amdgpu_gfx_kiq_init(struct amdgpu_device *adev,
364364
return r;
365365
}
366366

367-
memset(hpd, 0, hpd_size);
367+
memset_io(hpd, 0, hpd_size);
368368

369369
r = amdgpu_bo_reserve(kiq->eop_obj, true);
370370
if (unlikely(r != 0))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int amdgpu_sa_bo_manager_init(struct amdgpu_device *adev,
5858
return r;
5959
}
6060

61-
memset(sa_manager->cpu_ptr, 0, size);
61+
memset_io(sa_manager->cpu_ptr, 0, size);
6262
drm_suballoc_manager_init(&sa_manager->base, size, suballoc_align);
6363
return r;
6464
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo,
11011101
if (abo->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC)
11021102
caching = ttm_write_combined;
11031103
else
1104-
caching = ttm_cached;
1104+
caching = ttm_uncached;
11051105

11061106
/* allocate space for the uninitialized page entries */
11071107
if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags, caching)) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
962962
le32_to_cpu(header->ucode_array_offset_bytes);
963963
}
964964

965-
memcpy(ucode->kaddr, ucode_addr, ucode->ucode_size);
965+
memcpy_toio(ucode->kaddr, ucode_addr, ucode->ucode_size);
966966

967967
return 0;
968968
}
@@ -986,7 +986,7 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode,
986986
src_addr = (uint8_t *)ucode->fw->data +
987987
le32_to_cpu(comm_hdr->ucode_array_offset_bytes) +
988988
(le32_to_cpu(header->jt_offset) * 4);
989-
memcpy(dst_addr, src_addr, le32_to_cpu(header->jt_size) * 4);
989+
memcpy_toio(dst_addr, src_addr, le32_to_cpu(header->jt_size) * 4);
990990

991991
return 0;
992992
}
@@ -1003,7 +1003,7 @@ int amdgpu_ucode_create_bo(struct amdgpu_device *adev)
10031003
dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n");
10041004
return -ENOMEM;
10051005
} else if (amdgpu_sriov_vf(adev)) {
1006-
memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
1006+
memset_io(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
10071007
}
10081008
}
10091009
return 0;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ int amdgpu_uvd_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
11961196
{
11971197
struct amdgpu_device *adev = ring->adev;
11981198
struct amdgpu_bo *bo = adev->uvd.ib_bo;
1199-
uint32_t *msg;
1199+
volatile uint32_t *msg;
12001200
int i;
12011201

12021202
msg = amdgpu_bo_kptr(bo);
@@ -1224,7 +1224,7 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
12241224
{
12251225
struct amdgpu_device *adev = ring->adev;
12261226
struct amdgpu_bo *bo = NULL;
1227-
uint32_t *msg;
1227+
volatile uint32_t *msg;
12281228
int r, i;
12291229

12301230
if (direct) {

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ static int gfx_v8_0_mec_init(struct amdgpu_device *adev)
13221322
return r;
13231323
}
13241324

1325-
memset(hpd, 0, mec_hpd_size);
1325+
memset_io(hpd, 0, mec_hpd_size);
13261326

13271327
amdgpu_bo_kunmap(adev->gfx.mec.hpd_eop_obj);
13281328
amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
@@ -4395,7 +4395,7 @@ static int gfx_v8_0_deactivate_hqd(struct amdgpu_device *adev, u32 req)
43954395
return r;
43964396
}
43974397

4398-
static void gfx_v8_0_mqd_set_priority(struct amdgpu_ring *ring, struct vi_mqd *mqd)
4398+
static void gfx_v8_0_mqd_set_priority(struct amdgpu_ring *ring, volatile struct vi_mqd *mqd)
43994399
{
44004400
struct amdgpu_device *adev = ring->adev;
44014401

@@ -4411,7 +4411,7 @@ static void gfx_v8_0_mqd_set_priority(struct amdgpu_ring *ring, struct vi_mqd *m
44114411
static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)
44124412
{
44134413
struct amdgpu_device *adev = ring->adev;
4414-
struct vi_mqd *mqd = ring->mqd_ptr;
4414+
volatile struct vi_mqd *mqd = ring->mqd_ptr;
44154415
uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr;
44164416
uint32_t tmp;
44174417

@@ -4422,11 +4422,13 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)
44224422
mqd->compute_static_thread_mgmt_se2 = 0xffffffff;
44234423
mqd->compute_static_thread_mgmt_se3 = 0xffffffff;
44244424
mqd->compute_misc_reserved = 0x00000003;
4425+
44254426
mqd->dynamic_cu_mask_addr_lo = lower_32_bits(ring->mqd_gpu_addr
44264427
+ offsetof(struct vi_mqd_allocation, dynamic_cu_mask));
44274428
mqd->dynamic_cu_mask_addr_hi = upper_32_bits(ring->mqd_gpu_addr
44284429
+ offsetof(struct vi_mqd_allocation, dynamic_cu_mask));
44294430
eop_base_addr = ring->eop_gpu_addr >> 8;
4431+
44304432
mqd->cp_hqd_eop_base_addr_lo = eop_base_addr;
44314433
mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_base_addr);
44324434

@@ -4602,7 +4604,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
46024604
if (amdgpu_in_reset(adev)) { /* for GPU_RESET case */
46034605
/* reset MQD to a clean status */
46044606
if (adev->gfx.kiq[0].mqd_backup)
4605-
memcpy(mqd, adev->gfx.kiq[0].mqd_backup, sizeof(struct vi_mqd_allocation));
4607+
memcpy_toio(mqd, adev->gfx.kiq[0].mqd_backup, sizeof(struct vi_mqd_allocation));
46064608

46074609
/* reset ring buffer */
46084610
ring->wptr = 0;
@@ -4613,7 +4615,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
46134615
vi_srbm_select(adev, 0, 0, 0, 0);
46144616
mutex_unlock(&adev->srbm_mutex);
46154617
} else {
4616-
memset((void *)mqd, 0, sizeof(struct vi_mqd_allocation));
4618+
memset_io((void *)mqd, 0, sizeof(struct vi_mqd_allocation));
46174619
((struct vi_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF;
46184620
((struct vi_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
46194621
if (amdgpu_sriov_vf(adev) && adev->in_suspend)
@@ -4626,7 +4628,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
46264628
mutex_unlock(&adev->srbm_mutex);
46274629

46284630
if (adev->gfx.kiq[0].mqd_backup)
4629-
memcpy(adev->gfx.kiq[0].mqd_backup, mqd, sizeof(struct vi_mqd_allocation));
4631+
memcpy_fromio(adev->gfx.kiq[0].mqd_backup, mqd, sizeof(struct vi_mqd_allocation));
46304632
}
46314633

46324634
return 0;
@@ -4639,7 +4641,7 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)
46394641
int mqd_idx = ring - &adev->gfx.compute_ring[0];
46404642

46414643
if (!amdgpu_in_reset(adev) && !adev->in_suspend) {
4642-
memset((void *)mqd, 0, sizeof(struct vi_mqd_allocation));
4644+
memset_io((void *)mqd, 0, sizeof(struct vi_mqd_allocation));
46434645
((struct vi_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF;
46444646
((struct vi_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
46454647
mutex_lock(&adev->srbm_mutex);
@@ -4649,11 +4651,11 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)
46494651
mutex_unlock(&adev->srbm_mutex);
46504652

46514653
if (adev->gfx.mec.mqd_backup[mqd_idx])
4652-
memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct vi_mqd_allocation));
4654+
memcpy_fromio(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct vi_mqd_allocation));
46534655
} else {
46544656
/* restore MQD to a clean status */
46554657
if (adev->gfx.mec.mqd_backup[mqd_idx])
4656-
memcpy(mqd, adev->gfx.mec.mqd_backup[mqd_idx], sizeof(struct vi_mqd_allocation));
4658+
memcpy_toio(mqd, adev->gfx.mec.mqd_backup[mqd_idx], sizeof(struct vi_mqd_allocation));
46574659
/* reset ring buffer */
46584660
ring->wptr = 0;
46594661
amdgpu_ring_clear_ring(ring);

0 commit comments

Comments
 (0)