diff mbox series

[v3,5/6] drm/i915: Duplicate opregion vbt memory

Message ID 20240228213235.2495611-6-radhakrishna.sripada@intel.com (mailing list archive)
State New, archived
Headers show
Series VBT read cleanup | expand

Commit Message

Sripada, Radhakrishna Feb. 28, 2024, 9:32 p.m. UTC
In the case of vbt residing in opregion, we simply remap the region
into the kernel and pass the memory reference. Instead duplicate the
memory to handle a saner cleanup in intel_bios_init.

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c     | 6 ++++--
 drivers/gpu/drm/i915/display/intel_opregion.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index c283a5a07010..e5229c41dbf7 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -3144,8 +3144,10 @@  void intel_bios_init(struct drm_i915_private *i915)
 	oprom_vbt = firmware_get_vbt(i915, NULL);
 	vbt = oprom_vbt;
 
-	if (!vbt)
-		vbt = intel_opregion_get_vbt(i915, NULL);
+	if (!vbt) {
+		oprom_vbt = intel_opregion_get_vbt(i915, NULL);
+		vbt = oprom_vbt;
+	}
 
 	/*
 	 * If the OpRegion does not have VBT, look in SPI flash through MMIO or
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c
index 58dfecb617b0..68bd5101ec89 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -1151,7 +1151,7 @@  const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size)
 	if (size)
 		*size = opregion->vbt_size;
 
-	return opregion->vbt;
+	return kmemdup(opregion->vbt, opregion->vbt_size, GFP_KERNEL);
 }
 
 bool intel_opregion_headless_sku(struct drm_i915_private *i915)