Skip to content

Commit a8b0032

Browse files
jnikulagregkh
authored andcommitted
drm/i915/power: fix size for for_each_set_bit() in abox iteration
[ Upstream commit cfa7b76 ] 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ä <[email protected]> Cc: Matt Roper <[email protected]> Cc: [email protected] # v5.9+ Reviewed-by: Matt Roper <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jani Nikula <[email protected]> (cherry picked from commit 7ea3baa) Signed-off-by: Tvrtko Ursulin <[email protected]> [ adapted struct intel_display *display parameters to struct drm_i915_private *dev_priv ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f1b3497 commit a8b0032

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
@@ -5293,7 +5293,7 @@ static void icl_mbus_init(struct drm_i915_private *dev_priv)
52935293
if (DISPLAY_VER(dev_priv) == 12)
52945294
abox_regs |= BIT(0);
52955295

5296-
for_each_set_bit(i, &abox_regs, sizeof(abox_regs))
5296+
for_each_set_bit(i, &abox_regs, BITS_PER_TYPE(abox_regs))
52975297
intel_de_rmw(dev_priv, MBUS_ABOX_CTL(i), mask, val);
52985298
}
52995299

@@ -5754,11 +5754,11 @@ static void tgl_bw_buddy_init(struct drm_i915_private *dev_priv)
57545754
if (table[config].page_mask == 0) {
57555755
drm_dbg(&dev_priv->drm,
57565756
"Unknown memory configuration; disabling address buddy logic.\n");
5757-
for_each_set_bit(i, &abox_mask, sizeof(abox_mask))
5757+
for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask))
57585758
intel_de_write(dev_priv, BW_BUDDY_CTL(i),
57595759
BW_BUDDY_DISABLE);
57605760
} else {
5761-
for_each_set_bit(i, &abox_mask, sizeof(abox_mask)) {
5761+
for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask)) {
57625762
intel_de_write(dev_priv, BW_BUDDY_PAGE_MASK(i),
57635763
table[config].page_mask);
57645764

0 commit comments

Comments
 (0)