From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: chrisw@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH 4/8] pci: Replace used bitmap with capability byte map
Date: Fri, 12 Nov 2010 11:02:30 +0200 [thread overview]
Message-ID: <20101112090230.GF7631@redhat.com> (raw)
In-Reply-To: <1289542035.2805.49.camel@x201>
On Thu, Nov 11, 2010 at 11:07:15PM -0700, Alex Williamson wrote:
> On Fri, 2010-11-12 at 07:40 +0200, Michael S. Tsirkin wrote:
> > On Thu, Nov 11, 2010 at 07:55:43PM -0700, Alex Williamson wrote:
> > > Capabilities are allocated in bytes, so we can track both whether
> > > a byte is used and by what capability in the same structure.
> > >
> > > Remove pci_reserve_capability() as there are no users.
> > >
> > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> >
> > I actually wanted to remove the used array completely and ask
> > all users to add offsets directly.
> > Will this be needed then?
>
> Can you give an example, I don't understand what you mean by asking
> users to add offsets directly.
Here's a dump of patch in progress.
Something like the below (untested). After applying this we can remove
the whole used array allocator.
> I think some kind of tracking what's
> where in config space needs to be done somewhere and the common PCI code
> seems like it'd be the place.
Why do we need it? config lets us scan the capability list
readily enough. I had this idea that we should pack
capabilities in config space, but now I think it's silly.
> Thanks,
>
> Alex
pci: remove config space allocator
pci supports allocating caps in config space so they are packed tightly.
This doesn't seem to be useful, especially since caps must stay at fixed
offsets to ensure backwards compatibility (e.g. for migration).
Remove this support, and make virtio-pci supply the offset to
the MSIX capability explicitly.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/hw/msix.c b/hw/msix.c
index f66d255..6fd3791 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -52,7 +52,7 @@ int msix_supported;
* Original bar size must be a power of 2 or 0.
* New bar size is returned. */
static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
- unsigned bar_nr, unsigned bar_size)
+ unsigned offset, unsigned bar_nr, unsigned bar_size)
{
int config_offset;
uint8_t *config;
@@ -75,7 +75,7 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
pdev->msix_bar_size = new_size;
config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX,
- 0, MSIX_CAP_LENGTH);
+ offset, MSIX_CAP_LENGTH);
if (config_offset < 0)
return config_offset;
config = pdev->config + config_offset;
@@ -237,7 +237,7 @@ static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
/* Initialize the MSI-X structures. Note: if MSI-X is supported, BAR size is
* modified, it should be retrieved with msix_bar_size. */
int msix_init(struct PCIDevice *dev, unsigned short nentries,
- unsigned bar_nr, unsigned bar_size)
+ unsigned offset, unsigned bar_nr, unsigned bar_size)
{
int ret;
/* Nothing to do if MSI is not supported by interrupt controller */
@@ -261,7 +261,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
}
dev->msix_entries_nr = nentries;
- ret = msix_add_config(dev, nentries, bar_nr, bar_size);
+ ret = msix_add_config(dev, nentries, offset, bar_nr, bar_size);
if (ret)
goto err_config;
diff --git a/hw/msix.h b/hw/msix.h
index a9f7993..b61e42e 100644
--- a/hw/msix.h
+++ b/hw/msix.h
@@ -5,7 +5,7 @@
#include "pci.h"
int msix_init(PCIDevice *pdev, unsigned short nentries,
- unsigned bar_nr, unsigned bar_size);
+ unsigned offset, unsigned bar_nr, unsigned bar_size);
void msix_write_config(PCIDevice *pci_dev, uint32_t address,
uint32_t val, int len);
diff --git a/hw/pci.c b/hw/pci.c
index aed2d42..e411f12 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1737,12 +1737,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
uint8_t offset, uint8_t size)
{
uint8_t *config;
- if (!offset) {
- offset = pci_find_space(pdev, size);
- if (!offset) {
- return -ENOSPC;
- }
- }
+ assert(offset >= PCI_CONFIG_HEADER_SIZE);
config = pdev->config + offset;
config[PCI_CAP_LIST_ID] = cap_id;
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 729917d..bcb0266 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -543,7 +543,8 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
config[0x3d] = 1;
- if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0)) {
+ if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors,
+ PCI_CONFIG_HEADER_SIZE, 1, 0)) {
pci_register_bar(&proxy->pci_dev, 1,
msix_bar_size(&proxy->pci_dev),
PCI_BASE_ADDRESS_SPACE_MEMORY,
next prev parent reply other threads:[~2010-11-12 9:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-12 2:54 [Qemu-devel] [PATCH 0/8] PCI capability and device assignment improvements Alex Williamson
2010-11-12 2:55 ` [Qemu-devel] [PATCH 1/8] pci: pci_default_cap_write_config ignores wmask Alex Williamson
2010-11-12 5:22 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-12 6:03 ` Alex Williamson
2010-11-12 8:48 ` Michael S. Tsirkin
2010-11-12 15:49 ` Alex Williamson
2010-11-16 16:12 ` Michael S. Tsirkin
2010-11-12 2:55 ` [Qemu-devel] [PATCH 2/8] pci: Remove pci_enable_capability_support() Alex Williamson
2010-11-12 2:55 ` [Qemu-devel] [PATCH 3/8] device-assignment: Use PCI capabilities support Alex Williamson
2010-11-12 2:55 ` [Qemu-devel] [PATCH 4/8] pci: Replace used bitmap with capability byte map Alex Williamson
2010-11-12 5:40 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-12 6:07 ` Alex Williamson
2010-11-12 9:02 ` Michael S. Tsirkin [this message]
2010-11-12 15:32 ` Alex Williamson
2010-11-12 2:55 ` [Qemu-devel] [PATCH 5/8] pci: Remove cap.length, cap.start, cap.supported Alex Williamson
2010-11-12 2:56 ` [Qemu-devel] [PATCH 6/8] device-assignment: Move PCI capabilities to match physical hardware Alex Williamson
2010-11-12 9:20 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-12 13:53 ` Alex Williamson
2010-11-12 2:56 ` [Qemu-devel] [PATCH 7/8] pci: Pass ID for capability read/write handlers Alex Williamson
2010-11-12 2:56 ` [Qemu-devel] [RFC PATCH 8/8] device-assignment: pass through and stub more PCI caps Alex Williamson
2010-11-12 5:36 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-12 6:30 ` Alex Williamson
2010-11-12 9:11 ` Michael S. Tsirkin
2010-11-12 15:42 ` Alex Williamson
2010-11-16 16:08 ` Michael S. Tsirkin
2010-11-12 5:39 ` [Qemu-devel] Re: [PATCH 0/8] PCI capability and device assignment improvements Michael S. Tsirkin
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=20101112090230.GF7631@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=chrisw@redhat.com \
--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).