Skip to content

Commit 0717855

Browse files
gkurzmdroth
authored andcommitted
Revert "spapr_pci: map the MSI window in each PHB"
This patch is predicated on cc943c, which was dropped from stable tree for other reasons. This reverts commit 0824ca6. Signed-off-by: Michael Roth <[email protected]>
1 parent 3cb451e commit 0717855

File tree

4 files changed

+33
-25
lines changed

4 files changed

+33
-25
lines changed

hw/ppc/spapr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ static void ppc_spapr_init(MachineState *machine)
13771377
spapr_create_nvram(spapr);
13781378

13791379
/* Set up PCI */
1380+
spapr_pci_msi_init(spapr, SPAPR_PCI_MSI_WINDOW);
13801381
spapr_pci_rtas_init();
13811382

13821383
phb = spapr_create_phb(spapr, 0);

hw/ppc/spapr_pci.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
341341
}
342342

343343
/* Setup MSI/MSIX vectors in the device (via cfgspace or MSIX BAR) */
344-
spapr_msi_setmsg(pdev, SPAPR_PCI_MSI_WINDOW, ret_intr_type == RTAS_TYPE_MSIX,
344+
spapr_msi_setmsg(pdev, spapr->msi_win_addr, ret_intr_type == RTAS_TYPE_MSIX,
345345
irq, req_num);
346346

347347
/* Add MSI device to cache */
@@ -465,6 +465,34 @@ static const MemoryRegionOps spapr_msi_ops = {
465465
.endianness = DEVICE_LITTLE_ENDIAN
466466
};
467467

468+
void spapr_pci_msi_init(sPAPREnvironment *spapr, hwaddr addr)
469+
{
470+
uint64_t window_size = 4096;
471+
472+
/*
473+
* As MSI/MSIX interrupts trigger by writing at MSI/MSIX vectors,
474+
* we need to allocate some memory to catch those writes coming
475+
* from msi_notify()/msix_notify().
476+
* As MSIMessage:addr is going to be the same and MSIMessage:data
477+
* is going to be a VIRQ number, 4 bytes of the MSI MR will only
478+
* be used.
479+
*
480+
* For KVM we want to ensure that this memory is a full page so that
481+
* our memory slot is of page size granularity.
482+
*/
483+
#ifdef CONFIG_KVM
484+
if (kvm_enabled()) {
485+
window_size = getpagesize();
486+
}
487+
#endif
488+
489+
spapr->msi_win_addr = addr;
490+
memory_region_init_io(&spapr->msiwindow, NULL, &spapr_msi_ops, spapr,
491+
"msi", window_size);
492+
memory_region_add_subregion(get_system_memory(), spapr->msi_win_addr,
493+
&spapr->msiwindow);
494+
}
495+
468496
/*
469497
* PHB PCI device
470498
*/
@@ -484,7 +512,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
484512
char *namebuf;
485513
int i;
486514
PCIBus *bus;
487-
uint64_t msi_window_size = 4096;
488515

489516
if (sphb->index != -1) {
490517
hwaddr windows_base;
@@ -577,28 +604,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
577604
address_space_init(&sphb->iommu_as, &sphb->iommu_root,
578605
sphb->dtbusname);
579606

580-
/*
581-
* As MSI/MSIX interrupts trigger by writing at MSI/MSIX vectors,
582-
* we need to allocate some memory to catch those writes coming
583-
* from msi_notify()/msix_notify().
584-
* As MSIMessage:addr is going to be the same and MSIMessage:data
585-
* is going to be a VIRQ number, 4 bytes of the MSI MR will only
586-
* be used.
587-
*
588-
* For KVM we want to ensure that this memory is a full page so that
589-
* our memory slot is of page size granularity.
590-
*/
591-
#ifdef CONFIG_KVM
592-
if (kvm_enabled()) {
593-
msi_window_size = getpagesize();
594-
}
595-
#endif
596-
597-
memory_region_init_io(&sphb->msiwindow, NULL, &spapr_msi_ops, spapr,
598-
"msi", msi_window_size);
599-
memory_region_add_subregion(&sphb->iommu_root, SPAPR_PCI_MSI_WINDOW,
600-
&sphb->msiwindow);
601-
602607
pci_setup_iommu(bus, spapr_pci_dma_iommu, sphb);
603608

604609
pci_bus_set_route_irq_fn(bus, spapr_route_intx_pin_to_irq);

include/hw/pci-host/spapr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct sPAPRPHBState {
7070

7171
MemoryRegion memspace, iospace;
7272
hwaddr mem_win_addr, mem_win_size, io_win_addr, io_win_size;
73-
MemoryRegion memwindow, iowindow, msiwindow;
73+
MemoryRegion memwindow, iowindow;
7474

7575
uint32_t dma_liobn;
7676
AddressSpace iommu_as;

include/hw/ppc/spapr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct sPAPRNVRAM;
1313
typedef struct sPAPREnvironment {
1414
struct VIOsPAPRBus *vio_bus;
1515
QLIST_HEAD(, sPAPRPHBState) phbs;
16+
hwaddr msi_win_addr;
17+
MemoryRegion msiwindow;
1618
struct sPAPRNVRAM *nvram;
1719
XICSState *icp;
1820

0 commit comments

Comments
 (0)