]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/amdgpu: Fix build errors due to declarations after labels
authorJesse.Zhang <Jesse.Zhang@amd.com>
Mon, 16 Mar 2026 01:40:47 +0000 (09:40 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 14:42:47 +0000 (10:42 -0400)
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/gmc_v12_1.c:533:3: error: a label can only be
part of a statement and a declaration is not a statement

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jesse Zhang <jesse.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c

index 38c366b9a88bdac12e5d6263eeb20e5be9f22acf..7ea7b9c30bca965fc3e9886128ea0fe741518ac7 100644 (file)
@@ -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;
index 6e833e685dd0ba68bc5d3ff3c26ab1b71760bbfa..37fdcaf7192f14be5e5297c06e73ca05ba825c2c 100644 (file)
@@ -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 :