• Nathan Chancellor's avatar
    drm/i915/gt: Fix parameter in gmch_ggtt_insert_{entries, page}() · 1baeef6c
    Nathan Chancellor authored
    When building with clang's -Wincompatible-function-pointer-types-strict,
    the following warnings occur:
    
      drivers/gpu/drm/i915/gt/intel_ggtt_gmch.c:102:23: error: incompatible function pointer types assigning to 'void (*)(struct i915_address_space *, dma_addr_t, u64, unsigned int, u32)' (aka 'void (*)(struct i915_address_space *, unsigned int, unsigned long long, unsigned int, unsigned int)') from 'void (struct i915_address_space *, dma_addr_t, u64, enum i915_cache_level, u32)' (aka 'void (struct i915_address_space *, unsigned int, unsigned long long, enum i915_cache_level, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
              ggtt->vm.insert_page = gmch_ggtt_insert_page;
                                   ^ ~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/i915/gt/intel_ggtt_gmch.c:103:26: error: incompatible function pointer types assigning to 'void (*)(struct i915_address_space *, struct i915_vma_resource *, unsigned int, u32)' (aka 'void (*)(struct i915_address_space *, struct i915_vma_resource *, unsigned int, unsigned int)') from 'void (struct i915_address_space *, struct i915_vma_resource *, enum i915_cache_level, u32)' (aka 'void (struct i915_address_space *, struct i915_vma_resource *, enum i915_cache_level, unsigned int)') [-Werror, -Wincompatible-function-pointer-types-strict]
              ggtt->vm.insert_entries = gmch_ggtt_insert_entries;
                                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~
      2 errors generated.
    
    The warning is pointing out that while 'enum i915_cache_level' and
    'unsigned int' are ABI compatible, these indirect calls will fail
    clang's kernel Control Flow Integrity (kCFI) checks, as the callback's
    signature does not exactly match the prototype's signature.
    
    To fix this, replace the cache_level parameter with pat_index, as was
    done in other places within i915 where there is no difference between
    cache_level and pat_index on certain generations.
    
    Fixes: 9275277d ("drm/i915: use pat_index instead of cache_level")
    Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
    Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
    Reviewed-by: default avatarFei Yang <fei.yang@intel.com>
    Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230530-i915-gt-cache_level-wincompatible-function-pointer-types-strict-v1-2-54501d598229@kernel.org
    1baeef6c
intel_ggtt_gmch.c 3.05 KB