Skip to content

Commit 01541a8

Browse files
committed
Merge tag 'amd-drm-fixes-6.12-2024-10-16' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
amd-drm-fixes-6.12-2024-10-16: amdgpu: - SR-IOV fix - CS chunk handling fix - MES fixes - SMU13 fixes amdkfd: - VRAM usage reporting fix radeon: - Fix possible_clones handling Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 4cd33d9 + ec1aab7 commit 01541a8

File tree

11 files changed

+61
-35
lines changed

11 files changed

+61
-35
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
265265

266266
/* Only a single BO list is allowed to simplify handling. */
267267
if (p->bo_list)
268-
ret = -EINVAL;
268+
goto free_partial_kdata;
269269

270270
ret = amdgpu_cs_p1_bo_handles(p, p->chunks[i].kdata);
271271
if (ret)

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,11 +1635,9 @@ int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
16351635
{
16361636
int r;
16371637

1638-
if (!amdgpu_sriov_vf(adev)) {
1639-
r = device_create_file(adev->dev, &dev_attr_enforce_isolation);
1640-
if (r)
1641-
return r;
1642-
}
1638+
r = device_create_file(adev->dev, &dev_attr_enforce_isolation);
1639+
if (r)
1640+
return r;
16431641

16441642
r = device_create_file(adev->dev, &dev_attr_run_cleaner_shader);
16451643
if (r)
@@ -1650,8 +1648,7 @@ int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
16501648

16511649
void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev)
16521650
{
1653-
if (!amdgpu_sriov_vf(adev))
1654-
device_remove_file(adev->dev, &dev_attr_enforce_isolation);
1651+
device_remove_file(adev->dev, &dev_attr_enforce_isolation);
16551652
device_remove_file(adev->dev, &dev_attr_run_cleaner_shader);
16561653
}
16571654

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,10 @@ int amdgpu_mes_add_ring(struct amdgpu_device *adev, int gang_id,
12031203

12041204
r = amdgpu_ring_init(adev, ring, 1024, NULL, 0,
12051205
AMDGPU_RING_PRIO_DEFAULT, NULL);
1206-
if (r)
1206+
if (r) {
1207+
amdgpu_mes_unlock(&adev->mes);
12071208
goto clean_up_memory;
1209+
}
12081210

12091211
amdgpu_mes_ring_to_queue_props(adev, ring, &qprops);
12101212

@@ -1237,7 +1239,6 @@ int amdgpu_mes_add_ring(struct amdgpu_device *adev, int gang_id,
12371239
amdgpu_ring_fini(ring);
12381240
clean_up_memory:
12391241
kfree(ring);
1240-
amdgpu_mes_unlock(&adev->mes);
12411242
return r;
12421243
}
12431244

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ static int mes_v12_0_set_hw_resources(struct amdgpu_mes *mes, int pipe)
621621

622622
if (amdgpu_mes_log_enable) {
623623
mes_set_hw_res_pkt.enable_mes_event_int_logging = 1;
624-
mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr;
624+
mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr + pipe * AMDGPU_MES_LOG_BUFFER_SIZE;
625625
}
626626

627627
return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe,
@@ -1336,7 +1336,7 @@ static int mes_v12_0_sw_init(void *handle)
13361336
adev->mes.kiq_hw_fini = &mes_v12_0_kiq_hw_fini;
13371337
adev->mes.enable_legacy_queue_map = true;
13381338

1339-
adev->mes.event_log_size = AMDGPU_MES_LOG_BUFFER_SIZE;
1339+
adev->mes.event_log_size = adev->enable_uni_mes ? (AMDGPU_MAX_MES_PIPES * AMDGPU_MES_LOG_BUFFER_SIZE) : AMDGPU_MES_LOG_BUFFER_SIZE;
13401340

13411341
r = amdgpu_mes_init(adev);
13421342
if (r)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
11481148

11491149
if (flags & KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM)
11501150
size >>= 1;
1151-
WRITE_ONCE(pdd->vram_usage, pdd->vram_usage + PAGE_ALIGN(size));
1151+
atomic64_add(PAGE_ALIGN(size), &pdd->vram_usage);
11521152
}
11531153

