diff options
author | Bertrand Marquis <bertrand.marquis@arm.com> | 2021-10-15 17:51:41 +0100 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@xilinx.com> | 2021-10-15 11:21:54 -0700 |
commit | be4eefbce6cada21b8a17354c1f11d7865d9a603 (patch) | |
tree | eb454e9bd48b88105f8de30c2b9642a8efc84e8b /xen/include | |
parent | f791392f82ffe39cc1ea4c4db1d877223754a04a (diff) |
xen/vpci: Move ecam access functions to common code
PCI standard is using ECAM and not MCFG which is coming from ACPI[1].
Use ECAM/ecam instead of MCFG in common code and in new functions added
in common vpci code by this patch.
Move vpci_access_allowed from arch/x86/hvm/io.c to drivers/vpci/vpci.c.
Create vpci_ecam_{read,write} in drivers/vpci/vpci.c that
contains the common code to perform these operations, changed
vpci_mmcfg_{read,write} accordingly to make use of these functions.
The vpci_ecam_{read,write} functions are returning false on error and
true on success. As the x86 code was previously always returning
X86EMUL_OKAY the return code is ignored. A comment has been added in
the code to show that this is intentional.
Those functions will be used in a following patch inside by arm vpci
implementation.
Rename MMCFG_BDF to VPCI_ECAM_BDF and move it to vpci.h.
This macro is only used by functions calling vpci_ecam helpers.
No functional change intended with this patch.
[1] https://wiki.osdev.org/PCI_Express
Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'xen/include')
-rw-r--r-- | xen/include/asm-x86/pci.h | 2 | ||||
-rw-r--r-- | xen/include/xen/vpci.h | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/xen/include/asm-x86/pci.h b/xen/include/asm-x86/pci.h index edd7c3e71a..443f25347d 100644 --- a/xen/include/asm-x86/pci.h +++ b/xen/include/asm-x86/pci.h @@ -6,8 +6,6 @@ #define CF8_ADDR_HI(cf8) ( ((cf8) & 0x0f000000) >> 16) #define CF8_ENABLED(cf8) (!!((cf8) & 0x80000000)) -#define MMCFG_BDF(addr) ( ((addr) & 0x0ffff000) >> 12) - #define IS_SNB_GFX(id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \ diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 9f5b5d52e1..6746c2589a 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -19,6 +19,8 @@ typedef int vpci_register_init_t(struct pci_dev *dev); #define VPCI_PRIORITY_MIDDLE "5" #define VPCI_PRIORITY_LOW "9" +#define VPCI_ECAM_BDF(addr) (((addr) & 0x0ffff000) >> 12) + #define REGISTER_VPCI_INIT(x, p) \ static vpci_register_init_t *const x##_entry \ __used_section(".data.vpci." p) = x @@ -208,6 +210,16 @@ static inline unsigned int vmsix_entry_nr(const struct vpci_msix *msix, { return entry - msix->entries; } + +bool vpci_access_allowed(unsigned int reg, unsigned int len); + +/* ECAM mmio read/write helpers */ +bool vpci_ecam_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len, + unsigned long data); + +bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int len, + unsigned long *data); + #endif /* __XEN__ */ #else /* !CONFIG_HAS_VPCI */ |