Skip to content

Commit add74e3

Browse files
committed
Merge tag 'amd-drm-next-5.13-2021-04-23' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-next-5.13-2021-04-23: amdgpu: - Fixes for Aldebaran - Display LTTPR fixes - eDP fixes - Fixes for Vangogh - RAS fixes - ASPM support - Renoir SMU fixes - Modifier fixes - Misc code cleanups - Freesync fixes Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 9b2788d + 7845d80 commit add74e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1854
-445
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,10 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s
234234
})
235235

236236
/* GPUVM API */
237-
int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, u32 pasid,
238-
void **vm, void **process_info,
239-
struct dma_fence **ef);
240237
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd,
241238
struct file *filp, u32 pasid,
242239
void **vm, void **process_info,
243240
struct dma_fence **ef);
244-
void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm);
245241
void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm);
246242
uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm);
247243
int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(

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

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -445,22 +445,19 @@ static uint64_t get_pte_flags(struct amdgpu_device *adev, struct kgd_mem *mem)
445445
mapping_flags |= AMDGPU_VM_MTYPE_UC;
446446
} else if (mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
447447
if (bo_adev == adev) {
448-
mapping_flags |= AMDGPU_VM_MTYPE_RW;
448+
mapping_flags |= coherent ?
449+
AMDGPU_VM_MTYPE_CC : AMDGPU_VM_MTYPE_RW;
449450
if (adev->gmc.xgmi.connected_to_cpu)
450451
snoop = true;
451452
} else {
452-
mapping_flags |= AMDGPU_VM_MTYPE_NC;
453+
mapping_flags |= AMDGPU_VM_MTYPE_UC;
453454
if (amdgpu_xgmi_same_hive(adev, bo_adev))
454455
snoop = true;
455456
}
456457
} else {
457458
snoop = true;
458-
if (adev->gmc.xgmi.connected_to_cpu)
459-
/* system memory uses NC on A+A */
460-
mapping_flags |= AMDGPU_VM_MTYPE_NC;
461-
else
462-
mapping_flags |= coherent ?
463-
AMDGPU_VM_MTYPE_UC : AMDGPU_VM_MTYPE_NC;
459+
mapping_flags |= coherent ?
460+
AMDGPU_VM_MTYPE_UC : AMDGPU_VM_MTYPE_NC;
464461
}
465462
break;
466463
default:
@@ -1037,41 +1034,6 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
10371034
return ret;
10381035
}
10391036

1040-
int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, u32 pasid,
1041-
void **vm, void **process_info,
1042-
struct dma_fence **ef)
1043-
{
1044-
struct amdgpu_device *adev = get_amdgpu_device(kgd);
1045-
struct amdgpu_vm *new_vm;
1046-
int ret;
1047-
1048-
new_vm = kzalloc(sizeof(*new_vm), GFP_KERNEL);
1049-
if (!new_vm)
1050-
return -ENOMEM;
1051-
1052-
/* Initialize AMDGPU part of the VM */
1053-
ret = amdgpu_vm_init(adev, new_vm, AMDGPU_VM_CONTEXT_COMPUTE, pasid);
1054-
if (ret) {
1055-
pr_err("Failed init vm ret %d\n", ret);
1056-
goto amdgpu_vm_init_fail;
1057-
}
1058-
1059-
/* Initialize KFD part of the VM and process info */
1060-
ret = init_kfd_vm(new_vm, process_info, ef);
1061-
if (ret)
1062-
goto init_kfd_vm_fail;
1063-
1064-
*vm = (void *) new_vm;
1065-
1066-
return 0;
1067-
1068-
init_kfd_vm_fail:
1069-
amdgpu_vm_fini(adev, new_vm);
1070-
amdgpu_vm_init_fail:
1071-
kfree(new_vm);
1072-
return ret;
1073-
}
1074-
10751037
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd,
10761038
struct file *filp, u32 pasid,
10771039
void **vm, void **process_info,
@@ -1138,21 +1100,6 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
11381100
}
11391101
}
11401102

