[RFC 15/15] drm/i915: Use vbt type to determine its validity

Radhakrishna Sripada radhakrishna.sripada at intel.com
Mon Jan 8 23:05:17 UTC 2024


We depend on a non null vbt field in intel_vbt to determine
if a vbt is read from its source. This may not be foolproof
hence rely on vbt->type to determine if vbt is read from a source.
Note that this does not determine the validity of read vbt.

Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada at intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 135a2d5d50b8..0938c9ec8fbe 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -3119,6 +3119,11 @@ static void oprom_get_vbt(struct drm_i915_private *i915,
 	return;
 }
 
+static inline bool is_empty_vbt(struct intel_vbt *vbt)
+{
+	return vbt && vbt->type == I915_VBT_NONE;
+}
+
 /**
  * intel_bios_init - find VBT and initialize settings from the BIOS
  * @i915: i915 device instance
@@ -3154,19 +3159,19 @@ void intel_bios_init(struct drm_i915_private *i915)
 
 	intel_load_vbt_firmware(i915, vbt);
 
-	if (!vbt->vbt && opregion->asls)
+	if (is_empty_vbt(vbt) && opregion->asls)
 		intel_load_opregion_vbt(i915, opregion, vbt);
 	/*
 	 * If the OpRegion does not have VBT, look in SPI flash through MMIO or
 	 * PCI mapping
 	 */
-	if (!vbt->vbt && IS_DGFX(i915))
+	if (is_empty_vbt(vbt) && IS_DGFX(i915))
 		spi_oprom_get_vbt(i915, vbt);
 
-	if (!vbt->vbt)
+	if (is_empty_vbt(vbt))
 		oprom_get_vbt(i915, vbt);
 
-	if (!vbt->vbt)
+	if (is_empty_vbt(vbt))
 		goto out;
 
 	header = (struct vbt_header *)vbt->vbt;
-- 
2.34.1



More information about the Intel-gfx mailing list