In C90 (which the kernel uses with -std=gnu89), declarations must appear at the beginning of a block and cannot follow a label. The switch cases in amdgpu_discovery.c and gmc_v12_1.c contained variable declarations immediately after case labels, causing the compiler to error:
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:560:3: error: a label can only be part of a statement and a declaration is not a statement drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c:533:3: error: a label can only be part of a statement and a declaration is not a statement Signed-off-by: Jesse Zhang <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 15 ++++++++++----- drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index f77a03ea4d90..f3d0640d800e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -548,6 +548,11 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, struct table_info *info; bool check_table = true; char *table_name; + struct ip_discovery_header *ihdr; + struct gpu_info_header *ghdr; + struct harvest_info_header *hhdr; + struct vcn_info_header *vhdr; + struct mall_info_header *mhdr; r = amdgpu_discovery_get_table_info(adev, &info, table_id); if (r) @@ -557,7 +562,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, switch (table_id) { case IP_DISCOVERY: - struct ip_discovery_header *ihdr = + ihdr = (struct ip_discovery_header *)(discovery_bin + offset); act_val = le32_to_cpu(ihdr->signature); exp_val = DISCOVERY_TABLE_SIGNATURE; @@ -565,7 +570,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, table_name = "data table"; break; case GC: - struct gpu_info_header *ghdr = + ghdr = (struct gpu_info_header *)(discovery_bin + offset); act_val = le32_to_cpu(ghdr->table_id); exp_val = GC_TABLE_ID; @@ -573,7 +578,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, table_name = "gc table"; break; case HARVEST_INFO: - struct harvest_info_header *hhdr = + hhdr = (struct harvest_info_header *)(discovery_bin + offset); act_val = le32_to_cpu(hhdr->signature); exp_val = HARVEST_TABLE_SIGNATURE; @@ -581,7 +586,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, table_name = "harvest table"; break; case VCN_INFO: - struct vcn_info_header *vhdr = + vhdr = (struct vcn_info_header *)(discovery_bin + offset); act_val = le32_to_cpu(vhdr->table_id); exp_val = VCN_INFO_TABLE_ID; @@ -589,7 +594,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, table_name = "vcn table"; break; case MALL_INFO: - struct mall_info_header *mhdr = + mhdr = (struct mall_info_header *)(discovery_bin + offset); act_val = le32_to_cpu(mhdr->table_id); exp_val = MALL_INFO_TABLE_ID; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c index 38c366b9a88b..7ea7b9c30bca 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c @@ -527,10 +527,11 @@ static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev, unsigned int mtype, mtype_local, mtype_remote; bool snoop = false; bool is_local = false; + bool is_aid_a1; switch (gc_ip_version) { case IP_VERSION(12, 1, 0): - bool is_aid_a1 = (adev->rev_id & 0x10); + is_aid_a1 = (adev->rev_id & 0x10); mtype_local = is_aid_a1 ? MTYPE_RW : MTYPE_NC; mtype_remote = is_aid_a1 ? MTYPE_NC : MTYPE_UC; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index 8167fe642341..9b4143328371 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1220,6 +1220,7 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm, bool coherent = flags & (KFD_IOCTL_SVM_FLAG_COHERENT | KFD_IOCTL_SVM_FLAG_EXT_COHERENT); bool ext_coherent = flags & KFD_IOCTL_SVM_FLAG_EXT_COHERENT; unsigned int mtype_local, mtype_remote; + bool is_aid_a1, is_local; if (domain == SVM_RANGE_VRAM_DOMAIN) bo_node = prange->svm_bo->node; @@ -1307,8 +1308,8 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm, mapping_flags |= AMDGPU_VM_MTYPE_NC; break; case IP_VERSION(12, 1, 0): - bool is_aid_a1 = (node->adev->rev_id & 0x10); - bool is_local = (domain == SVM_RANGE_VRAM_DOMAIN) && + is_aid_a1 = (node->adev->rev_id & 0x10); + is_local = (domain == SVM_RANGE_VRAM_DOMAIN) && (bo_node->adev == node->adev); mtype_local = amdgpu_mtype_local == 0 ? AMDGPU_VM_MTYPE_RW : -- 2.49.0
