PCI: break MSI-X data out of struct pci_dev_info
PATCH 1/1 PCI: break MSI-X data out of struct pci_dev_info
Considering that a significant share of PCI devices out there (not the least the myriad of CPU-exposed ones) don't support MSI-X at all, and that the amount of data is well beyond a handful of bytes, break this out of the common structure, at once allowing the actual data to be tracked to become architecture specific.
xen/arch/x86/hvm/vmsi.c +1 -1
@@ -199,7 +199,7 @@ static void __iomem *msixtbl_addr_to_vir nr_page = (addr >>PAGE_SHIFT ) - (entry->gtable >>PAGE_SHIFT ); - idx = entry->pdev->msix_table_idx[nr_page]; + idx = entry->pdev->msix->table_idx[nr_page];if ( !idx )return NULL ;
xen/arch/x86/msi.c +51 -50
225 lines not on this page · raw message
xen/drivers/passthrough/pci.c +16 -1
@@ -179,8 +179,22 @@ static struct pci_dev *alloc_pdev(struct *((u8 *) &pdev->devfn) = devfn; pdev->domain =NULL ;INIT_LIST_HEAD (&pdev->msi_list); + +if (pci_find_cap_offset (pseg->nr, bus,PCI_SLOT (devfn),PCI_FUNC (devfn), +PCI_CAP_ID_MSIX ) ) + { + struct arch_msix *msix = xzalloc(struct arch_msix); + +if ( !msix ) + { +xfree (pdev); +return NULL ; + } +spin_lock_init (&msix->table_lock); + pdev->msix = msix; + } +list_add (&pdev->alldevs_list, &pseg->alldevs_list); -spin_lock_init (&pdev->msix_table_lock);/* update bus2bridge */ switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) )
@@ -277,6 +291,7 @@ static void free_pdev(struct pci_seg *ps }list_del (&pdev->alldevs_list); +xfree (pdev->msix);xfree (pdev); }
xen/include/asm-x86/msi.h +16 -0
@@ -214,6 +214,22 @@ struct msg_address {__u32 hi_address; } __attribute__ ((packed)); +#define MAX_MSIX_TABLE_ENTRIES (PCI_MSIX_FLAGS_QSIZE + 1) +#define MAX_MSIX_TABLE_PAGES PFN_UP(MAX_MSIX_TABLE_ENTRIES * \ + PCI_MSIX_ENTRY_SIZE + \ + (~PCI_MSIX_BIRMASK & (PAGE_SIZE - 1))) + +struct arch_msix { +unsigned int nr_entries, used_entries; +struct { +unsigned long first, last; + } table, pba; +int table_refcnt[MAX_MSIX_TABLE_PAGES ]; +int table_idx[MAX_MSIX_TABLE_PAGES ]; +spinlock_t table_lock; +domid_t warned; +}; +void early_msi_init (void );void msi_compose_msg (struct irq_desc *,struct msi_msg *);void __msi_set_enable (u16 seg,u8 bus,u8 slot,u8 func,int pos,int enable);
xen/include/xen/pci.h +2 -12
@@ -32,10 +32,6 @@#define PCI_BDF (b,d,f) ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))#define PCI_BDF2 (b,df) ((((b) & 0xff) << 8) | ((df) & 0xff)) -#define MAX_MSIX_TABLE_ENTRIES (PCI_MSIX_FLAGS_QSIZE + 1) -#define MAX_MSIX_TABLE_PAGES PFN_UP(MAX_MSIX_TABLE_ENTRIES * \ - PCI_MSIX_ENTRY_SIZE + \ - (~PCI_MSIX_BIRMASK & (PAGE_SIZE - 1)))struct pci_dev_info {bool_t is_extfn;bool_t is_virtfn;
@@ -50,14 +46,8 @@ struct pci_dev {struct list_head domain_list;struct list_head msi_list; -unsigned int msix_nr_entries, msix_used_entries; -struct { -unsigned long first, last; - } msix_table, msix_pba; -int msix_table_refcnt[MAX_MSIX_TABLE_PAGES ]; -int msix_table_idx[MAX_MSIX_TABLE_PAGES ]; -spinlock_t msix_table_lock; -domid_t msix_warned; + +struct arch_msix *msix;struct domain *domain;const u16 seg;
PCI: break MSI-X data out of struct pci_dev_info
Considering that a significant share of PCI devices out there (not the least the myriad of CPU-exposed ones) don't support MSI-X at all, and that the amount of data is well beyond a handful of bytes, break this out of the common structure, at once allowing the actual data to be tracked to become architecture specific.
xen/arch/x86/hvm/vmsi.c +1 -1
@@ -199,7 +199,7 @@ static void __iomem *msixtbl_addr_to_vir nr_page = (addr >>PAGE_SHIFT ) - (entry->gtable >>PAGE_SHIFT ); - idx = entry->pdev->msix_table_idx[nr_page]; + idx = entry->pdev->msix->table_idx[nr_page];if ( !idx )return NULL ;
xen/arch/x86/msi.c +51 -50
225 lines not on this page · raw message
xen/drivers/passthrough/pci.c +16 -1
@@ -179,8 +179,22 @@ static struct pci_dev *alloc_pdev(struct *((u8 *) &pdev->devfn) = devfn; pdev->domain =NULL ;INIT_LIST_HEAD (&pdev->msi_list); + +if (pci_find_cap_offset (pseg->nr, bus,PCI_SLOT (devfn),PCI_FUNC (devfn), +PCI_CAP_ID_MSIX ) ) + { + struct arch_msix *msix = xzalloc(struct arch_msix); + +if ( !msix ) + { +xfree (pdev); +return NULL ; + } +spin_lock_init (&msix->table_lock); + pdev->msix = msix; + } +list_add (&pdev->alldevs_list, &pseg->alldevs_list); -spin_lock_init (&pdev->msix_table_lock);/* update bus2bridge */ switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) )
@@ -277,6 +291,7 @@ static void free_pdev(struct pci_seg *ps }list_del (&pdev->alldevs_list); +xfree (pdev->msix);xfree (pdev); }
xen/include/asm-x86/msi.h +16 -0
@@ -214,6 +214,22 @@ struct msg_address {__u32 hi_address; } __attribute__ ((packed)); +#define MAX_MSIX_TABLE_ENTRIES (PCI_MSIX_FLAGS_QSIZE + 1) +#define MAX_MSIX_TABLE_PAGES PFN_UP(MAX_MSIX_TABLE_ENTRIES * \ + PCI_MSIX_ENTRY_SIZE + \ + (~PCI_MSIX_BIRMASK & (PAGE_SIZE - 1))) + +struct arch_msix { +unsigned int nr_entries, used_entries; +struct { +unsigned long first, last; + } table, pba; +int table_refcnt[MAX_MSIX_TABLE_PAGES ]; +int table_idx[MAX_MSIX_TABLE_PAGES ]; +spinlock_t table_lock; +domid_t warned; +}; +void early_msi_init (void );void msi_compose_msg (struct irq_desc *,struct msi_msg *);void __msi_set_enable (u16 seg,u8 bus,u8 slot,u8 func,int pos,int enable);
xen/include/xen/pci.h +2 -12
@@ -32,10 +32,6 @@#define PCI_BDF (b,d,f) ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))#define PCI_BDF2 (b,df) ((((b) & 0xff) << 8) | ((df) & 0xff)) -#define MAX_MSIX_TABLE_ENTRIES (PCI_MSIX_FLAGS_QSIZE + 1) -#define MAX_MSIX_TABLE_PAGES PFN_UP(MAX_MSIX_TABLE_ENTRIES * \ - PCI_MSIX_ENTRY_SIZE + \ - (~PCI_MSIX_BIRMASK & (PAGE_SIZE - 1)))struct pci_dev_info {bool_t is_extfn;bool_t is_virtfn;
@@ -50,14 +46,8 @@ struct pci_dev {struct list_head domain_list;struct list_head msi_list; -unsigned int msix_nr_entries, msix_used_entries; -struct { -unsigned long first, last; - } msix_table, msix_pba; -int msix_table_refcnt[MAX_MSIX_TABLE_PAGES ]; -int msix_table_idx[MAX_MSIX_TABLE_PAGES ]; -spinlock_t msix_table_lock; -domid_t msix_warned; + +struct arch_msix *msix;struct domain *domain;const u16 seg;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Considering that a significant share of PCI devices out there (not the least the myriad of CPU-exposed ones) don't support MSI-X at all, and that the amount of data is well beyond a handful of bytes, break this out of the common structure, at once allowing the actual data to be tracked to become architecture specific.
Signed-off-by Jan Beulich <[email protected]>