drm/i915/mtl: avoid stringop-overflow warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 16 Oct 2023 20:10:04 +0000 (22:10 +0200)
committerJani Nikula <jani.nikula@intel.com>
Thu, 26 Oct 2023 12:16:05 +0000 (15:16 +0300)
The newly added memset() causes a warning for some reason I could not
figure out:

In file included from arch/x86/include/asm/string.h:3,
                 from drivers/gpu/drm/i915/gt/intel_rc6.c:6:
In function 'rc6_res_reg_init',
    inlined from 'intel_rc6_init' at drivers/gpu/drm/i915/gt/intel_rc6.c:610:2:
arch/x86/include/asm/string_32.h:195:29: error: '__builtin_memset' writing 16 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
  195 | #define memset(s, c, count) __builtin_memset(s, c, count)
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gt/intel_rc6.c:584:9: note: in expansion of macro 'memset'
  584 |         memset(rc6->res_reg, INVALID_MMIO_REG.reg, sizeof(rc6->res_reg));
      |         ^~~~~~
In function 'intel_rc6_init':

Change it to an normal initializer and an added memcpy() that does not have
this problem.

Fixes: 4bb9ca7ee074 ("drm/i915/mtl: C6 residency and C state type for MTL SAMedia")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231016201012.1022812-1-arnd@kernel.org
drivers/gpu/drm/i915/gt/intel_rc6.c

index 8b67abd720be866282b1c8b3946786c31186fe0a..7090e4be29cb69bb6f2fdf459cf4062fc4a1ce3a 100644 (file)
@@ -581,19 +581,23 @@ static void __intel_rc6_disable(struct intel_rc6 *rc6)
 
 static void rc6_res_reg_init(struct intel_rc6 *rc6)
 {
-       memset(rc6->res_reg, INVALID_MMIO_REG.reg, sizeof(rc6->res_reg));
+       i915_reg_t res_reg[INTEL_RC6_RES_MAX] = {
+               [0 ... INTEL_RC6_RES_MAX - 1] = INVALID_MMIO_REG,
+       };
 
        switch (rc6_to_gt(rc6)->type) {
        case GT_MEDIA:
-               rc6->res_reg[INTEL_RC6_RES_RC6] = MTL_MEDIA_MC6;
+               res_reg[INTEL_RC6_RES_RC6] = MTL_MEDIA_MC6;
                break;
        default:
-               rc6->res_reg[INTEL_RC6_RES_RC6_LOCKED] = GEN6_GT_GFX_RC6_LOCKED;
-               rc6->res_reg[INTEL_RC6_RES_RC6] = GEN6_GT_GFX_RC6;
-               rc6->res_reg[INTEL_RC6_RES_RC6p] = GEN6_GT_GFX_RC6p;
-               rc6->res_reg[INTEL_RC6_RES_RC6pp] = GEN6_GT_GFX_RC6pp;
+               res_reg[INTEL_RC6_RES_RC6_LOCKED] = GEN6_GT_GFX_RC6_LOCKED;
+               res_reg[INTEL_RC6_RES_RC6] = GEN6_GT_GFX_RC6;
+               res_reg[INTEL_RC6_RES_RC6p] = GEN6_GT_GFX_RC6p;
+               res_reg[INTEL_RC6_RES_RC6pp] = GEN6_GT_GFX_RC6pp;
                break;
        }
+
+       memcpy(rc6->res_reg, res_reg, sizeof(res_reg));
 }
 
 void intel_rc6_init(struct intel_rc6 *rc6)