qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Avi Kivity <avi@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] Add PCI memory region registration
Date: Wed, 27 May 2009 09:08:33 -0500	[thread overview]
Message-ID: <4A1D4961.1010903@us.ibm.com> (raw)
In-Reply-To: <1243157375-14329-3-git-send-email-avi@redhat.com>

Avi Kivity wrote:
> A registered PCI memory region will be automatically mapped and unmapped
> as the associated BAR is manipulated.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  hw/pci.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  hw/pci.h |   26 ++++++++++++++++++++
>  2 files changed, 103 insertions(+), 1 deletions(-)
>
> diff --git a/hw/pci.h b/hw/pci.h
> index ff858a1..b27e8fd 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -2,6 +2,7 @@
>  #define QEMU_PCI_H
>  
>  #include "qemu-common.h"
> +#include "sys-queue.h"
>  
>  /* PCI includes legacy ISA access.  */
>  #include "isa.h"
> @@ -80,11 +81,21 @@ typedef int PCIUnregisterFunc(PCIDevice *pci_dev);
>  #define PCI_ADDRESS_SPACE_IO		0x01
>  #define PCI_ADDRESS_SPACE_MEM_PREFETCH	0x08
>  
> +typedef struct PCIIORegionComponent {
> +    PhysicalMemoryRegion *pmr;
> +    target_phys_addr_t offset;
> +    target_phys_addr_t size;
> +    ram_addr_t ram_addr;
> +    ram_addr_t region_offset;
> +    LIST_ENTRY(PCIIORegionComponent) link;
> +} PCIIORegionComponent;
> +
>  typedef struct PCIIORegion {
>      uint32_t addr; /* current PCI mapping address. -1 means not mapped */
>      uint32_t size;
>      uint8_t type;
>      PCIMapIORegionFunc *map_func;
> +    LIST_HEAD(pci_region_list, PCIIORegionComponent) components;
>  } PCIIORegion;
>  
>  #define PCI_ROM_SLOT 6
> @@ -171,6 +182,21 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num,
>                              uint32_t size, int type,
>                              PCIMapIORegionFunc *map_func);
>  
> +PCIIORegionComponent *pci_register_physical_memory(PCIDevice *pci_dev,
> +                                                   int region_num,
> +                                                   target_phys_addr_t size,
> +                                                   ram_addr_t ram_addr);
>   

PCI devices should not care about physical memory.  They should only 
care about IO regions.  It ought to look something like:

enum {
   PCI_REGION_IO,
   PCI_REGION_MEM,
};

typedef struct PCIIOFunction
{
   uint32_t (*read)(void *opaque, uint64_t offset, int size);
   void (*write)(void *opaque, uint64_t offset, int size, uint64_t value);
} PCIIOFunction;

pci_register_io_region(PCIDevice *pci_dev,
                                     int region_num,
                                     int region_type,
                                     int order,
                                     PCIIOFunction *io_func,
                                     void *opaque);

The current PCI map API goes away.  Devices don't have to know anything 
about that.  Special handling for PIO/MMIO for PCI devices also go 
away.  Devices can register PCI_REGION_IO regions and they'll be 
automatically mapped to MMIO for non-x86 architectures.  This means a 
lot of current PCI devices can be built once instead of being built for 
each architecture.

If you want, we can setup a temporary branch in qemu to stage the 
conversion.  I'm willing to help do the conversion too.

Regards,

Anthony Liguori

  reply	other threads:[~2009-05-27 14:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-24  9:29 [Qemu-devel] [PATCH 0/3] Object-based physical memory management Avi Kivity
2009-05-24  9:29 ` [Qemu-devel] [PATCH 1/3] Add PhysicalMemoryRegion type Avi Kivity
2009-05-27 14:16   ` Christoph Hellwig
2009-05-27 15:07     ` Avi Kivity
2009-05-24  9:29 ` [Qemu-devel] [PATCH 2/3] Add PCI memory region registration Avi Kivity
2009-05-27 14:08   ` Anthony Liguori [this message]
2009-05-27 15:02     ` Avi Kivity
2009-05-27 15:11       ` Anthony Liguori
2009-05-27 15:24         ` Avi Kivity
2009-05-27 22:33           ` Anthony Liguori
2009-05-31 11:02             ` Christoph Hellwig
2009-05-31 11:50               ` Avi Kivity
2009-05-31 11:47             ` Avi Kivity
2009-05-31 13:52               ` Anthony Liguori
2009-05-31 13:03             ` Avi Kivity
2009-05-24  9:29 ` [Qemu-devel] [PATCH 3/3] Convert RTL8139 to use PCI memory regitration facility Avi Kivity
2009-05-27 14:08 ` [Qemu-devel] [PATCH 0/3] Object-based physical memory management Anthony Liguori
2009-05-27 14:54   ` Avi Kivity

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=4A1D4961.1010903@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --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).