Skip to content

Commit fe8f5b2

Browse files
committed
Merge tag 'amd-drm-fixes-6.2-2022-12-21' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-fixes-6.2-2022-12-21: amdgpu: - Avoid large variable on the stack - S0ix fixes - SMU 13.x fixes - VCN fix - Add missing fence reference amdkfd: - Fix init vm error handling - Fix double release of compute pasid Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 38624d2 + c1c4a8b commit fe8f5b2

File tree

12 files changed

+102
-36
lines changed

12 files changed

+102
-36
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,10 @@ int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct amdgpu_device *adev, bool is_
270270
(&((struct amdgpu_fpriv *) \
271271
((struct drm_file *)(drm_priv))->driver_priv)->vm)
272272

273+
int amdgpu_amdkfd_gpuvm_set_vm_pasid(struct amdgpu_device *adev,
274+
struct file *filp, u32 pasid);
273275
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
274-
struct file *filp, u32 pasid,
276+
struct file *filp,
275277
void **process_info,
276278
struct dma_fence **ef);
277279
void amdgpu_amdkfd_gpuvm_release_process_vm(struct amdgpu_device *adev,

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,10 +1429,9 @@ static void amdgpu_amdkfd_gpuvm_unpin_bo(struct amdgpu_bo *bo)
14291429
amdgpu_bo_unreserve(bo);
14301430
}
14311431

1432-
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
1433-
struct file *filp, u32 pasid,
1434-
void **process_info,
1435-
struct dma_fence **ef)
1432+
int amdgpu_amdkfd_gpuvm_set_vm_pasid(struct amdgpu_device *adev,
1433+
struct file *filp, u32 pasid)
1434+
14361435
{
14371436
struct amdgpu_fpriv *drv_priv;
14381437
struct amdgpu_vm *avm;
@@ -1443,10 +1442,6 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
14431442
return ret;
14441443
avm = &drv_priv->vm;
14451444

1446-
/* Already a compute VM? */
1447-
if (avm->process_info)
1448-
return -EINVAL;
1449-
14501445
/* Free the original amdgpu allocated pasid,
14511446
* will be replaced with kfd allocated pasid.
14521447
*/
@@ -1455,14 +1450,36 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
14551450
amdgpu_vm_set_pasid(adev, avm, 0);
14561451
}
14571452

1458-
/* Convert VM into a compute VM */
1459-
ret = amdgpu_vm_make_compute(adev, avm);
1453+
ret = amdgpu_vm_set_pasid(adev, avm, pasid);
14601454
if (ret)
14611455
return ret;
14621456

1463-
ret = amdgpu_vm_set_pasid(adev, avm, pasid);
1457+
return 0;
1458+
}
1459+
1460+
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
1461+
struct file *filp,
1462+
void **process_info,
1463+
struct dma_fence **ef)
1464+
{
1465+
struct amdgpu_fpriv *drv_priv;
1466+
struct amdgpu_vm *avm;
1467+
int ret;
1468+
1469+
ret = amdgpu_file_to_fpriv(filp, &drv_priv);
14641470
if (ret)
14651471
return ret;
1472+
avm = &drv_priv->vm;
1473+
1474+
/* Already a compute VM? */
1475+
if (avm->process_info)
1476+
return -EINVAL;
1477+
1478+
/* Convert VM into a compute VM */
1479+
ret = amdgpu_vm_make_compute(adev, avm);
1480+
if (ret)
1481+
return ret;
1482+
14661483
/* Initialize KFD part of the VM and process info */
14671484
ret = init_kfd_vm(avm, process_info, ef);
14681485
if (ret)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,14 +3016,15 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
30163016
continue;
30173017
}
30183018

3019-
/* skip suspend of gfx and psp for S0ix
3019+
/* skip suspend of gfx/mes and psp for S0ix
30203020
* gfx is in gfxoff state, so on resume it will exit gfxoff just
30213021
* like at runtime. PSP is also part of the always on hardware
30223022
* so no need to suspend it.
30233023
*/
30243024
if (adev->in_s0ix &&
30253025
(adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP ||
3026-
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GFX))
3026+
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GFX ||
3027+
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_MES))
30273028
continue;
30283029

