intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Radhakrishna Sripada <radhakrishna.sripada@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/4] drm/i915: Pass size to oprom_get_vbt
Date: Tue, 27 Feb 2024 14:37:10 +0200	[thread overview]
Message-ID: <875xyajd6x.fsf@intel.com> (raw)
In-Reply-To: <20240220223129.3822480-2-radhakrishna.sripada@intel.com>

On Tue, 20 Feb 2024, Radhakrishna Sripada <radhakrishna.sripada@intel.com> wrote:
> oprom_get_vbt will later be used to show the contents of vbt for which
> the size of vbt is needed.
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_bios.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index fe52c06271ef..ceb6e4145c62 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -3008,38 +3008,39 @@ static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915)
>  	return NULL;
>  }
>  
> -static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915)
> +static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915,
> +					size_t *size)
>  {
>  	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
>  	void __iomem *p = NULL, *oprom;
>  	struct vbt_header *vbt;
>  	u16 vbt_size;
> -	size_t i, size;
> +	size_t i;
>  
> -	oprom = pci_map_rom(pdev, &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 += 4) {
> +	for (i = 0; i + 4 < *size; i += 4) {

Not a fan of using *size everywhere. Please just use size here, and do
something like this near the end:

	if (sizep)
		*sizep = size;

This also allows you to pass NULL when you don't need the size, like
intel_bios_init(), and you can drop the extra dummy local variable.

BR,
Jani.

>  		if (ioread32(oprom + i) != *((const u32 *)"$VBT"))
>  			continue;
>  
>  		p = oprom + i;
> -		size -= i;
> +		*size -= i;
>  		break;
>  	}
>  
>  	if (!p)
>  		goto err_unmap_oprom;
>  
> -	if (sizeof(struct vbt_header) > size) {
> +	if (sizeof(struct vbt_header) > *size) {
>  		drm_dbg(&i915->drm, "VBT header incomplete\n");
>  		goto err_unmap_oprom;
>  	}
>  
>  	vbt_size = ioread16(p + offsetof(struct vbt_header, vbt_size));
> -	if (vbt_size > size) {
> +	if (vbt_size > *size) {
>  		drm_dbg(&i915->drm,
>  			"VBT incomplete (vbt_size overflows)\n");
>  		goto err_unmap_oprom;
> @@ -3082,6 +3083,7 @@ void intel_bios_init(struct drm_i915_private *i915)
>  	const struct vbt_header *vbt;
>  	struct vbt_header *oprom_vbt = NULL;
>  	const struct bdb_header *bdb;
> +	size_t size;
>  
>  	INIT_LIST_HEAD(&i915->display.vbt.display_devices);
>  	INIT_LIST_HEAD(&i915->display.vbt.bdb_blocks);
> @@ -3106,7 +3108,7 @@ void intel_bios_init(struct drm_i915_private *i915)
>  	}
>  
>  	if (!vbt) {
> -		oprom_vbt = oprom_get_vbt(i915);
> +		oprom_vbt = oprom_get_vbt(i915, &size);
>  		vbt = oprom_vbt;
>  	}

-- 
Jani Nikula, Intel

  reply	other threads:[~2024-02-27 12:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 22:31 [PATCH v2 0/4] VBT read cleanup Radhakrishna Sripada
2024-02-20 22:31 ` [PATCH v2 1/4] drm/i915: Pass size to oprom_get_vbt Radhakrishna Sripada
2024-02-27 12:37   ` Jani Nikula [this message]
2024-02-20 22:31 ` [PATCH v2 2/4] drm/i915: Pass size to spi_oprom_get_vbt Radhakrishna Sripada
2024-02-27 12:38   ` Jani Nikula
2024-02-20 22:31 ` [PATCH v2 3/4] drm/i915: Move vbt read from firmware to intel_bios.c Radhakrishna Sripada
2024-02-27 12:42   ` Jani Nikula
2024-02-20 22:31 ` [PATCH v2 4/4] drm/i915: Show bios vbt when read from firmware/spi/oprom Radhakrishna Sripada
2024-02-27 12:43   ` Jani Nikula
2024-02-21  2:51 ` ✗ Fi.CI.SPARSE: warning for VBT read cleanup Patchwork
2024-02-21  3:08 ` ✓ Fi.CI.BAT: success " Patchwork
2024-02-21  6:15 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-27 12:33 ` [PATCH v2 0/4] " Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xyajd6x.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=radhakrishna.sripada@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).