All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Isaku Yamahata <yamahata@valinux.co.jp>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] pci: add standard bridge device
Date: Sun, 04 Sep 2011 16:55:33 +0300	[thread overview]
Message-ID: <4E638355.8030903@redhat.com> (raw)
In-Reply-To: <20110904134101.GA27239@redhat.com>

On 09/04/2011 04:41 PM, Michael S. Tsirkin wrote:
> On Sun, Sep 04, 2011 at 04:05:14PM +0300, Avi Kivity wrote:
> >  It follows naturally:
>
> OK, so it seems the following is more or less what you suggest?
> I'm not sure I create/destroy subregions properly.
> Both the alias and the subregion get the same start value?

Yes (so addresses are not shifted).

> Is the region name for debugging only?

For everything except RAM regions (there, the name is also used for 
save/restore).

> When does priority matter? In case of overlap?

Yes.  In this case, since overlap resolution is not defined by the spec, 
the actual priority does not matter.

> @@ -135,6 +135,75 @@ pcibus_t pci_bridge_get_limit(const PCIDevice *bridge, uint8_t type)
>       return limit;
>   }
>
> +static pcibus_t pci_bridge_get_size(const PCIDevice *bridge, uint8_t type)
> +{
> +    return pci_bridge_get_limit(bridge, type)>=
> +        pci_bridge_get_base(bridge, type) ?
> +        pci_bridge_get_limit(bridge, type) -
> +        pci_bridge_get_base(bridge, type)  + 1 : 0;
> +}

Correct but unreadable.  Doesn't work for limit == 2^64-1, is this a 
possible value?

> +
> +static void pci_bridge_region_init(PCIBridge *br)
> +{
> +    PCIBus *sec_bus =&br->sec_bus;
> +    PCIBus *parent = br->dev.bus;
> +    memory_region_init_alias(sec_bus->alias_pref_mem, "pci_bridge_pref_mem",
> +	     sec_bus->address_space_mem,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_MEM_PREFETCH),
> +	     pci_bridge_get_size(&br->dev, PCI_BASE_ADDRESS_MEM_PREFETCH));
> +    memory_region_add_subregion_overlap(parent->address_space_mem,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_MEM_PREFETCH),
> +             sec_bus->alias_pref_mem, 1);
> +    memory_region_init_alias(sec_bus->alias_mem, "pci_bridge_memory",
> +	     sec_bus->address_space_mem,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
> +	     pci_bridge_get_size(&br->dev, PCI_BASE_ADDRESS_SPACE_MEMORY));
> +    memory_region_add_subregion_overlap(parent->address_space_mem,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
> +             sec_bus->alias_mem, 1);
> +    memory_region_init_alias(sec_bus->alias_io, "pci_bridge_io",
> +	     sec_bus->address_space_io,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_SPACE_IO),
> +	     pci_bridge_get_size(&br->dev, PCI_BASE_ADDRESS_SPACE_IO));
> +    memory_region_add_subregion_overlap(parent->address_space_io,
> +	     pci_bridge_get_base(&br->dev, PCI_BASE_ADDRESS_SPACE_IO),
> +             sec_bus->alias_io, 1);
> +}

This looks right.  Might want to use pci_address_space() instead of 
->address_space_mem.

Don't you have to do something similar for the vga window?

> +
> +static void pci_bridge_region_cleanup(PCIBridge *br)
> +{
> +    PCIBus *sec_bus =&br->sec_bus;
> +    PCIBus *parent = br->dev.bus;
> +    memory_region_del_subregion(parent->address_space_mem,
> +                                sec_bus->alias_pref_mem);
> +    memory_region_destroy(sec_bus->alias_pref_mem);
> +    memory_region_del_subregion(parent->address_space_mem,
> +                                sec_bus->alias_mem);
> +    memory_region_destroy(sec_bus->alias_mem);
> +    memory_region_del_subregion(parent->address_space_io,
> +                                sec_bus->alias_io);
> +    memory_region_destroy(sec_bus->alias_io);
> +}

This is fine too.

