Skip to content

Commit 951bad0

Browse files
committed
Merge tag 'amd-drm-fixes-5.16-2021-11-10' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-fixes-5.16-2021-11-10: amdgpu: - Don't allow partial copy from user for DC debugfs - SRIOV fixes - GFX9 CSB pin count fix - Various IP version check fixes - DP 2.0 fixes - Limit DCN1 MPO fix to DCN1 amdkfd: - SVM fixes - Reset fixes Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211110222536.7527-1-alexander.deucher@amd.com
2 parents f8ca7b7 + 4d395f9 commit 951bad0

32 files changed

Lines changed: 205 additions & 79 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void amdgpu_amdkfd_ras_poison_consumption_handler(struct kgd_dev *kgd);
297297
void amdgpu_amdkfd_gpuvm_init_mem_limits(void);
298298
void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
299299
struct amdgpu_vm *vm);
300-
void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo);
300+
void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo);
301301
void amdgpu_amdkfd_reserve_system_mem(uint64_t size);
302302
#else
303303
static inline
@@ -312,7 +312,7 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
312312
}
313313

314314
static inline
315-
void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
315+
void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo)
316316
{
317317
}
318318
#endif

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void unreserve_mem_limit(struct amdgpu_device *adev,
207207
spin_unlock(&kfd_mem_limit.mem_limit_lock);
208208
}
209209

210-
void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
210+
void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo)
211211
{
212212
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
213213
u32 domain = bo->preferred_domains;
@@ -219,6 +219,8 @@ void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
219219
}
220220

221221
unreserve_mem_limit(adev, amdgpu_bo_size(bo), domain, sg);
222+
223+
kfree(bo->kfd_bo);
222224
}
223225

224226

@@ -734,14 +736,19 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
734736
}
735737

736738
/* Add BO to VM internal data structures */
739+
ret = amdgpu_bo_reserve(bo[i], false);
740+
if (ret) {
741+
pr_debug("Unable to reserve BO during memory attach");
742+
goto unwind;
743+
}
737744
attachment[i]->bo_va = amdgpu_vm_bo_add(adev, vm, bo[i]);
745+
amdgpu_bo_unreserve(bo[i]);
738746
if (unlikely(!attachment[i]->bo_va)) {
739747
ret = -ENOMEM;
740748
pr_err("Failed to add BO object to VM. ret == %d\n",
741749
ret);
742750
goto unwind;
743751
}
744-
745752
attachment[i]->va = va;
746753
attachment[i]->pte_flags = get_pte_flags(adev, mem);
747754
attachment[i]->adev = adev;
@@ -757,7 +764,9 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
757764
if (!attachment[i])
758765
continue;
759766
if (attachment[i]->bo_va) {
767+
amdgpu_bo_reserve(bo[i], true);
760768
amdgpu_vm_bo_rmv(adev, attachment[i]->bo_va);
769+
amdgpu_bo_unreserve(bo[i]);
761770
list_del(&attachment[i]->list);
762771
}
763772
if (bo[i])
@@ -1568,12 +1577,12 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
15681577
pr_debug("Release VA 0x%llx - 0x%llx\n", mem->va,
15691578
mem->va + bo_size * (1 + mem->aql_queue));
15701579

1571-
ret = unreserve_bo_and_vms(&ctx, false, false);
1572-
15731580
/* Remove from VM internal data structures */
15741581
list_for_each_entry_safe(entry, tmp, &mem->attachments, list)
15751582
kfd_mem_detach(entry);
15761583

1584+
ret = unreserve_bo_and_vms(&ctx, false, false);
1585+
15771586
/* Free the sync object */
15781587
amdgpu_sync_free(&mem->sync);
15791588

@@ -1600,9 +1609,13 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
16001609
drm_vma_node_revoke(&mem->bo->tbo.base.vma_node, drm_priv);
16011610
if (mem->dmabuf)
16021611
dma_buf_put(mem->dmabuf);
1603-
drm_gem_object_put(&mem->bo->tbo.base);
16041612
mutex_destroy(&mem->lock);
1605-
kfree(mem);
1613+
1614+
/* If this releases the last reference, it will end up calling
1615+
* amdgpu_amdkfd_release_notify and kfree the mem struct. That's why
1616+
* this needs to be the last call here.
1617+
*/
1618+
drm_gem_object_put(&mem->bo->tbo.base);
16061619