1141-
void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm)
1142-
{
1143-
struct amdgpu_device *adev = get_amdgpu_device(kgd);
1144-
struct amdgpu_vm *avm = (struct amdgpu_vm *)vm;
1145-
1146-
if (WARN_ON(!kgd || !vm))
1147-
return;
1148-
1149-
pr_debug("Destroying process vm %p\n", vm);
1150-
1151-
/* Release the VM context */
1152-
amdgpu_vm_fini(adev, avm);
1153-
kfree(vm);
1154-
}
1155-
11561103
void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm)
11571104
{
11581105
struct amdgpu_device *adev = get_amdgpu_device(kgd);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,19 @@ int amdgpu_display_gem_fb_verify_and_init(
908908
&amdgpu_fb_funcs);
909909
if (ret)
910910
goto err;
911+
/* Verify that the modifier is supported. */
912+
if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
913+
mode_cmd->modifier[0])) {
914+
struct drm_format_name_buf format_name;
915+
drm_dbg_kms(dev,
916+
"unsupported pixel format %s / modifier 0x%llx\n",
917+
drm_get_format_name(mode_cmd->pixel_format,
918+
&format_name),
919+
mode_cmd->modifier[0]);
920+
921+
ret = -EINVAL;
922+
goto err;
923+
}
911924

912925
ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj);
913926
if (ret)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach,
291291
break;
292292

293293
case TTM_PL_VRAM:
294-
r = amdgpu_vram_mgr_alloc_sgt(adev, &bo->tbo.mem, attach->dev,
295-
dir, &sgt);
294+
r = amdgpu_vram_mgr_alloc_sgt(adev, &bo->tbo.mem, 0,
295+
bo->tbo.base.size, attach->dev, dir, &sgt);
296296
if (r)
297297
return ERR_PTR(r);
298298
break;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ uint amdgpu_ras_mask = 0xffffffff;
185185
int amdgpu_bad_page_threshold = -1;
186186
struct amdgpu_watchdog_timer amdgpu_watchdog_timer = {
187187
.timeout_fatal_disable = false,
188-
.period = 0x23, /* default to max. timeout = 1 << 0x23 cycles */
188+
.period = 0x0, /* default to 0x0 (timeout disable) */
189189
};
190190

191191
/**
@@ -553,7 +553,7 @@ module_param_named(timeout_fatal_disable, amdgpu_watchdog_timer.timeout_fatal_di
553553
* DOC: timeout_period (uint)
554554
* Modify the watchdog timeout max_cycles as (1 << period)
555555
*/
556-
MODULE_PARM_DESC(timeout_period, "watchdog timeout period (1 to 0x23(default), timeout maxCycles = (1 << period)");
556+
MODULE_PARM_DESC(timeout_period, "watchdog timeout period (0 = timeout disabled, 1 ~ 0x23 = timeout maxcycles = (1 << period)");
557557
module_param_named(timeout_period, amdgpu_watchdog_timer.period, uint, 0644);
558558

559559
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
205205
struct drm_gem_object *gobj = NULL;
206206
struct amdgpu_bo *abo = NULL;
207207
int ret;
208-
unsigned long tmp;
209208

210209
memset(&mode_cmd, 0, sizeof(mode_cmd));
211210
mode_cmd.width = sizes->surface_width;
@@ -246,8 +245,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
246245

247246
info->fbops = &amdgpufb_ops;
248247

