Skip to content

Commit d472b36

Browse files
committed
Merge tag 'amd-drm-next-5.14-2021-06-16' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-next-5.14-2021-06-16: amdgpu: - Aldebaran fixes - Expose asic independent throttler status - BACO fixes for navi1x - Smartshift fixes - Misc code cleanups - RAS fixes for Sienna Cichlid - Gamma verificaton fixes - DC LTTPR fixes - DP AUX timeout handling fixes - GFX9, 10 powergating fixes amdkfd: - TLB flush fixes when using SDMA - Locking fixes - SVM fixes Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210617031719.4013-1-alexander.deucher@amd.com
2 parents 43ccc78 + a4b0b97 commit d472b36

103 files changed

Lines changed: 2362 additions & 888 deletions

File tree

Some content is hidden

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

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

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ static struct {
4747
spinlock_t mem_limit_lock;
4848
} kfd_mem_limit;
4949

50-
/* Struct used for amdgpu_amdkfd_bo_validate */
51-
struct amdgpu_vm_parser {
52-
uint32_t domain;
53-
bool wait;
54-
};
55-
5650
static const char * const domain_bit_to_string[] = {
5751
"CPU",
5852
"GTT",
@@ -348,11 +342,9 @@ static int amdgpu_amdkfd_bo_validate(struct amdgpu_bo *bo, uint32_t domain,
348342
return ret;
349343
}
350344

351-
static int amdgpu_amdkfd_validate(void *param, struct amdgpu_bo *bo)
345+
static int amdgpu_amdkfd_validate_vm_bo(void *_unused, struct amdgpu_bo *bo)
352346
{
353-
struct amdgpu_vm_parser *p = param;
354-
355-
return amdgpu_amdkfd_bo_validate(bo, p->domain, p->wait);
347+
return amdgpu_amdkfd_bo_validate(bo, bo->allowed_domains, false);
356348
}
357349

358350
/* vm_validate_pt_pd_bos - Validate page table and directory BOs
@@ -364,28 +356,23 @@ static int amdgpu_amdkfd_validate(void *param, struct amdgpu_bo *bo)
364356
*/
365357
static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm)
366358
{
367-
struct amdgpu_bo *pd = vm->root.base.bo;
359+
struct amdgpu_bo *pd = vm->root.bo;
368360
struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev);
369-
struct amdgpu_vm_parser param;
370361
int ret;
371362

372-
param.domain = AMDGPU_GEM_DOMAIN_VRAM;
373-
param.wait = false;
374-
375-
ret = amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_amdkfd_validate,
376-
&param);
363+
ret = amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_amdkfd_validate_vm_bo, NULL);
377364
if (ret) {
378365
pr_err("failed to validate PT BOs\n");
379366
return ret;
380367
}
381368

382-
ret = amdgpu_amdkfd_validate(&param, pd);
369+
ret = amdgpu_amdkfd_validate_vm_bo(NULL, pd);
383370
if (ret) {
384371
pr_err("failed to validate PD\n");
385372
return ret;
386373
}
387374

388-
vm->pd_phys_addr = amdgpu_gmc_pd_addr(vm->root.base.bo);
375+
vm->pd_phys_addr = amdgpu_gmc_pd_addr(vm->root.bo);
389376

390377
if (vm->use_cpu_for_update) {
391378
ret = amdgpu_bo_kmap(pd, NULL);
@@ -400,7 +387,7 @@ static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm)
400387

401388
static int vm_update_pds(struct amdgpu_vm *vm, struct amdgpu_sync *sync)
402389
{
403-
struct amdgpu_bo *pd = vm->root.base.bo;
390+
struct amdgpu_bo *pd = vm->root.bo;
404391
struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev);
405392
int ret;
406393

@@ -652,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
652639
}
653640
}
654641

655-
gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
642+
gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
656643
if (IS_ERR(gobj))
657644
return PTR_ERR(gobj);
658645

