The unaligned ioread32() will make us read byte by byte looking for the vbt. We could just as well have done a ioread8() + a shift and avoid the extra confusion on how we are looking for "$VBT". However when using ACPI it's guaranteed the VBT is 4-byte aligned per spec, so we can probably assume it here as well. Signed-off-by: Lucas De Marchi <lucas.demarchi@xxxxxxxxx> --- drivers/gpu/drm/i915/display/intel_bios.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 3ab73f8db8dd..328bc6b6157f 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -1802,27 +1802,20 @@ static struct vbt_header *oprom_get_vbt(struct drm_i915_private *dev_priv) void __iomem *p = NULL, __iomem *oprom; struct vbt_header *vbt; u16 vbt_size; - size_t i, size; + size_t size; oprom = pci_map_rom(pdev, &size); if (!oprom) return NULL; /* Scour memory looking for the VBT signature. */ - for (i = 0; i + 4 < size; i++) { - if (ioread32(oprom + i) != *((const u32 *)"$VBT")) - continue; - - p = oprom + i; - size -= i; - break; - } - - if (!p) - goto err_unmap_oprom; + for (p = oprom; size >= 4; p += 4, size -= 4) + if (ioread32(p) == *((const u32 *)"$VBT")) + break; if (sizeof(struct vbt_header) > size) { - DRM_DEBUG_DRIVER("VBT header incomplete\n"); + if (size >= 4) + DRM_DEBUG_DRIVER("VBT header incomplete\n"); goto err_unmap_oprom; } -- 2.24.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx