From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: David Gibson <david@gibson.dropbear.id.au>,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
Alex Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH] kernel vfio: PCI ROM size calculation
Date: Sun, 13 May 2012 20:55:03 -0600 [thread overview]
Message-ID: <1336964103.6954.12.camel@bling.home> (raw)
In-Reply-To: <4FAE0824.4050209@ozlabs.ru>
On Sat, 2012-05-12 at 16:50 +1000, Alexey Kardashevskiy wrote:
> The original code calculated the real size of the ROM and passed it to
> QEMU which tried to do pci_register_bar and failed with error message
> "ERROR: PCI region size must be pow2".
>
> The example card is PCIe Intel E1000E with the ROM size 0x9c00.
>
> pci_resource_len seems to be a proper solution.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> drivers/vfio/pci/vfio_pci.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index b2f1f3a..6d4a783 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -234,12 +234,9 @@ static long vfio_pci_ioctl(void *device_data,
> * this gives the user an easy way to determine whether
> * there's anything here w/o trying to read it. */
This is actually intentional, but maybe isn't the best way to handle it
anymore. The cut-off comment above reads:
/* Report the actual ROM size instead of the BAR size,
* this gives the user an easy way to determine whether
* there's anything here w/o trying to read it. */
At the time I added that though, I think we still had a separate ioctl
to get the BAR size, so one gave the real size, the other the BAR size.
Do we care to expose that ROMs have real size, maybe zero, that doesn't
necessarily match pci_resource_len()? Thanks,
Alex
> if (info.index == VFIO_PCI_ROM_REGION_INDEX) {
> - void __iomem *io;
> - size_t size;
> -
> - io = pci_map_rom(pdev, &size);
> - info.size = io ? size : 0;
> - pci_unmap_rom(pdev, io);
> + info.size = pci_resource_len(pdev,
> + PCI_ROM_RESOURCE);
> + info.flags |= VFIO_PCI_ROM_REGION_INDEX;
> } else if (flags & IORESOURCE_MEM) {
> info.size = pci_resource_len(pdev, info.index);
> info.flags |= (VFIO_REGION_INFO_FLAG_WRITE |
>
next prev parent reply other threads:[~2012-05-14 2:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-12 6:50 [Qemu-devel] [PATCH] kernel vfio: PCI ROM size calculation Alexey Kardashevskiy
2012-05-14 2:55 ` Alex Williamson [this message]
2012-05-14 3:24 ` Alexey Kardashevskiy
2012-05-14 4:34 ` Alex Williamson
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=1336964103.6954.12.camel@bling.home \
--to=alex.williamson@redhat.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).