@@ -1166,7 +1153,7 @@ static int process_sync_pds_resv(struct amdkfd_process_info *process_info,
11661153

11671154
list_for_each_entry(peer_vm, &process_info->vm_list_head,
11681155
vm_list_node) {
1169-
struct amdgpu_bo *pd = peer_vm->root.base.bo;
1156+
struct amdgpu_bo *pd = peer_vm->root.bo;
11701157

11711158
ret = amdgpu_sync_resv(NULL, sync, pd->tbo.base.resv,
11721159
AMDGPU_SYNC_NE_OWNER,
@@ -1233,24 +1220,24 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
12331220
vm->process_info = *process_info;
12341221

12351222
/* Validate page directory and attach eviction fence */
1236-
ret = amdgpu_bo_reserve(vm->root.base.bo, true);
1223+
ret = amdgpu_bo_reserve(vm->root.bo, true);
12371224
if (ret)
12381225
goto reserve_pd_fail;
12391226
ret = vm_validate_pt_pd_bos(vm);
12401227
if (ret) {
12411228
pr_err("validate_pt_pd_bos() failed\n");
12421229
goto validate_pd_fail;
12431230
}
1244-
ret = amdgpu_bo_sync_wait(vm->root.base.bo,
1231+
ret = amdgpu_bo_sync_wait(vm->root.bo,
12451232
AMDGPU_FENCE_OWNER_KFD, false);
12461233
if (ret)
12471234
goto wait_pd_fail;
1248-
ret = dma_resv_reserve_shared(vm->root.base.bo->tbo.base.resv, 1);
1235+
ret = dma_resv_reserve_shared(vm->root.bo->tbo.base.resv, 1);
12491236
if (ret)
12501237
goto reserve_shared_fail;
1251-
amdgpu_bo_fence(vm->root.base.bo,
1238+
amdgpu_bo_fence(vm->root.bo,
12521239
&vm->process_info->eviction_fence->base, true);
1253-
amdgpu_bo_unreserve(vm->root.base.bo);
1240+
amdgpu_bo_unreserve(vm->root.bo);
12541241

12551242
/* Update process info */
12561243
mutex_lock(&vm->process_info->lock);
@@ -1264,7 +1251,7 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
12641251
reserve_shared_fail:
12651252
wait_pd_fail:
12661253
validate_pd_fail:
1267-
amdgpu_bo_unreserve(vm->root.base.bo);
1254+
amdgpu_bo_unreserve(vm->root.bo);
12681255
reserve_pd_fail:
12691256
vm->process_info = NULL;
12701257
if (info) {
@@ -1319,7 +1306,7 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
13191306
struct amdgpu_vm *vm)
13201307
{
13211308
struct amdkfd_process_info *process_info = vm->process_info;
1322-
struct amdgpu_bo *pd = vm->root.base.bo;
1309+
struct amdgpu_bo *pd = vm->root.bo;
13231310

13241311
if (!process_info)
13251312
return;
@@ -1375,7 +1362,7 @@ void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *drm_priv)
13751362
uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv)
13761363
{
13771364
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
1378-
struct amdgpu_bo *pd = avm->root.base.bo;
1365+
struct amdgpu_bo *pd = avm->root.bo;
13791366
struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev);
13801367

13811368
if (adev->asic_type < CHIP_VEGA10)
@@ -2402,7 +2389,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
24022389
/* Attach eviction fence to PD / PT BOs */
24032390
list_for_each_entry(peer_vm, &process_info->vm_list_head,
24042391
vm_list_node) {
2405-
struct amdgpu_bo *bo = peer_vm->root.base.bo;
2392+
struct amdgpu_bo *bo = peer_vm->root.bo;
24062393

24072394
amdgpu_bo_fence(bo, &process_info->eviction_fence->base, true);
24082395
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
832832
if (r)
833833
return r;
834834

835-
p->job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.base.bo);
835+
p->job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.bo);
836836

837837
if (amdgpu_vm_debug) {
838838
/* Invalidate all BOs to test for userspace bugs */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,11 +1304,11 @@ static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused)
13041304

13051305
seq_printf(m, "pid:%d\tProcess:%s ----------\n",
13061306
vm->task_info.pid, vm->task_info.process_name);
1307-
r = amdgpu_bo_reserve(vm->root.base.bo, true);
1307+
r = amdgpu_bo_reserve(vm->root.bo, true);
13081308
if (r)
13091309
break;
13101310
amdgpu_debugfs_vm_bo_info(vm, m);
1311-
amdgpu_bo_unreserve(vm->root.base.bo);
1311+
amdgpu_bo_unreserve(vm->root.bo);
13121312
}
13131313

13141314
mutex_unlock(&dev->filelist_mutex);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,7 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
41244124
{
41254125
struct dma_fence *fence = NULL, *next = NULL;
41264126
struct amdgpu_bo *shadow;
4127+
struct amdgpu_bo_vm *vmbo;
41274128
long r = 1, tmo;
41284129

41294130
if (amdgpu_sriov_runtime(adev))
@@ -4133,8 +4134,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
41334134

41344135
dev_info(adev->dev, "recover vram bo from shadow start\n");
41354136
mutex_lock(&adev->shadow_list_lock);
4136-
list_for_each_entry(shadow, &adev->shadow_list, shadow_list) {
4137-
4137+
list_for_each_entry(vmbo, &adev->shadow_list, shadow_list) {
4138+
shadow = &vmbo->bo;
41384139
/* No need to recover an evicted BO */
41394140
if (shadow->tbo.resource->mem_type != TTM_PL_TT ||
41404141
shadow->tbo.resource->start == AMDGPU_BO_INVALID_OFFSET ||

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
325325
return 0;
326326
}
327327

328-
int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
328+
int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
329329
int *major, int *minor, int *revision)
330330
{
331331
struct binary_header *bhdr;
@@ -357,7 +357,7 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
357357
for (j = 0; j < num_ips; j++) {
358358
ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
359359

360-
if (le16_to_cpu(ip->hw_id) == hw_id) {
360+
if ((le16_to_cpu(ip->hw_id) == hw_id) && (ip->number_instance == number_instance)) {
361361
if (major)
362362
*major = ip->major;
363363
if (minor)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
void amdgpu_discovery_fini(struct amdgpu_device *adev);
3131
int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
3232
void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev);
33-
int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
33+
int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
3434
int *major, int *minor, int *revision);
3535
int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev);
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
448448

449449
for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) {
450450
struct amdgpu_vm *vm = bo_base->vm;
451-
struct dma_resv *resv = vm->root.base.bo->tbo.base.resv;
451+
struct dma_resv *resv = vm->root.bo->tbo.base.resv;
452452

453453
if (ticket) {
454454
/* When we get an error here it means that somebody

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
6969
dev = PCI_SLOT(adev->pdev->devfn);
7070
fn = PCI_FUNC(adev->pdev->devfn);
7171

72-
ret = amdgpu_bo_reserve(fpriv->vm.root.base.bo, false);
72+
ret = amdgpu_bo_reserve(fpriv->vm.root.bo, false);
7373
if (ret) {
7474
DRM_ERROR("Fail to reserve bo\n");
7575
return;
7676
}
7777
amdgpu_vm_get_memory(&fpriv->vm, &vram_mem, &gtt_mem, &cpu_mem);
78-
amdgpu_bo_unreserve(fpriv->vm.root.base.bo);
78+
amdgpu_bo_unreserve(fpriv->vm.root.bo);
7979
seq_printf(m, "pdev:\t%04x:%02x:%02x.%d\npasid:\t%u\n", domain, bus,
8080
dev, fn, fpriv->vm.pasid);
8181
seq_printf(m, "vram mem:\t%llu kB\n", vram_mem/1024UL);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int amdgpu_gem_object_open(struct drm_gem_object *obj,
170170
return -EPERM;
171171

172172
if (abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID &&
173-
abo->tbo.base.resv != vm->root.base.bo->tbo.base.resv)
173+
abo->tbo.base.resv != vm->root.bo->tbo.base.resv)
174174
return -EPERM;
175175

176176
r = amdgpu_bo_reserve(abo, false);
@@ -320,11 +320,11 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
320320
}
321321

322322
if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
323-
r = amdgpu_bo_reserve(vm->root.base.bo, false);
323+
r = amdgpu_bo_reserve(vm->root.bo, false);
324324
if (r)
325325
return r;
326326

327-
resv = vm->root.base.bo->tbo.base.resv;
327+
resv = vm->root.bo->tbo.base.resv;
328328
}
329329

330330
initial_domain = (u32)(0xffffffff & args->in.domains);
@@ -353,9 +353,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
353353
if (!r) {
354354
struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
355355

356-
abo->parent = amdgpu_bo_ref(vm->root.base.bo);
356+
abo->parent = amdgpu_bo_ref(vm->root.bo);
357357
}
358-
amdgpu_bo_unreserve(vm->root.base.bo);
358+
amdgpu_bo_unreserve(vm->root.bo);
359359
}
360360
if (r)
361361
return r;
@@ -841,7 +841,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
841841
}
842842
for (base = robj->vm_bo; base; base = base->next)
843843
if (amdgpu_xgmi_same_hive(amdgpu_ttm_adev(robj->tbo.bdev),
844-
amdgpu_ttm_adev(base->vm->root.base.bo->tbo.bdev))) {
844+
amdgpu_ttm_adev(base->vm->root.bo->tbo.bdev))) {
845845
r = -EINVAL;
846846
amdgpu_bo_unreserve(robj);
847847
goto out;

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
124124
mutex_unlock(&mgpu_info.mutex);
125125
}
126126

127+
static void amdgpu_get_audio_func(struct amdgpu_device *adev)
128+
{
129+
struct pci_dev *p = NULL;
130+
131+
p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
132+
adev->pdev->bus->number, 1);
133+
if (p) {
134+
pm_runtime_get_sync(&p->dev);
135+
136+
pm_runtime_mark_last_busy(&p->dev);
137+
pm_runtime_put_autosuspend(&p->dev);
138+
139+
pci_dev_put(p);
140+
}
141+
}
142+
127143
/**
128144
* amdgpu_driver_load_kms - Main load function for KMS.
129145
*
@@ -213,9 +229,35 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
213229
DPM_FLAG_MAY_SKIP_RESUME);
214230
pm_runtime_use_autosuspend(dev->dev);
215231
pm_runtime_set_autosuspend_delay(dev->dev, 5000);
232+
216233
pm_runtime_allow(dev->dev);
234+
217235
pm_runtime_mark_last_busy(dev->dev);
218236
pm_runtime_put_autosuspend(dev->dev);
237+
238+
/*
239+
* For runpm implemented via BACO, PMFW will handle the
240+
* timing for BACO in and out:
241+
* - put ASIC into BACO state only when both video and
242+
* audio functions are in D3 state.
243+
* - pull ASIC out of BACO state when either video or
244+
* audio function is in D0 state.
245+
* Also, at startup, PMFW assumes both functions are in
246+
* D0 state.
247+
*
248+
* So if snd driver was loaded prior to amdgpu driver
249+
* and audio function was put into D3 state, there will
250+
* be no PMFW-aware D-state transition(D0->D3) on runpm
251+
* suspend. Thus the BACO will be not correctly kicked in.
252+
*
253+
* Via amdgpu_get_audio_func(), the audio dev is put
254+
* into D0 state. Then there will be a PMFW-aware D-state
255+
* transition(D0->D3) on runpm suspend.
256+
*/
257+
if (amdgpu_device_supports_baco(dev) &&
258+
!(adev->flags & AMD_IS_APU) &&
259+
(adev->asic_type >= CHIP_NAVI10))
260+
amdgpu_get_audio_func(adev);
219261
}
220262

221263
if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DRV_LOAD))
@@ -1220,7 +1262,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
12201262
}
12211263

12221264
pasid = fpriv->vm.pasid;
1223-
pd = amdgpu_bo_ref(fpriv->vm.root.base.bo);
1265+
pd = amdgpu_bo_ref(fpriv->vm.root.bo);
12241266

12251267
amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
12261268
amdgpu_vm_fini(adev, &fpriv->vm);

0 commit comments

Comments
 (0)