249-
tmp = amdgpu_bo_gpu_offset(abo) - adev->gmc.vram_start;
250-
info->fix.smem_start = adev->gmc.aper_base + tmp;
248+
info->fix.smem_start = amdgpu_gmc_vram_cpu_pa(adev, abo);
251249
info->fix.smem_len = amdgpu_bo_size(abo);
252250
info->screen_base = amdgpu_bo_kptr(abo);
253251
info->screen_size = amdgpu_bo_size(abo);

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ void amdgpu_gmc_tmz_set(struct amdgpu_device *adev)
487487
{
488488
switch (adev->asic_type) {
489489
case CHIP_RAVEN:
490+
case CHIP_RENOIR:
490491
if (amdgpu_tmz == 0) {
491492
adev->gmc.tmz_enabled = false;
492493
dev_info(adev->dev,
@@ -497,7 +498,6 @@ void amdgpu_gmc_tmz_set(struct amdgpu_device *adev)
497498
"Trusted Memory Zone (TMZ) feature enabled\n");
498499
}
499500
break;
500-
case CHIP_RENOIR:
501501
case CHIP_NAVI10:
502502
case CHIP_NAVI14:
503503
case CHIP_NAVI12:
@@ -661,8 +661,7 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev)
661661
u64 vram_addr = adev->vm_manager.vram_base_offset -
662662
adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;
663663
u64 vram_end = vram_addr + vram_size;
664-
u64 gart_ptb_gpu_pa = amdgpu_bo_gpu_offset(adev->gart.bo) +
665-
adev->vm_manager.vram_base_offset - adev->gmc.vram_start;
664+
u64 gart_ptb_gpu_pa = amdgpu_gmc_vram_pa(adev, adev->gart.bo);
666665

667666
flags |= AMDGPU_PTE_VALID | AMDGPU_PTE_READABLE;
668667
flags |= AMDGPU_PTE_WRITEABLE;
@@ -685,3 +684,39 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev)
685684
/* Requires gart_ptb_gpu_pa to be 4K aligned */
686685
amdgpu_gmc_set_pte_pde(adev, adev->gmc.ptr_pdb0, i, gart_ptb_gpu_pa, flags);
687686
}
687+
688+
/**
689+
* amdgpu_gmc_vram_mc2pa - calculate vram buffer's physical address from MC
690+
* address
691+
*
692+
* @adev: amdgpu_device pointer
693+
* @mc_addr: MC address of buffer
694+
*/
695+
uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr)
696+
{
697+
return mc_addr - adev->gmc.vram_start + adev->vm_manager.vram_base_offset;
698+
}
699+
700+
/**
701+
* amdgpu_gmc_vram_pa - calculate vram buffer object's physical address from
702+
* GPU's view
703+
*
704+
* @adev: amdgpu_device pointer
705+
* @bo: amdgpu buffer object
706+
*/
707+
uint64_t amdgpu_gmc_vram_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo)
708+
{
709+
return amdgpu_gmc_vram_mc2pa(adev, amdgpu_bo_gpu_offset(bo));
710+
}
711+
712+
/**
713+
* amdgpu_gmc_vram_cpu_pa - calculate vram buffer object's physical address
714+
* from CPU's view
715+
*
716+
* @adev: amdgpu_device pointer
717+
* @bo: amdgpu buffer object
718+
*/
719+
uint64_t amdgpu_gmc_vram_cpu_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo)
720+
{
721+
return amdgpu_bo_gpu_offset(bo) - adev->gmc.vram_start + adev->gmc.aper_base;
722+
}

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,6 @@ struct amdgpu_gmc {
218218
*/
219219
u64 fb_start;
220220
u64 fb_end;
221-
/* In the case of use GART table for vmid0 FB access, [fb_start, fb_end]
222-
* will be squeezed to GART aperture. But we have a PSP FW issue to fix
223-
* for now. To temporarily workaround the PSP FW issue, added below two
224-
* variables to remember the original fb_start/end to re-enable FB
225-
* aperture to workaround the PSP FW issue. Will delete it after we
226-
* get a proper PSP FW fix.
227-
*/
228-
u64 fb_start_original;
229-
u64 fb_end_original;
230221
unsigned vram_width;
231222
u64 real_vram_size;
232223
int vram_mtrr;
@@ -341,4 +332,7 @@ amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
341332
void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
342333

343334
void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev);
335+
uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);
336+
uint64_t amdgpu_gmc_vram_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo);
337+
uint64_t amdgpu_gmc_vram_cpu_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo);
344338
#endif

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
7676
}
7777

7878
ib->ptr = amdgpu_sa_bo_cpu_addr(ib->sa_bo);
79+
/* flush the cache before commit the IB */
80+
ib->flags = AMDGPU_IB_FLAG_EMIT_MEM_SYNC;
7981

8082
if (!vm)
8183
ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ static int init_pmu_entry_by_type_and_add(struct amdgpu_pmu_entry *pmu_entry,
519519
pmu_entry->pmu.attr_groups = kmemdup(attr_groups, sizeof(attr_groups),
520520
GFP_KERNEL);
521521

522-
if (!pmu_entry->pmu.attr_groups)
522+
if (!pmu_entry->pmu.attr_groups) {
523+
ret = -ENOMEM;
523524
goto err_attr_group;
525+
}
524526

525527
snprintf(pmu_name, PMU_NAME_SIZE, "%s_%d", pmu_entry->pmu_file_prefix,
526528
adev_to_drm(pmu_entry->adev)->primary->index);

0 commit comments

Comments
 (0)