Skip to content

Commit 7ea3baa

Browse files
committed
drm/i915/power: fix size for for_each_set_bit() in abox iteration
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: 62afef2 ("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>
1 parent 90d8aad commit 7ea3baa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/i915/display/intel_display_power.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ static void icl_mbus_init(struct intel_display *display)
11741174
if (DISPLAY_VER(display) == 12)
11751175
abox_regs |= BIT(0);
11761176

1177-
for_each_set_bit(i, &abox_regs, sizeof(abox_regs))
1177+
for_each_set_bit(i, &abox_regs, BITS_PER_TYPE(abox_regs))
11781178
intel_de_rmw(display, MBUS_ABOX_CTL(i), mask, val);
11791179
}
11801180

@@ -1639,11 +1639,11 @@ static void tgl_bw_buddy_init(struct intel_display *display)
16391639
if (table[config].page_mask == 0) {
16401640
drm_dbg_kms(display->drm,
16411641
"Unknown memory configuration; disabling address buddy logic.\n");
1642-
for_each_set_bit(i, &abox_mask, sizeof(abox_mask))
1642+
for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask))
16431643
intel_de_write(display, BW_BUDDY_CTL(i),
16441644
BW_BUDDY_DISABLE);
16451645
} else {
1646-
for_each_set_bit(i, &abox_mask, sizeof(abox_mask)) {
1646+
for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask)) {
16471647
intel_de_write(display, BW_BUDDY_PAGE_MASK(i),
16481648
table[config].page_mask);
16491649

0 commit comments

Comments
 (0)