qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH: RFC] Adding BAR0 for e500 PCI controller


From: Bharat Bhushan
Subject: [Qemu-devel] [PATCH: RFC] Adding BAR0 for e500 PCI controller
Date: Tue, 14 Aug 2012 18:20:07 +0530

PCI Root complex have TYPE-1 configuration header while PCI endpoint
have type-0 configuration header. The type-1 configuration header have
a BAR (BAR0). In Freescale PCI controller BAR0 is used for mapping pci
address space to CCSR address space. This can used for 2 purposes: 1)
for MSI interrupt generation 2) Allow CCSR registers access when configured
as PCI endpoint, which I am not sure is a use case with QEMU-KVM guest.

What I observed is that when guest read the size of BAR0 of host controller
configuration header (TYPE1 header) then it always reads it as 0. When
looking into the QEMU hw/ppce500_pci.c, I do not find the PCI controller
device registering BAR0. I do not find any other controller also doing so
may they do not use BAR0.

There are two issues when BAR0 is not there (which I can think of):
1) There should be BAR0 emulated for PCI Root comaplex (TYPE1 header) and
when reading the size of BAR0, it should give size as per real h/w.

2) Do we need this BAR0 inbound address translation?
        When BAR0 is of non-zero size then it will be configured for PCI
address space to local address(CCSR) space translation on inbound access.
The primary use case is for MSI interrupt generation. The device is
configured with a address offsets in PCI address space, which will be
translated to MSI interrupt generation MPIC registers. Currently I do
not understand the MSI interrupt generation mechanism in QEMU and also
IIRC we do not use QEMU MSI interrupt mechanism on e500 guest machines.
But this BAR0 will be used when using MSI on e500.

I can see one more issue, There are ATMUs emulated in hw/ppce500_pci.c,
but i do not see these being used for address translation.
So far that works because pci address space and local address space are 1:1
mapped. BAR0 inbound translation + ATMU translation will complete the address
translation of inbound traffic.

Signed-off-by: Bharat Bhushan <address@hidden>
---
 hw/pci_host.h    |    1 +
 hw/ppce500_pci.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..0ec0691 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -36,6 +36,7 @@ struct PCIHostState {
     MemoryRegion data_mem;
     MemoryRegion mmcfg;
     MemoryRegion *address_space;
+    MemoryRegion bar0;
     uint32_t config_reg;
     PCIBus *bus;
 };
diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c
index 0f60b24..7e58a62 100644
--- a/hw/ppce500_pci.c
+++ b/hw/ppce500_pci.c
@@ -306,6 +306,7 @@ static int e500_pcihost_initfn(SysBusDevice *dev)
     PCIHostState *h;
     PPCE500PCIState *s;
     PCIBus *b;
+    PCIDevice *pdev;
     int i;
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *address_space_io = get_system_io();
@@ -336,6 +337,10 @@ static int e500_pcihost_initfn(SysBusDevice *dev)
     memory_region_add_subregion(&s->container, PCIE500_REG_BASE, &s->iomem);
     sysbus_init_mmio(dev, &s->container);
 
+    memory_region_init_io(&h->bar0, &pci_host_conf_be_ops, h,
+                          "PCIHOST-bar0", 0x1000000);
+    pdev = pci_find_device(b, 0, 0);
+    pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &h->bar0);
     return 0;
 }
 
-- 
1.7.0.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]