mirrored from git://xenbits.xen.org/xen.git
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xen/pci: Refactor MSI code that implements MSI functionality within XEN
On Arm, the initial plan is to only support GICv3 ITS which doesn't require us to manage the MSIs because the HW will protect against spoofing. Move the code under CONFIG_HAS_PCI_MSI flag to gate the code for ARM. No functional change intended. Signed-off-by: Rahul Singh <rahul.singh@arm.com> Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Acked-by: Jan Beulich <jbeulich@suse.com>
- Loading branch information
Showing
7 changed files
with
149 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <xen/init.h> | ||
#include <xen/pci.h> | ||
#include <xen/msi.h> | ||
#include <asm/hvm/io.h> | ||
|
||
int pdev_msix_assign(struct domain *d, struct pci_dev *pdev) | ||
{ | ||
int rc; | ||
|
||
if ( pdev->msix ) | ||
{ | ||
rc = pci_reset_msix_state(pdev); | ||
if ( rc ) | ||
return rc; | ||
msixtbl_init(d); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int pdev_msi_init(struct pci_dev *pdev) | ||
{ | ||
unsigned int pos; | ||
|
||
INIT_LIST_HEAD(&pdev->msi_list); | ||
|
||
pos = pci_find_cap_offset(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), | ||
PCI_FUNC(pdev->devfn), PCI_CAP_ID_MSI); | ||
if ( pos ) | ||
{ | ||
uint16_t ctrl = pci_conf_read16(pdev->sbdf, msi_control_reg(pos)); | ||
|
||
pdev->msi_maxvec = multi_msi_capable(ctrl); | ||
} | ||
|
||
pos = pci_find_cap_offset(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), | ||
PCI_FUNC(pdev->devfn), PCI_CAP_ID_MSIX); | ||
if ( pos ) | ||
{ | ||
struct arch_msix *msix = xzalloc(struct arch_msix); | ||
uint16_t ctrl; | ||
|
||
if ( !msix ) | ||
return -ENOMEM; | ||
|
||
spin_lock_init(&msix->table_lock); | ||
|
||
ctrl = pci_conf_read16(pdev->sbdf, msix_control_reg(pos)); | ||
msix->nr_entries = msix_table_size(ctrl); | ||
|
||
pdev->msix = msix; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void pdev_msi_deinit(struct pci_dev *pdev) | ||
{ | ||
XFREE(pdev->msix); | ||
} | ||
|
||
void pdev_dump_msi(const struct pci_dev *pdev) | ||
{ | ||
const struct msi_desc *msi; | ||
|
||
if ( list_empty(&pdev->msi_list) ) | ||
return; | ||
|
||
printk(" - MSIs < "); | ||
list_for_each_entry ( msi, &pdev->msi_list, list ) | ||
printk("%d ", msi->irq); | ||
printk(">"); | ||
} | ||
|
||
/* | ||
* Local variables: | ||
* mode: C | ||
* c-file-style: "BSD" | ||
* c-basic-offset: 4 | ||
* tab-width: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
|
||
config HAS_PCI | ||
bool | ||
|
||
config HAS_PCI_MSI | ||
bool | ||
depends on HAS_PCI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef __XEN_MSI_H_ | ||
#define __XEN_MSI_H_ | ||
|
||
#include <xen/pci.h> | ||
|
||
#ifdef CONFIG_HAS_PCI_MSI | ||
|
||
#include <asm/msi.h> | ||
|
||
int pdev_msix_assign(struct domain *d, struct pci_dev *pdev); | ||
int pdev_msi_init(struct pci_dev *pdev); | ||
void pdev_msi_deinit(struct pci_dev *pdev); | ||
void pdev_dump_msi(const struct pci_dev *pdev); | ||
|
||
#else /* !CONFIG_HAS_PCI_MSI */ | ||
|
||
static inline int pdev_msix_assign(struct domain *d, struct pci_dev *pdev) | ||
{ | ||
return 0; | ||
} | ||
|
||
static inline int pdev_msi_init(struct pci_dev *pdev) | ||
{ | ||
return 0; | ||
} | ||
|
||
static inline void pdev_msi_deinit(struct pci_dev *pdev) {} | ||
static inline void pci_cleanup_msi(struct pci_dev *pdev) {} | ||
static inline void pdev_dump_msi(const struct pci_dev *pdev) {} | ||
|
||
#endif /* CONFIG_HAS_PCI_MSI */ | ||
|
||
#endif /* __XEN_MSI_H */ | ||
|
||
/* | ||
* Local variables: | ||
* mode: C | ||
* c-file-style: "BSD" | ||
* c-basic-offset: 4 | ||
* tab-width: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters