All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	kvm@vger.kernel.org, Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [PATCH 13/13] qemu-kvm: Resolve PCI upstream diffs
Date: Tue, 28 Jun 2011 11:58:39 +0300	[thread overview]
Message-ID: <20110628085839.GO10881@redhat.com> (raw)
In-Reply-To: <673183e9e8b750a6c9b8f735038538d8a864ba1f.1309198794.git.jan.kiszka@web.de>

On Mon, Jun 27, 2011 at 08:19:56PM +0200, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Device assignment no longer peeks into config_map, so we can drop all
> the related changes and sync the PCI core with upstream.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

That's great because I was looking at refactoring that code.
Will make merges much less painful.

> ---
>  hw/pci.c |   29 +++++++++++++++--------------
>  hw/pci.h |    8 ++++++--
>  2 files changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 5deaa04..a637506 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -793,7 +793,7 @@ static void pci_config_alloc(PCIDevice *pci_dev)
>      pci_dev->cmask = qemu_mallocz(config_size);
>      pci_dev->wmask = qemu_mallocz(config_size);
>      pci_dev->w1cmask = qemu_mallocz(config_size);
> -    pci_dev->config_map = qemu_mallocz(config_size);
> +    pci_dev->used = qemu_mallocz(config_size);
>  }
>  
>  static void pci_config_free(PCIDevice *pci_dev)
> @@ -802,7 +802,7 @@ static void pci_config_free(PCIDevice *pci_dev)
>      qemu_free(pci_dev->cmask);
>      qemu_free(pci_dev->wmask);
>      qemu_free(pci_dev->w1cmask);
> -    qemu_free(pci_dev->config_map);
> +    qemu_free(pci_dev->used);
>  }
>  
>  /* -1 for devfn means auto assign */
> @@ -833,8 +833,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>      pci_dev->irq_state = 0;
>      pci_config_alloc(pci_dev);
>  
> -    memset(pci_dev->config_map, 0xff, PCI_CONFIG_HEADER_SIZE);
> -
>      pci_config_set_vendor_id(pci_dev->config, info->vendor_id);
>      pci_config_set_device_id(pci_dev->config, info->device_id);
>      pci_config_set_revision(pci_dev->config, info->revision);
> @@ -1899,7 +1897,7 @@ static int pci_find_space(PCIDevice *pdev, uint8_t size)
>      int offset = PCI_CONFIG_HEADER_SIZE;
>      int i;
>      for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
> -        if (pdev->config_map[i])
> +        if (pdev->used[i])
>              offset = i + 1;
>          else if (i - offset + 1 == size)
>              return offset;
> @@ -2080,13 +2078,13 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>          int i;
>  
>          for (i = offset; i < offset + size; i++) {
> -            if (pdev->config_map[i]) {
> +            if (pdev->used[i]) {
>                  fprintf(stderr, "ERROR: %04x:%02x:%02x.%x "
>                          "Attempt to add PCI capability %x at offset "
>                          "%x overlaps existing capability %x at offset %x\n",
>                          pci_find_domain(pdev->bus), pci_bus_num(pdev->bus),
>                          PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
> -                        cap_id, offset, pdev->config_map[i], i);
> +                        cap_id, offset, pdev->used[i], i);
>                  return -EINVAL;
>              }
>          }
> @@ -2096,14 +2094,12 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>      config[PCI_CAP_LIST_ID] = cap_id;
>      config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST];
>      pdev->config[PCI_CAPABILITY_LIST] = offset;
> -    memset(pdev->config_map + offset, cap_id, size);
> +    pdev->config[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
> +    memset(pdev->used + offset, 0xFF, size);
>      /* Make capability read-only by default */
>      memset(pdev->wmask + offset, 0, size);
>      /* Check capability by default */
>      memset(pdev->cmask + offset, 0xFF, size);
> -
> -    pdev->config[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
> -
>      return offset;
>  }
>  
> @@ -2119,11 +2115,16 @@ void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
>      memset(pdev->w1cmask + offset, 0, size);
>      /* Clear cmask as device-specific registers can't be checked */
>      memset(pdev->cmask + offset, 0, size);
> -    memset(pdev->config_map + offset, 0, size);
> +    memset(pdev->used + offset, 0, size);
>  
> -    if (!pdev->config[PCI_CAPABILITY_LIST]) {
> +    if (!pdev->config[PCI_CAPABILITY_LIST])
>          pdev->config[PCI_STATUS] &= ~PCI_STATUS_CAP_LIST;
> -    }
> +}
> +
> +/* Reserve space for capability at a known offset (to call after load). */
> +void pci_reserve_capability(PCIDevice *pdev, uint8_t offset, uint8_t size)
> +{
> +    memset(pdev->used + offset, 0xff, size);
>  }
>  
>  uint8_t pci_find_capability(PCIDevice *pdev, uint8_t cap_id)
> diff --git a/hw/pci.h b/hw/pci.h
> index c7081bc..ed734b3 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -146,8 +146,8 @@ struct PCIDevice {
>      /* Used to implement RW1C(Write 1 to Clear) bytes */
>      uint8_t *w1cmask;
>  
> -    /* Used to allocate config space and track capabilities. */
> -    uint8_t *config_map;
> +    /* Used to allocate config space capabilities. */
> +    uint8_t *used;
>  
>      /* the following fields are read only */
>      PCIBus *bus;
> @@ -233,14 +233,18 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>  
>  void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
>  
> +void pci_reserve_capability(PCIDevice *pci_dev, uint8_t offset, uint8_t size);
> +
>  uint8_t pci_find_capability(PCIDevice *pci_dev, uint8_t cap_id);
>  
> +
>  uint32_t pci_default_read_config(PCIDevice *d,
>                                   uint32_t address, int len);
>  void pci_default_write_config(PCIDevice *d,
>                                uint32_t address, uint32_t val, int len);
>  void pci_device_save(PCIDevice *s, QEMUFile *f);
>  int pci_device_load(PCIDevice *s, QEMUFile *f);
> +
>  typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level);
>  typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
>  
> -- 
> 1.7.1

  reply	other threads:[~2011-06-28  8:58 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-27 18:19 [PATCH 00/13] qemu-kvm: device assignment cleanups and upstream diff reductions Jan Kiszka
2011-06-27 18:19 ` [PATCH 01/13] qemu-kvm: Reduce configure and Makefile.target diff to upstream Jan Kiszka
2011-06-27 18:19 ` [PATCH 02/13] qemu-kvm: Drop some no longer needed #ifdefs Jan Kiszka
2011-06-27 18:19 ` [PATCH 03/13] qemu-kvm: Drop -enable-nesting command line switch Jan Kiszka
2011-06-28 10:48   ` Roedel, Joerg
2011-06-28 10:52     ` Jan Kiszka
2011-06-28 11:45       ` Avi Kivity
2011-06-27 18:19 ` [PATCH 04/13] qemu-kvm: Remove eventfd compat header Jan Kiszka
2011-06-28 11:09   ` Michael S. Tsirkin
2011-06-28 11:11     ` Jan Kiszka
2011-06-28 12:07       ` Michael S. Tsirkin
2011-06-28 12:11         ` Jan Kiszka
2011-06-28 12:17           ` Michael S. Tsirkin
2011-06-28 12:40             ` Jan Kiszka
2011-07-03  9:46     ` Bernhard Held
2011-07-03  9:54       ` Michael S. Tsirkin
2011-07-03  9:57         ` Michael S. Tsirkin
2011-07-03 18:31           ` Bernhard Held
2011-07-04 10:37             ` Michael S. Tsirkin
2011-07-04 12:13               ` Bernhard Held
2011-07-04 13:34                 ` Michael S. Tsirkin
2011-06-27 18:19 ` [PATCH 05/13] qemu-kvm: Remove qemu_ram_unmap Jan Kiszka
2011-06-27 18:19 ` [PATCH 06/13] qemu-kvm: Drop or replace useless device-assignment.h inclusions Jan Kiszka
2011-06-27 18:19 ` [PATCH 07/13] pci-assign: Fix kvm_deassign_irq handling in assign_irq Jan Kiszka
2011-06-27 18:19 ` [PATCH 08/13] pci-assign: Update legacy interrupts only if used Jan Kiszka
2011-06-27 18:19 ` [PATCH 09/13] pci-assign: Drop libpci header dependency Jan Kiszka
2011-06-28  8:54   ` Michael S. Tsirkin
2011-06-27 18:19 ` [PATCH 10/13] pci-assign: Refactor calc_assigned_dev_id Jan Kiszka
2011-06-27 18:19 ` [PATCH 11/13] pci-assign: Track MSI/MSI-X capability position, clean up related code Jan Kiszka
2011-06-27 18:19 ` [PATCH 12/13] pci-assign: Generic config space access management Jan Kiszka
2011-06-27 20:54   ` Michael S. Tsirkin
2011-06-27 22:48   ` Alex Williamson
2011-06-28  7:08     ` Jan Kiszka
2011-06-28  8:07     ` Avi Kivity
2011-06-28  8:19       ` Jan Kiszka
2011-06-28  8:21         ` Avi Kivity
2011-06-28  8:10   ` Michael S. Tsirkin
2011-06-28  8:18     ` Jan Kiszka
2011-06-28  8:30       ` Michael S. Tsirkin
2011-06-28  9:20         ` Jan Kiszka
2011-06-28  8:51   ` Michael S. Tsirkin
2011-06-28  9:10     ` Avi Kivity
2011-06-27 18:19 ` [PATCH 13/13] qemu-kvm: Resolve PCI upstream diffs Jan Kiszka
2011-06-28  8:58   ` Michael S. Tsirkin [this message]
2011-06-28  9:12     ` Jan Kiszka
2011-06-28  9:22       ` Michael S. Tsirkin
2011-06-28  8:10 ` [PATCH 00/13] qemu-kvm: device assignment cleanups and upstream diff reductions Avi Kivity
2011-06-28  8:57   ` 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=20110628085839.GO10881@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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.