From: Jeff Garzik <jeff@garzik.org>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: linuxraid@amcc.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] 3w-9xxx: use PCI resource length correctly
Date: Fri, 28 Sep 2007 10:50:34 -0400 [thread overview]
Message-ID: <46FD14BA.7010508@garzik.org> (raw)
In-Reply-To: <20070928144556.GG4668@blackpad.ctb.virtua.com.br>
Eduardo Habkost wrote:
> Trying to ioremap() a larger area than pci_resource_len()
> may fail (e.g. under Xen). Fixes 3w-9xxx to use pci_resource_len()
> as length parameter to ioremap() instead of PAGE_SIZE.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> drivers/scsi/3w-9xxx.c | 14 +++++++++-----
> 1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index efd9d8d..885b340 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -1999,7 +1999,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
> {
> struct Scsi_Host *host = NULL;
> TW_Device_Extension *tw_dev;
> - u32 mem_addr;
> + int bar;
> + unsigned long mem_addr, mem_len;
> int retval = -ENODEV;
>
> retval = pci_enable_device(pdev);
> @@ -2046,12 +2047,15 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
> }
>
> if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
> - mem_addr = pci_resource_start(pdev, 1);
> + bar = 1;
> else
> - mem_addr = pci_resource_start(pdev, 2);
> + bar = 2;
> +
> + mem_addr = pci_resource_start(pdev, bar);
> + mem_len = pci_resource_len(pdev, bar);
>
> /* Save base address */
> - tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
> + tw_dev->base_addr = ioremap(mem_addr, mem_len);
Have you verified that the hardware resource is always a reasonable size?
Jeff
next prev parent reply other threads:[~2007-09-28 14:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-28 14:45 [PATCH] 3w-9xxx: use PCI resource length correctly Eduardo Habkost
2007-09-28 14:50 ` Jeff Garzik [this message]
2007-09-28 15:15 ` Eduardo Pereira Habkost
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=46FD14BA.7010508@garzik.org \
--to=jeff@garzik.org \
--cc=ehabkost@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxraid@amcc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.