@@ -341,7 +341,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
341
341
}
342
342
343
343
/* 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 ,
345
345
irq , req_num );
346
346
347
347
/* Add MSI device to cache */
@@ -465,6 +465,34 @@ static const MemoryRegionOps spapr_msi_ops = {
465
465
.endianness = DEVICE_LITTLE_ENDIAN
466
466
};
467
467
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
+
468
496
/*
469
497
* PHB PCI device
470
498
*/
@@ -484,7 +512,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
484
512
char * namebuf ;
485
513
int i ;
486
514
PCIBus * bus ;
487
- uint64_t msi_window_size = 4096 ;
488
515
489
516
if (sphb -> index != -1 ) {
490
517
hwaddr windows_base ;
@@ -577,28 +604,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
577
604
address_space_init (& sphb -> iommu_as , & sphb -> iommu_root ,
578
605
sphb -> dtbusname );
579
606
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
-
602
607
pci_setup_iommu (bus , spapr_pci_dma_iommu , sphb );
603
608
604
609
pci_bus_set_route_irq_fn (bus , spapr_route_intx_pin_to_irq );
0 commit comments