Skip to content

Commit 7bd939d

Browse files
Likun GAOalexdeucher
authored andcommitted
drm/amdgpu: add judgement when add ip blocks (v2)
Judgement whether to add an sw ip according to the harvest info. v2: fix indentation (Alex) Signed-off-by: Likun Gao <[email protected]> Reviewed-by: Guchun Chen <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 1acbb61 commit 7bd939d

File tree

6 files changed

+57
-2
lines changed

6 files changed

+57
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ struct amdgpu_device {
10061006
struct amdgpu_df df;
10071007

10081008
struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM];
1009+
uint32_t harvest_ip_mask;
10091010
int num_ip_blocks;
10101011
struct mutex mn_lock;
10111012
DECLARE_HASHTABLE(mn_hash, 7);

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,19 @@ int amdgpu_device_ip_block_add(struct amdgpu_device *adev,
16831683
if (!ip_block_version)
16841684
return -EINVAL;
16851685

1686+
switch (ip_block_version->type) {
1687+
case AMD_IP_BLOCK_TYPE_VCN:
1688+
if (adev->harvest_ip_mask & AMD_HARVEST_IP_VCN_MASK)
1689+
return 0;
1690+
break;
1691+
case AMD_IP_BLOCK_TYPE_JPEG:
1692+
if (adev->harvest_ip_mask & AMD_HARVEST_IP_JPEG_MASK)
1693+
return 0;
1694+
break;
1695+
default:
1696+
break;
1697+
}
1698+
16861699
DRM_INFO("add ip block number %d <%s>\n", adev->num_ip_blocks,
16871700
ip_block_version->funcs->name);
16881701

@@ -3111,7 +3124,6 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)
31113124
return amdgpu_device_asic_has_dc_support(adev->asic_type);
31123125
}
31133126

3114-
31153127
static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
31163128
{
31173129
struct amdgpu_device *adev =
@@ -3274,6 +3286,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
32743286
adev->vm_manager.vm_pte_funcs = NULL;
32753287
adev->vm_manager.vm_pte_num_scheds = 0;
32763288
adev->gmc.gmc_funcs = NULL;
3289+
adev->harvest_ip_mask = 0x0;
32773290
adev->fence_context = dma_fence_context_alloc(AMDGPU_MAX_RINGS);
32783291
bitmap_zero(adev->gfx.pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
32793292

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,34 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
373373
return -EINVAL;
374374
}
375375

376+
void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
377+
{
378+
struct binary_header *bhdr;
379+
struct harvest_table *harvest_info;
380+
int i;
381+
382+
bhdr = (struct binary_header *)adev->mman.discovery_bin;
383+
harvest_info = (struct harvest_table *)(adev->mman.discovery_bin +
384+
le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));
385+
386+
for (i = 0; i < 32; i++) {
387+
if (le32_to_cpu(harvest_info->list[i].hw_id) == 0)
388+
break;
389+
390+
switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
391+
case VCN_HWID:
392+
adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
393+
adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
394+
break;
395+
case DMU_HWID:
396+
adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
397+
break;
398+
default:
399+
break;
400+
}
401+
}
402+
}
403+
376404
int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
377405
{
378406
struct binary_header *bhdr;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
void amdgpu_discovery_fini(struct amdgpu_device *adev);
3131
int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
32+
void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev);
3233
int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
3334
int *major, int *minor, int *revision);
3435
int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ static int nv_reg_base_init(struct amdgpu_device *adev)
635635
goto legacy_init;
636636
}
637637

638+
amdgpu_discovery_harvest_ip(adev);
639+
638640
return 0;
639641
}
640642

@@ -777,7 +779,6 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
777779
amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
778780
if (!amdgpu_sriov_vf(adev))
779781
amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
780-
781782
if (adev->enable_mes)
782783
amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
783784
break;
@@ -1154,6 +1155,11 @@ static int nv_common_early_init(void *handle)
11541155
return -EINVAL;
11551156
}
11561157

1158+
if (adev->harvest_ip_mask & AMD_HARVEST_IP_VCN_MASK)
1159+
adev->pg_flags &= ~(AMD_PG_SUPPORT_VCN |
1160+
AMD_PG_SUPPORT_VCN_DPG |
1161+
AMD_PG_SUPPORT_JPEG);
1162+
11571163
if (amdgpu_sriov_vf(adev)) {
11581164
amdgpu_virt_init_setting(adev);
11591165
xgpu_nv_mailbox_set_irq_funcs(adev);

drivers/gpu/drm/amd/include/amd_shared.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ enum PP_FEATURE_MASK {
216216
PP_GFX_DCS_MASK = 0x80000,
217217
};
218218

219+
enum amd_harvest_ip_mask {
220+
AMD_HARVEST_IP_VCN_MASK = 0x1,
221+
AMD_HARVEST_IP_JPEG_MASK = 0x2,
222+
AMD_HARVEST_IP_DMU_MASK = 0x4,
223+
};
224+
219225
enum DC_FEATURE_MASK {
220226
DC_FBC_MASK = 0x1,
221227
DC_MULTI_MON_PP_MCLK_SWITCH_MASK = 0x2,

0 commit comments

Comments
 (0)