16071620
return ret;
16081621
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,11 +3167,21 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
31673167
{
31683168
switch (asic_type) {
31693169
#if defined(CONFIG_DRM_AMD_DC)
3170-
#if defined(CONFIG_DRM_AMD_DC_SI)
31713170
case CHIP_TAHITI:
31723171
case CHIP_PITCAIRN:
31733172
case CHIP_VERDE:
31743173
case CHIP_OLAND:
3174+
/*
3175+
* We have systems in the wild with these ASICs that require
3176+
* LVDS and VGA support which is not supported with DC.
3177+
*
3178+
* Fallback to the non-DC driver here by default so as not to
3179+
* cause regressions.
3180+
*/
3181+
#if defined(CONFIG_DRM_AMD_DC_SI)
3182+
return amdgpu_dc > 0;
3183+
#else
3184+
return false;
31753185
#endif
31763186
case CHIP_BONAIRE:
31773187
case CHIP_KAVERI:
@@ -4283,8 +4293,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
42834293
if (r)
42844294
return r;
42854295

4286-
amdgpu_amdkfd_pre_reset(adev);
4287-
42884296
/* Resume IP prior to SMC */
42894297
r = amdgpu_device_ip_reinit_early_sriov(adev);
42904298
if (r)
@@ -5020,8 +5028,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
50205028

50215029
cancel_delayed_work_sync(&tmp_adev->delayed_init_work);
50225030

5023-
if (!amdgpu_sriov_vf(tmp_adev))
5024-
amdgpu_amdkfd_pre_reset(tmp_adev);
5031+
amdgpu_amdkfd_pre_reset(tmp_adev);
50255032

50265033
/*
50275034
* Mark these ASICs to be reseted as untracked first

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
867867
case IP_VERSION(2, 0, 2):
868868
case IP_VERSION(2, 2, 0):
869869
amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
870-
amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
870+
if (!amdgpu_sriov_vf(adev))
871+
amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
871872
break;
872873
case IP_VERSION(2, 0, 3):
873874
break;
@@ -881,6 +882,7 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
881882
break;
882883
case IP_VERSION(3, 0, 0):
883884
case IP_VERSION(3, 0, 16):
885+
case IP_VERSION(3, 0, 64):
884886
case IP_VERSION(3, 1, 1):
885887
case IP_VERSION(3, 0, 2):
886888
amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo)
12741274
abo = ttm_to_amdgpu_bo(bo);
12751275

12761276
if (abo->kfd_bo)
1277-
amdgpu_amdkfd_unreserve_memory_limit(abo);
1277+
amdgpu_amdkfd_release_notify(abo);
12781278

12791279
/* We only remove the fence if the resv has individualized. */
12801280
WARN_ON_ONCE(bo->type == ttm_bo_type_kernel

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
134134
adev->vcn.indirect_sram = true;
135135
break;
136136
case IP_VERSION(3, 0, 0):
137+
case IP_VERSION(3, 0, 64):
137138
if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 0))
138139
fw_name = FIRMWARE_SIENNA_CICHLID;
139140
else

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,9 @@ static void amdgpu_xgmi_reset_ras_error_count(struct amdgpu_device *adev)
806806
for (i = 0; i < ARRAY_SIZE(xgmi23_pcs_err_status_reg_aldebaran); i++)
807807
pcs_clear_status(adev,
808808
xgmi23_pcs_err_status_reg_aldebaran[i]);
809-
for (i = 0; i < ARRAY_SIZE(xgmi23_pcs_err_status_reg_aldebaran); i++)
809+
for (i = 0; i < ARRAY_SIZE(xgmi3x16_pcs_err_status_reg_aldebaran); i++)
810810
pcs_clear_status(adev,
811-
xgmi23_pcs_err_status_reg_aldebaran[i]);
811+
xgmi3x16_pcs_err_status_reg_aldebaran[i]);
812812
for (i = 0; i < ARRAY_SIZE(walf_pcs_err_status_reg_aldebaran); i++)
813813
pcs_clear_status(adev,
814814
walf_pcs_err_status_reg_aldebaran[i]);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8249,6 +8249,9 @@ static int gfx_v10_0_update_gfx_clock_gating(struct amdgpu_device *adev,
82498249
static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
82508250
{
82518251
u32 reg, data;
8252+
8253+
amdgpu_gfx_off_ctrl(adev, false);
8254+
82528255
/* not for *_SOC15 */
82538256
reg = SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_MC_CNTL);
82548257
if (amdgpu_sriov_is_pp_one_vf(adev))
@@ -8263,6 +8266,8 @@ static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
82638266
WREG32_SOC15_NO_KIQ(GC, 0, mmRLC_SPM_MC_CNTL, data);
82648267
else
82658268
WREG32_SOC15(GC, 0, mmRLC_SPM_MC_CNTL, data);
8269+
8270+
amdgpu_gfx_off_ctrl(adev, true);
82668271
}
82678272

82688273
static bool gfx_v10_0_check_rlcg_range(struct amdgpu_device *adev,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,12 +3575,16 @@ static void gfx_v7_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
35753575
{
35763576
u32 data;
35773577

3578+
amdgpu_gfx_off_ctrl(adev, false);
3579+
35783580
data = RREG32(mmRLC_SPM_VMID);
35793581

35803582
data &= ~RLC_SPM_VMID__RLC_SPM_VMID_MASK;
35813583
data |= (vmid & RLC_SPM_VMID__RLC_SPM_VMID_MASK) << RLC_SPM_VMID__RLC_SPM_VMID__SHIFT;
35823584

35833585
WREG32(mmRLC_SPM_VMID, data);
3586+
3587+
amdgpu_gfx_off_ctrl(adev, true);
35843588
}
35853589

35863590
static void gfx_v7_0_enable_cgcg(struct amdgpu_device *adev, bool enable)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,6 +5624,8 @@ static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
56245624
{
56255625
u32 data;
56265626

5627+
amdgpu_gfx_off_ctrl(adev, false);
5628+
56275629
if (amdgpu_sriov_is_pp_one_vf(adev))
56285630
data = RREG32_NO_KIQ(mmRLC_SPM_VMID);
56295631
else
@@ -5636,6 +5638,8 @@ static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
56365638
WREG32_NO_KIQ(mmRLC_SPM_VMID, data);
56375639
else
56385640
WREG32(mmRLC_SPM_VMID, data);
5641+
5642+
amdgpu_gfx_off_ctrl(adev, true);
56395643
}
56405644

56415645
static const struct amdgpu_rlc_funcs iceland_rlc_funcs = {

0 commit comments

Comments
 (0)