public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: John Keller <jpk@sgi.com>
Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] - SN: Correct ROM resource length for BIOS copy
Date: Fri, 29 Jun 2007 16:46:44 +0000	[thread overview]
Message-ID: <20070629094644.616c754a.randy.dunlap@oracle.com> (raw)
In-Reply-To: <20070629162058.24692.18526.sendpatchset@attica.americas.sgi.com>

On Fri, 29 Jun 2007 11:20:58 -0500 John Keller wrote:

> On SN systems, when setting the IORESOURCE_ROM_BIOS_COPY resource flag,
> the resource length should be set to the actual size of the ROM image
> so that a call to pci_map_rom() returns the correct size.
> 
> Signed-off-by: John Keller <jpk@sgi.com>
> ---
> 
> To avoid duplicate code, the image size calculation loop in
> pci_map_rom() has been put into a separate function that both
> pci_map_rom() and the SN specific code now call.
> 
>  arch/ia64/sn/kernel/io_acpi_init.c |   17 ++----
>  arch/ia64/sn/kernel/io_init.c      |   20 ++++++-
>  drivers/pci/rom.c                  |   73 ++++++++++++++++-----------
>  include/linux/pci.h                |    1 
>  4 files changed, 70 insertions(+), 41 deletions(-)
> 
> 
> Index: linux-2.6/drivers/pci/rom.c
> =================================> --- linux-2.6.orig/drivers/pci/rom.c	2007-06-28 10:36:02.956505069 -0500
> +++ linux-2.6/drivers/pci/rom.c	2007-06-28 10:45:18.475626403 -0500
> @@ -54,6 +54,49 @@ static void pci_disable_rom(struct pci_d
>  }
>  
>  /**
> + * pci_get_rom_size - obtain the actual size of the ROM image
> + * @rom: kernel virtual pointer to image of ROM
> + *  size: size of PCI window

nit:  s/ size/@size/

> + *  return: size of actual ROM image
> + *
> + * Determine the actual length of the ROM image.
> + * The PCI window size could be much larger than the
> + * actual image size.
> + */
> +size_t pci_get_rom_size(void __iomem *rom, size_t size)
> +{
> +	void __iomem *image;
> +	int last_image;
> +
> +	image = rom;
> +	do {
> +		void __iomem *pds;
> +		/* Standard PCI ROMs start out with these bytes 55 AA */
> +		if (readb(image) != 0x55)
> +			break;
> +		if (readb(image + 1) != 0xAA)
> +			break;
> +		/* get the PCI data structure and check its signature */
> +		pds = image + readw(image + 24);
> +		if (readb(pds) != 'P')
> +			break;
> +		if (readb(pds + 1) != 'C')
> +			break;
> +		if (readb(pds + 2) != 'I')
> +			break;
> +		if (readb(pds + 3) != 'R')
> +			break;
> +		last_image = readb(pds + 21) & 0x80;
> +		/* this length is reliable */
> +		image += readw(pds + 16) * 512;
> +	} while (!last_image);
> +
> +	/* never return a size larger than the PCI resource window */
> +	/* there are known ROMs that get the size wrong */
> +	return min((size_t)(image - rom), size);
> +}
> +
> +/**
>   * pci_map_rom - map a PCI ROM to kernel space
>   * @pdev: pointer to pci device struct
>   * @size: pointer to receive size of pci window over ROM


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

      reply	other threads:[~2007-06-29 16:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-29 16:20 [PATCH] - SN: Correct ROM resource length for BIOS copy John Keller
2007-06-29 16:46 ` Randy Dunlap [this message]

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=20070629094644.616c754a.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=jpk@sgi.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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