11541154
mutex_unlock(&p->mutex);
@@ -1219,7 +1219,7 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
12191219
kfd_process_device_remove_obj_handle(
12201220
pdd, GET_IDR_HANDLE(args->handle));
12211221

1222-
WRITE_ONCE(pdd->vram_usage, pdd->vram_usage - size);
1222+
atomic64_sub(size, &pdd->vram_usage);
12231223

12241224
err_unlock:
12251225
err_pdd:
@@ -2347,7 +2347,7 @@ static int criu_restore_memory_of_gpu(struct kfd_process_device *pdd,
23472347
} else if (bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
23482348
bo_bucket->restored_offset = offset;
23492349
/* Update the VRAM usage count */
2350-
WRITE_ONCE(pdd->vram_usage, pdd->vram_usage + bo_bucket->size);
2350+
atomic64_add(bo_bucket->size, &pdd->vram_usage);
23512351
}
23522352
return 0;
23532353
}

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ struct kfd_process_device {
775775
enum kfd_pdd_bound bound;
776776

777777
/* VRAM usage */
778-
uint64_t vram_usage;
778+
atomic64_t vram_usage;
779779
struct attribute attr_vram;
780780
char vram_filename[MAX_SYSFS_FILENAME_LEN];
781781

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static ssize_t kfd_procfs_show(struct kobject *kobj, struct attribute *attr,
332332
} else if (strncmp(attr->name, "vram_", 5) == 0) {
333333
struct kfd_process_device *pdd = container_of(attr, struct kfd_process_device,
334334
attr_vram);
335-
return snprintf(buffer, PAGE_SIZE, "%llu\n", READ_ONCE(pdd->vram_usage));
335+
return snprintf(buffer, PAGE_SIZE, "%llu\n", atomic64_read(&pdd->vram_usage));
336336
} else if (strncmp(attr->name, "sdma_", 5) == 0) {
337337
struct kfd_process_device *pdd = container_of(attr, struct kfd_process_device,
338338
attr_sdma);
@@ -1625,7 +1625,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_node *dev,
16251625
pdd->bound = PDD_UNBOUND;
16261626
pdd->already_dequeued = false;
16271627
pdd->runtime_inuse = false;
1628-
pdd->vram_usage = 0;
1628+
atomic64_set(&pdd->vram_usage, 0);
16291629
pdd->sdma_past_activity_counter = 0;
16301630
pdd->user_gpu_id = dev->id;
16311631
atomic64_set(&pdd->evict_duration_counter, 0);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,27 @@ static void svm_range_bo_release(struct kref *kref)
405405
spin_lock(&svm_bo->list_lock);
406406
}
407407
spin_unlock(&svm_bo->list_lock);
408+
409+
if (mmget_not_zero(svm_bo->eviction_fence->mm)) {
410+
struct kfd_process_device *pdd;
411+
struct kfd_process *p;
412+
struct mm_struct *mm;
413+
414+
mm = svm_bo->eviction_fence->mm;
415+
/*
416+
* The forked child process takes svm_bo device pages ref, svm_bo could be
417+
* released after parent process is gone.
418+
*/
419+
p = kfd_lookup_process_by_mm(mm);
420+
if (p) {
421+
pdd = kfd_get_process_device_data(svm_bo->node, p);
422+
if (pdd)
423+
atomic64_sub(amdgpu_bo_size(svm_bo->bo), &pdd->vram_usage);
424+
kfd_unref_process(p);
425+
}
426+
mmput(mm);
427+
}
428+
408429
if (!dma_fence_is_signaled(&svm_bo->eviction_fence->base))
409430
/* We're not in the eviction worker. Signal the fence. */
410431
dma_fence_signal(&svm_bo->eviction_fence->base);
@@ -532,6 +553,7 @@ int
532553
svm_range_vram_node_new(struct kfd_node *node, struct svm_range *prange,
533554
bool clear)
534555
{
556+
struct kfd_process_device *pdd;
535557
struct amdgpu_bo_param bp;
536558
struct svm_range_bo *svm_bo;
537559
struct amdgpu_bo_user *ubo;
@@ -623,6 +645,10 @@ svm_range_vram_node_new(struct kfd_node *node, struct svm_range *prange,
623645
list_add(&prange->svm_bo_list, &svm_bo->range_list);
624646
spin_unlock(&svm_bo->list_lock);
625647

648+
pdd = svm_range_get_pdd_by_node(prange, node);
649+
if (pdd)
650+
atomic64_add(amdgpu_bo_size(bo), &pdd->vram_usage);
651+
626652
return 0;
627653

628654
reserve_bo_failed:

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,11 @@ static int smu_sw_init(void *handle)
12641264
smu->workload_prority[PP_SMC_POWER_PROFILE_VR] = 4;
12651265
smu->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE] = 5;
12661266
smu->workload_prority[PP_SMC_POWER_PROFILE_CUSTOM] = 6;
1267-
smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
1267+
1268+
if (smu->is_apu)
1269+
smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
1270+
else
1271+
smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D];
12681272

12691273
smu->workload_setting[0] = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
12701274
smu->workload_setting[1] = PP_SMC_POWER_PROFILE_FULLSCREEN3D;
@@ -2226,7 +2230,7 @@ static int smu_bump_power_profile_mode(struct smu_context *smu,
22262230
static int smu_adjust_power_state_dynamic(struct smu_context *smu,
22272231
enum amd_dpm_forced_level level,
22282232
bool skip_display_settings,
2229-
bool force_update)
2233+
bool init)
22302234
{
22312235
int ret = 0;
22322236
int index = 0;
@@ -2255,7 +2259,7 @@ static int smu_adjust_power_state_dynamic(struct smu_context *smu,
22552259
}
22562260
}
22572261

2258-
if (force_update || smu_dpm_ctx->dpm_level != level) {
2262+
if (smu_dpm_ctx->dpm_level != level) {
22592263
ret = smu_asic_set_performance_level(smu, level);
22602264
if (ret) {
22612265
dev_err(smu->adev->dev, "Failed to set performance level!");
@@ -2272,7 +2276,7 @@ static int smu_adjust_power_state_dynamic(struct smu_context *smu,
22722276
index = index > 0 && index <= WORKLOAD_POLICY_MAX ? index - 1 : 0;
22732277
workload[0] = smu->workload_setting[index];
22742278

2275-
if (force_update || smu->power_profile_mode != workload[0])
2279+
if (init || smu->power_profile_mode != workload[0])
22762280
smu_bump_power_profile_mode(smu, workload, 0);
22772281
}
22782282

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,18 +2555,16 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu,
25552555
workload_mask = 1 << workload_type;
25562556

25572557
/* Add optimizations for SMU13.0.0/10. Reuse the power saving profile */
2558-
if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_COMPUTE) {
2559-
if ((amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 0) &&
2560-
((smu->adev->pm.fw_version == 0x004e6601) ||
2561-
(smu->adev->pm.fw_version >= 0x004e7300))) ||
2562-
(amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 10) &&
2563-
smu->adev->pm.fw_version >= 0x00504500)) {
2564-
workload_type = smu_cmn_to_asic_specific_index(smu,
2565-
CMN2ASIC_MAPPING_WORKLOAD,
2566-
PP_SMC_POWER_PROFILE_POWERSAVING);
2567-
if (workload_type >= 0)
2568-
workload_mask |= 1 << workload_type;
2569-
}
2558+
if ((amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 0) &&
2559+
((smu->adev->pm.fw_version == 0x004e6601) ||
2560+
(smu->adev->pm.fw_version >= 0x004e7300))) ||
2561+
(amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 10) &&
2562+
smu->adev->pm.fw_version >= 0x00504500)) {
2563+
workload_type = smu_cmn_to_asic_specific_index(smu,
2564+
CMN2ASIC_MAPPING_WORKLOAD,
2565+
PP_SMC_POWER_PROFILE_POWERSAVING);
2566+
if (workload_type >= 0)
2567+
workload_mask |= 1 << workload_type;
25702568
}
25712569

25722570
ret = smu_cmn_send_smc_msg_with_param(smu,

0 commit comments

Comments
 (0)