From: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Alexander Graf <agraf@suse.de>,
qemu-devel@nongnu.org,
Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 1/2] pseries pci: spapr_finalize_pci_setup introduced
Date: Tue, 10 Jul 2012 15:51:36 +1000 [thread overview]
Message-ID: <1341899497-23265-2-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1341899497-23265-1-git-send-email-aik@ozlabs.ru>
Previously PCI bus setup was done in 3 steps:
1) create a PCI bus, configure DMA
2) create PCI devices on the bus
3) populate a PCI bus node in the Device Tree
As some bus parameters can be configured only when some or all
the devices got attached to the bus and initialized,
the spapr_finalize_pci_setup has been introduced.
As an example, such a handler can setup DMA window parameters taken from
an IOMMU file descriptor available from a VFIO PCI device.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/spapr.c | 7 +++++++
hw/spapr_pci.c | 13 ++++++++++---
hw/spapr_pci.h | 2 ++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/hw/spapr.c b/hw/spapr.c
index b83f83b..688a135 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -516,7 +516,14 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
}
QLIST_FOREACH(phb, &spapr->phbs, list) {
+ ret = spapr_finalize_pci_setup(phb);
+ if (ret < 0) {
+ break;
+ }
ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
+ if (ret < 0) {
+ break;
+ }
}
if (ret < 0) {
diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index 014297b..5f89003 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -573,9 +573,6 @@ static int spapr_phb_init(SysBusDevice *s)
phb->host_state.bus = bus;
phb->dma_liobn = SPAPR_PCI_BASE_LIOBN | (pci_find_domain(bus) << 16);
- phb->dma_window_start = 0;
- phb->dma_window_size = 0x40000000;
- phb->dma = spapr_tce_new_dma_context(phb->dma_liobn, phb->dma_window_size);
pci_setup_iommu(bus, spapr_pci_dma_context_fn, phb);
QLIST_INSERT_HEAD(&spapr->phbs, phb, list);
@@ -639,6 +636,16 @@ void spapr_create_phb(sPAPREnvironment *spapr,
qdev_init_nofail(dev);
}
+/* Finalize PCI setup, called when all devices are already created */
+int spapr_finalize_pci_setup(sPAPRPHBState *phb)
+{
+ phb->dma_window_start = 0;
+ phb->dma_window_size = 0x40000000;
+ phb->dma = spapr_tce_new_dma_context(phb->dma_liobn,
+ phb->dma_window_size);
+ return 0;
+}
+
/* Macros to operate with address in OF binding to PCI */
#define b_x(x, p, l) (((x) & ((1<<(l))-1)) << (p))
#define b_n(x) b_x((x), 31, 1) /* 0 if relocatable */
diff --git a/hw/spapr_pci.h b/hw/spapr_pci.h
index 145071c..3aae273 100644
--- a/hw/spapr_pci.h
+++ b/hw/spapr_pci.h
@@ -68,6 +68,8 @@ void spapr_create_phb(sPAPREnvironment *spapr,
uint64_t mem_win_addr, uint64_t mem_win_size,
uint64_t io_win_addr, uint64_t msi_win_addr);
+int spapr_finalize_pci_setup(sPAPRPHBState *phb);
+
int spapr_populate_pci_dt(sPAPRPHBState *phb,
uint32_t xics_phandle,
void *fdt);
--
1.7.10
next prev parent reply other threads:[~2012-07-10 5:51 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 5:51 [Qemu-devel] [PATCH 0/2] RFC: powerpc-vfio: adding support Alexey Kardashevskiy
2012-07-10 5:51 ` Alexey Kardashevskiy [this message]
2012-07-10 5:51 ` [Qemu-devel] [PATCH 2/2] vfio-powerpc: added VFIO support Alexey Kardashevskiy
2012-07-10 16:55 ` Alex Williamson
2012-07-10 21:32 ` Benjamin Herrenschmidt
2012-07-10 21:48 ` Alex Williamson
2012-07-10 21:53 ` Benjamin Herrenschmidt
2012-07-11 2:54 ` Alexey Kardashevskiy
2012-07-11 3:10 ` Benjamin Herrenschmidt
2012-07-12 3:11 ` Alex Williamson
2012-07-12 8:47 ` Alexey Kardashevskiy
2012-07-10 22:26 ` Scott Wood
2012-07-10 23:55 ` Alexey Kardashevskiy
2012-07-11 0:04 ` Benjamin Herrenschmidt
2012-07-11 0:17 ` Alexey Kardashevskiy
2012-07-11 0:26 ` Benjamin Herrenschmidt
2012-07-10 16:57 ` [Qemu-devel] [PATCH 0/2] RFC: powerpc-vfio: adding support Alex Williamson
2012-07-11 2:25 ` Alexey Kardashevskiy
2012-07-12 2:54 ` Alex Williamson
2012-07-12 4:16 ` Alexey Kardashevskiy
2012-07-12 4:31 ` Alex Williamson
2012-07-12 4:38 ` Alexey Kardashevskiy
2012-07-12 4:43 ` Alex Williamson
2012-07-12 4:58 ` Alexey Kardashevskiy
2012-07-12 5:29 ` Alex Williamson
2012-07-12 5:47 ` Alexey Kardashevskiy
2012-07-16 3:51 ` Alexey Kardashevskiy
2012-07-23 5:32 ` [Qemu-devel] [PATCH 0/3] vfio-pci: reworking end-of-interrupt Alexey Kardashevskiy
2012-07-23 5:32 ` [Qemu-devel] [PATCH 1/3] xics: added end-of-interrupt (EOI) handlers Alexey Kardashevskiy
2012-07-23 5:32 ` [Qemu-devel] [PATCH 2/3] ioapic: removed obsolete ioapic_remove_gsi_eoi_notifier Alexey Kardashevskiy
2012-07-23 5:32 ` [Qemu-devel] [PATCH 3/3] vfio-pci: rework of EOI Alexey Kardashevskiy
2012-07-12 8:52 ` [Qemu-devel] [PATCH] RFC: vfio-powerpc: added VFIO support (v2) Alexey Kardashevskiy
2012-07-12 20:54 ` [Qemu-devel] [Qemu-ppc] " Blue Swirl
2012-07-12 21:37 ` Alex Williamson
2012-07-13 5:24 ` Alexey Kardashevskiy
2012-07-13 14:33 ` Blue Swirl
2012-07-12 22:35 ` Scott Wood
2012-07-13 5:31 ` Alexey Kardashevskiy
2012-07-13 3:47 ` [Qemu-devel] " Alex Williamson
2012-07-13 5:03 ` Alexey Kardashevskiy
2012-07-13 7:26 ` [Qemu-devel] [PATCH] RFC: vfio-powerpc: added VFIO support (v3) Alexey Kardashevskiy
2012-07-13 14:38 ` Blue Swirl
2012-07-13 15:07 ` Alex Williamson
2012-07-14 2:34 ` Alexey Kardashevskiy
2012-07-16 14:21 ` Alex Williamson
2012-07-16 21:17 ` Alex Williamson
2012-07-17 7:53 ` Alexey Kardashevskiy
2012-07-17 14:11 ` Alex Williamson
2012-07-18 11:09 ` [Qemu-devel] [PATCH] vfio-powerpc: added VFIO support (v4) Alexey Kardashevskiy
2012-07-18 14:14 ` Alex Williamson
2012-07-19 4:01 ` Alexey Kardashevskiy
2012-07-19 4:04 ` [Qemu-devel] [PATCH] vfio-powerpc: added VFIO support (v5) Alexey Kardashevskiy
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=1341899497-23265-2-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).