diff mbox series

[v2,4/4] drm/i915: Show bios vbt when read from firmware/spi/oprom

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

Commit Message

Sripada, Radhakrishna Feb. 20, 2024, 10:31 p.m. UTC
Make debugfs vbt only shows valid vbt when read from ACPI opregion.
Make it work when read from firmware/spi/pci oprom cases.

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c | 30 +++++++++++++++++------
 1 file changed, 23 insertions(+), 7 deletions(-)

Comments

Jani Nikula Feb. 27, 2024, 12:43 p.m. UTC | #1
On Tue, 20 Feb 2024, Radhakrishna Sripada <radhakrishna.sripada@intel.com> wrote:
> Make debugfs vbt only shows valid vbt when read from ACPI opregion.
> Make it work when read from firmware/spi/pci oprom cases.
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_bios.c | 30 +++++++++++++++++------
>  1 file changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index 4cd338ed362d..b9b4ebc0ecd6 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -3723,14 +3723,30 @@ static int intel_bios_vbt_show(struct seq_file *m, void *unused)
>  	struct drm_i915_private *i915 = m->private;
>  	const void *vbt;
>  	size_t vbt_size;
> +	bool need_cleanup = false;
>  
> -	/*
> -	 * FIXME: VBT might originate from other places than opregion, and then
> -	 * this would be incorrect.
> -	 */
> -	vbt = intel_opregion_get_vbt(i915, &vbt_size);
> -	if (vbt)
> -		seq_write(m, vbt, vbt_size);
> +	vbt = firmware_get_vbt(i915, &vbt_size);
> +
> +	if (!vbt)
> +		vbt = intel_opregion_get_vbt(i915, &vbt_size);
> +
> +	if (!vbt && IS_DGFX(i915)) {
> +		vbt = spi_oprom_get_vbt(i915, &vbt_size);
> +		need_cleanup = true;
> +	}
> +
> +	if (!vbt) {
> +		vbt = oprom_get_vbt(i915, &vbt_size);
> +		need_cleanup = true;
> +	}

We can't duplicate all of that, needs to be a single function that gets
used in both intel_bios_init() and here.

BR,
Jani.

> +
> +	if (!vbt)
> +		return 0;
> +
> +	seq_write(m, vbt, vbt_size);
> +
> +	if (need_cleanup)
> +		kfree(vbt);
>  
>  	return 0;
>  }
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 4cd338ed362d..b9b4ebc0ecd6 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -3723,14 +3723,30 @@  static int intel_bios_vbt_show(struct seq_file *m, void *unused)
 	struct drm_i915_private *i915 = m->private;
 	const void *vbt;
 	size_t vbt_size;
+	bool need_cleanup = false;
 
-	/*
-	 * FIXME: VBT might originate from other places than opregion, and then
-	 * this would be incorrect.
-	 */
-	vbt = intel_opregion_get_vbt(i915, &vbt_size);
-	if (vbt)
-		seq_write(m, vbt, vbt_size);
+	vbt = firmware_get_vbt(i915, &vbt_size);
+
+	if (!vbt)
+		vbt = intel_opregion_get_vbt(i915, &vbt_size);
+
+	if (!vbt && IS_DGFX(i915)) {
+		vbt = spi_oprom_get_vbt(i915, &vbt_size);
+		need_cleanup = true;
+	}
+
+	if (!vbt) {
+		vbt = oprom_get_vbt(i915, &vbt_size);
+		need_cleanup = true;
+	}
+
+	if (!vbt)
+		return 0;
+
+	seq_write(m, vbt, vbt_size);
+
+	if (need_cleanup)
+		kfree(vbt);
 
 	return 0;
 }