]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/i915/power: fix size for for_each_set_bit() in abox iteration
authorJani Nikula <jani.nikula@intel.com>
Fri, 5 Sep 2025 10:41:49 +0000 (13:41 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Sep 2025 14:37:32 +0000 (16:37 +0200)
commit cfa7b7659757f8d0fc4914429efa90d0d2577dd7 upstream.

for_each_set_bit() expects size to be in bits, not bytes. The abox mask
iteration uses bytes, but it works by coincidence, because the local
variable holding the mask is unsigned long, and the mask only ever has
bit 2 as the highest bit. Using a smaller type could lead to subtle and
very hard to track bugs.

Fixes: 62afef2811e4 ("drm/i915/rkl: RKL uses ABOX0 for pixel transfers")
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org # v5.9+
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20250905104149.1144751-1-jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
(cherry picked from commit 7ea3baa6efe4bb93d11e1c0e6528b1468d7debf6)
Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/i915/display/intel_display_power.c

index 16356523816fb8438d88851ab2a19ccc1b7662ef..068ed911e12458a49ea84696a8cc38a0fbcb85f6 100644 (file)
@@ -1169,7 +1169,7 @@ static void icl_mbus_init(struct intel_display *display)
        if (DISPLAY_VER(display) == 12)
                abox_regs |= BIT(0);
 
-       for_each_set_bit(i, &abox_regs, sizeof(abox_regs))
+       for_each_set_bit(i, &abox_regs, BITS_PER_TYPE(abox_regs))
                intel_de_rmw(display, MBUS_ABOX_CTL(i), mask, val);
 }
 
@@ -1630,11 +1630,11 @@ static void tgl_bw_buddy_init(struct intel_display *display)
        if (table[config].page_mask == 0) {
                drm_dbg_kms(display->drm,
                            "Unknown memory configuration; disabling address buddy logic.\n");
-               for_each_set_bit(i, &abox_mask, sizeof(abox_mask))
+               for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask))
                        intel_de_write(display, BW_BUDDY_CTL(i),
                                       BW_BUDDY_DISABLE);
        } else {
-               for_each_set_bit(i, &abox_mask, sizeof(abox_mask)) {
+               for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask)) {
                        intel_de_write(display, BW_BUDDY_PAGE_MASK(i),
                                       table[config].page_mask);