30293030
/* XXX handle errors */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
238238
/* Wait for PD/PT moves to be completed */
239239
dma_resv_iter_begin(&cursor, bo->tbo.base.resv, DMA_RESV_USAGE_KERNEL);
240240
dma_resv_for_each_fence_unlocked(&cursor, fence) {
241+
dma_fence_get(fence);
241242
r = drm_sched_job_add_dependency(&p->job->base, fence);
242243
if (r) {
244+
dma_fence_put(fence);
243245
dma_resv_iter_end(&cursor);
244246
return r;
245247
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,8 @@ static int mes_v11_0_late_init(void *handle)
13421342
{
13431343
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
13441344

1345-
if (!amdgpu_in_reset(adev) &&
1345+
/* it's only intended for use in mes_self_test case, not for s0ix and reset */
1346+
if (!amdgpu_in_reset(adev) && !adev->in_s0ix &&
13461347
(adev->ip_versions[GC_HWIP][0] != IP_VERSION(11, 0, 3)))
13471348
amdgpu_mes_self_test(adev);
13481349

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ static int soc21_common_early_init(void *handle)
666666
AMD_CG_SUPPORT_VCN_MGCG |
667667
AMD_CG_SUPPORT_JPEG_MGCG;
668668
adev->pg_flags = AMD_PG_SUPPORT_VCN |
669+
AMD_PG_SUPPORT_VCN_DPG |
669670
AMD_PG_SUPPORT_GFX_PG |
670671
AMD_PG_SUPPORT_JPEG;
671672
adev->external_rev_id = adev->rev_id + 0x1;

drivers/gpu/drm/amd/amdkfd/kfd_process.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,13 +689,13 @@ void kfd_process_destroy_wq(void)
689689
}
690690

691691
static void kfd_process_free_gpuvm(struct kgd_mem *mem,
692-
struct kfd_process_device *pdd, void *kptr)
692+
struct kfd_process_device *pdd, void **kptr)
693693
{
694694
struct kfd_dev *dev = pdd->dev;
695695

696-
if (kptr) {
696+
if (kptr && *kptr) {
697697
amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(mem);
698-
kptr = NULL;
698+
*kptr = NULL;
699699
}
700700

701701
amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->adev, mem, pdd->drm_priv);
@@ -795,7 +795,7 @@ static void kfd_process_device_destroy_ib_mem(struct kfd_process_device *pdd)
795795
if (!qpd->ib_kaddr || !qpd->ib_base)
796796
return;
797797

798-
kfd_process_free_gpuvm(qpd->ib_mem, pdd, qpd->ib_kaddr);
798+
kfd_process_free_gpuvm(qpd->ib_mem, pdd, &qpd->ib_kaddr);
799799
}
800800

801801
struct kfd_process *kfd_create_process(struct file *filep)
@@ -1277,7 +1277,7 @@ static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd)
12771277
if (!dev->cwsr_enabled || !qpd->cwsr_kaddr || !qpd->cwsr_base)
12781278
return;
12791279

1280-
kfd_process_free_gpuvm(qpd->cwsr_mem, pdd, qpd->cwsr_kaddr);
1280+
kfd_process_free_gpuvm(qpd->cwsr_mem, pdd, &qpd->cwsr_kaddr);
12811281
}
12821282

12831283
void kfd_process_set_trap_handler(struct qcm_process_device *qpd,
@@ -1576,9 +1576,9 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
15761576
p = pdd->process;
15771577
dev = pdd->dev;
15781578

1579-
ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(
1580-
dev->adev, drm_file, p->pasid,
1581-
&p->kgd_process_info, &p->ef);
1579+
ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(dev->adev, drm_file,
1580+
&p->kgd_process_info,
1581+
&p->ef);
15821582
if (ret) {
15831583
pr_err("Failed to create process VM object\n");
15841584
return ret;
@@ -1593,13 +1593,19 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
15931593
if (ret)
15941594
goto err_init_cwsr;
15951595

1596+
ret = amdgpu_amdkfd_gpuvm_set_vm_pasid(dev->adev, drm_file, p->pasid);
1597+
if (ret)
1598+
goto err_set_pasid;
1599+
15961600
pdd->drm_file = drm_file;
15971601

15981602
return 0;
15991603

1604+
err_set_pasid:
1605+
kfd_process_device_destroy_cwsr_dgpu(pdd);
16001606
err_init_cwsr:
1607+
kfd_process_device_destroy_ib_mem(pdd);
16011608
err_reserve_ib_mem:
1602-
kfd_process_device_free_bos(pdd);
16031609
pdd->drm_priv = NULL;
16041610

16051611
return ret;

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ typedef enum {
522522
TEMP_HOTSPOT_M,
523523
TEMP_MEM,
524524
TEMP_VR_GFX,
525+
TEMP_VR_SOC,
525526
TEMP_VR_MEM0,
526527
TEMP_VR_MEM1,
527-
TEMP_VR_SOC,
528528
TEMP_VR_U,
529529
TEMP_LIQUID0,
530530
TEMP_LIQUID1,

drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define SMU13_DRIVER_IF_VERSION_INV 0xFFFFFFFF
2929
#define SMU13_DRIVER_IF_VERSION_YELLOW_CARP 0x04
3030
#define SMU13_DRIVER_IF_VERSION_ALDE 0x08
31+
#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_0_0 0x34
3132
#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_4 0x07
3233
#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_5 0x04
3334
#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_0_10 0x32

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ int smu_v13_0_check_fw_version(struct smu_context *smu)
290290
smu->smc_driver_if_version = SMU13_DRIVER_IF_VERSION_ALDE;
291291
break;
292292
case IP_VERSION(13, 0, 0):
293+
smu->smc_driver_if_version = SMU13_DRIVER_IF_VERSION_SMU_V13_0_0_0;
294+
break;
293295
case IP_VERSION(13, 0, 10):
294296
smu->smc_driver_if_version = SMU13_DRIVER_IF_VERSION_SMU_V13_0_0_10;
295297
break;

0 commit comments

Comments
 (0)