> +
> +static void pci_bridge_update_mappings(PCIBridge *br)
> +{
> +    /* TODO: this doesn't handle the case of one VCPU
> +     * updating the bridge while another accesses an unaffected
> +     * region. To fix we'll need new memory region APIs. */
> +    pci_bridge_region_cleanup(br);
> +    pci_bridge_region_init(br);

memory_region_transaction_{begin,commit}()

(isn't 100% implemented, but at least the API is in place)
> +
> +#if 0
> +    TODO: do we need to propagate updates to child buses?
> +
> +    pci_for_each_device_under_bus(b, pci_bridge_update_mappings_fn);
> +
> +    QLIST_FOREACH(child,&b->child, sibling) {
> +        pci_bridge_update_mappings(child);
> +    }
> +#endif
> +}

Don't need this.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2011-09-04 13:55 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04  9:43 [Qemu-devel] [PATCH] pci: add standard bridge device Michael S. Tsirkin
2011-07-05 13:29 ` Isaku Yamahata
2011-07-05 13:43   ` Michael S. Tsirkin
2011-08-17  8:37 ` Wen Congyang
2011-08-18  3:22   ` Wen Congyang
2011-08-18 15:15     ` Avi Kivity
2011-08-19  5:12       ` Wen Congyang
2011-08-19 15:26         ` Avi Kivity
2011-08-22  3:13           ` Wen Congyang
2011-08-22  6:23             ` Avi Kivity
2011-09-02  1:32               ` Wen Congyang
2011-09-02  2:56               ` Wen Congyang
2011-09-04  8:25                 ` Avi Kivity
2011-09-06  3:06                   ` Wen Congyang
2011-09-06  7:45                     ` Avi Kivity
2011-09-07  4:39                       ` Wen Congyang
2011-09-07 11:52                         ` Michael S. Tsirkin
2011-09-08  6:15                           ` Wen Congyang
2011-09-08  7:26                             ` Wen Congyang
2011-09-08  9:43                               ` Gerd Hoffmann
2011-09-08  9:58                                 ` Wen Congyang
2011-09-08 10:42                                   ` Michael S. Tsirkin
2011-09-08 11:03                                     ` Wen Congyang
2011-09-08 11:13                                       ` Michael S. Tsirkin
2011-09-09  6:43           ` Wen Congyang
2011-09-09  7:12             ` Michael S. Tsirkin
2011-09-09  7:24               ` Wen Congyang
2011-09-09  7:34                 ` Michael S. Tsirkin
2011-09-09  7:35                   ` Wen Congyang
2011-08-26  9:43       ` Michael S. Tsirkin
2011-08-28  7:50         ` Avi Kivity
2011-08-28 11:41           ` Michael S. Tsirkin
2011-08-28 13:10             ` Avi Kivity
2011-08-28 13:42               ` Michael S. Tsirkin
2011-08-28 13:53                 ` Avi Kivity
2011-09-04 12:30                   ` Michael S. Tsirkin
2011-09-04 12:40                     ` Avi Kivity
2011-09-04 13:01                       ` Michael S. Tsirkin
2011-09-04 13:05                         ` Avi Kivity
2011-09-04 13:09                           ` Avi Kivity
2011-09-04 13:41                           ` Michael S. Tsirkin
2011-09-04 13:55                             ` Avi Kivity [this message]
2011-09-04 14:21                               ` Michael S. Tsirkin
2011-09-04 14:36                                 ` Avi Kivity
2011-09-04 14:54                                   ` Michael S. Tsirkin
2011-09-04 15:14                                     ` Avi Kivity
2011-09-04 15:24                                       ` Michael S. Tsirkin
2011-09-04 15:37                                         ` Avi Kivity
2011-09-04 15:45                                           ` Michael S. Tsirkin
2011-09-04 15:46                                             ` Avi Kivity
2011-09-04 16:19                                               ` Michael S. Tsirkin
2011-09-04 16:22                                                 ` Avi Kivity
2011-09-04 17:03                                                   ` Michael S. Tsirkin
2011-09-05  5:36                                                     ` Avi Kivity
2011-09-04 15:26                                   ` Michael S. Tsirkin
2011-09-04 15:42                                     ` Avi Kivity
2011-09-04 15:46                                       ` Michael S. Tsirkin
2011-09-04 15:49                                         ` Avi Kivity
2011-09-04 16:20                                           ` Michael S. Tsirkin
2011-08-26  9:57     ` Michael S. Tsirkin
2011-09-04 17:11 ` Michael S. Tsirkin
2011-09-05  8:17   ` Markus Armbruster
2011-09-05  9:38     ` Michael S. Tsirkin
2011-09-05  9:53       ` Gerd Hoffmann
2011-09-05 11:40         ` Michael S. Tsirkin
2011-09-06  9:18         ` Markus Armbruster
     [not found] ` <4E801927.8020708@cn.fujitsu.com>
     [not found]   ` <20110926070824.GB5860@redhat.com>
     [not found]     ` <4EAF4AFD.6040102@cn.fujitsu.com>
     [not found]       ` <20111101084439.GA11958@redhat.com>
2011-11-01  8:49         ` Wen Congyang
2011-11-01 11:48           ` Michael S. Tsirkin
2011-11-02  1:00             ` Wen Congyang
2011-11-02  2:15           ` Isaku Yamahata
2011-11-02  2:38             ` Wen Congyang

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=4E638355.8030903@redhat.com \
    --to=avi@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /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.