VT-d: cleanup ATS code
PATCH 8/11 VT-d: cleanup ATS code
Rather than having per-architecture stubs when ATS support is not implemented, simply provide inline functions in the common header for that case.
Signed-off-by Jan Beulich <[email protected]>
xen/drivers/passthrough/vtd/extern.h +36 -4
@@ -24,7 +24,6 @@#include "dmar.h" #include <xen/keyhandler.h> -extern bool_t ats_enabled;extern bool_t rwbf_quirk;void print_iommu_regs (struct acpi_drhd_unit *drhd);
@@ -56,17 +55,50 @@ struct iommu * ioapic_to_iommu(unsignedstruct acpi_drhd_unit *ioapic_to_drhd (unsigned int apic_id);struct acpi_drhd_unit *iommu_to_drhd (struct iommu *iommu);struct acpi_rhsa_unit *drhd_to_rhsa (struct acpi_drhd_unit *drhd); + +#ifdef CONFIG_X86_64 +extern bool_t ats_enabled; +struct acpi_drhd_unit *find_ats_dev_drhd (struct iommu *iommu);int ats_device (int seg,int bus,int devfn);int enable_ats_device (int seg,int bus,int devfn); -int disable_ats_device (int seg,int bus,int devfn); +void disable_ats_device (int seg,int bus,int devfn);int invalidate_ats_tcs (struct iommu *iommu); -int qinval_device_iotlb (struct iommu *iommu, -u32 max_invs_pend,u16 sid,u16 size,u64 addr);int dev_invalidate_iotlb (struct iommu *iommu,u16 did,u64 addr,unsigned int size_order,u64 type); +#else +#define ats_enabled 0 + +static inline struct acpi_drhd_unit *find_ats_dev_drhd (struct iommu *iommu) +{ +return NULL ; +} + +static inline int ats_device (int seg,int bus,int devfn) +{ +return 0 ; +} +static inline int enable_ats_device (int seg,int bus,int devfn) +{ +BUG (); +return -ENOSYS ; +} +static inline void disable_ats_device (int seg,int bus,int devfn) +{ +BUG (); +} + +static inline int dev_invalidate_iotlb (struct iommu *iommu,u16 did,u64 addr, +unsigned int size_order,u64 type) +{ +return 0 ; +} +#endif + +int qinval_device_iotlb (struct iommu *iommu, +u32 max_invs_pend,u16 sid,u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);
xen/drivers/passthrough/vtd/ia64/Makefile +0 -1
@@ -1,2 +1 @@ obj-y += vtd.o -obj-y += ats.o
xen/drivers/passthrough/vtd/ia64/ats.c deleted +0 -59
59 lines not on this page · raw message
xen/drivers/passthrough/vtd/x86/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y += vtd.o -obj-y += ats.o +obj-$(CONFIG_X86_64) += ats.o
xen/drivers/passthrough/vtd/x86/ats.c +8 -28
@@ -127,23 +127,11 @@ int enable_ats_device(int seg, int bus,u32 value;int pos; -if ( !acpi_find_matched_atsr_unit (bus, devfn) ) - { - dprintk(XENLOG_WARNING VTDPREFIX, -"cannot find matched atsr for %x:%x.%x\n" , - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -return 0 ; - } - pos =pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS ); -if ( !pos ) - { - dprintk(XENLOG_ERR VTDPREFIX, "ats capability not found %x:%x.%x\n", - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -return 0 ; - } -else - dprintk(XENLOG_ERR VTDPREFIX, "ats capability found %x:%x.%x\n", +BUG_ON (!pos); + +if ( iommu_verbose ) + dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS capability found\n", bus,PCI_SLOT (devfn),PCI_FUNC (devfn));/* BUGBUG: add back seg when multi-seg platform support is enabled */
@@ -189,16 +177,14 @@ int enable_ats_device(int seg, int bus,return pos; } -int disable_ats_device (int seg,int bus,int devfn) +void disable_ats_device (int seg,int bus,int devfn) { -struct list_head *pdev_list, *tmp;struct pci_ats_dev *pdev;u32 value;int pos; pos =pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS ); -if ( !pos ) -return 0 ; +BUG_ON (!pos);/* BUGBUG: add back seg when multi-seg platform support is enabled */ value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -207,9 +193,8 @@ int disable_ats_device(int seg, int bus,pci_conf_write16 (bus,PCI_SLOT (devfn),PCI_FUNC (devfn), pos +ATS_REG_CTL , value); -list_for_each_safe ( pdev_list, tmp, &ats_devices ) + list_for_each_entry ( pdev, &ats_devices, list ) { - pdev = list_entry(pdev_list, struct pci_ats_dev, list);if ( pdev->bus == bus && pdev->devfn == devfn ) {list_del (&pdev->list);
@@ -221,8 +206,6 @@ int disable_ats_device(int seg, int bus,if ( iommu_verbose ) dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS is disabled\n", bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); - -return 0 ; }
@@ -257,10 +240,7 @@ out:if ( ctxt_entry )unmap_vtd_domain_page (ctxt_entry); -if ( found ) -return 1 ; - -return 0 ; +return found; } int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
Rather than having per-architecture stubs when ATS support is not implemented, simply provide inline functions in the common header for that case.
Signed-off-by Jan Beulich <[email protected]>
xen/drivers/passthrough/vtd/extern.h +36 -4
@@ -24,7 +24,6 @@#include "dmar.h" #include <xen/keyhandler.h> -extern bool_t ats_enabled;extern bool_t rwbf_quirk;void print_iommu_regs (struct acpi_drhd_unit *drhd);
@@ -56,17 +55,50 @@ struct iommu * ioapic_to_iommu(unsignedstruct acpi_drhd_unit *ioapic_to_drhd (unsigned int apic_id);struct acpi_drhd_unit *iommu_to_drhd (struct iommu *iommu);struct acpi_rhsa_unit *drhd_to_rhsa (struct acpi_drhd_unit *drhd); + +#ifdef CONFIG_X86_64 +extern bool_t ats_enabled; +struct acpi_drhd_unit *find_ats_dev_drhd (struct iommu *iommu);int ats_device (int seg,int bus,int devfn);int enable_ats_device (int seg,int bus,int devfn); -int disable_ats_device (int seg,int bus,int devfn); +void disable_ats_device (int seg,int bus,int devfn);int invalidate_ats_tcs (struct iommu *iommu); -int qinval_device_iotlb (struct iommu *iommu, -u32 max_invs_pend,u16 sid,u16 size,u64 addr);int dev_invalidate_iotlb (struct iommu *iommu,u16 did,u64 addr,unsigned int size_order,u64 type); +#else +#define ats_enabled 0 + +static inline struct acpi_drhd_unit *find_ats_dev_drhd (struct iommu *iommu) +{ +return NULL ; +} + +static inline int ats_device (int seg,int bus,int devfn) +{ +return 0 ; +} +static inline int enable_ats_device (int seg,int bus,int devfn) +{ +BUG (); +return -ENOSYS ; +} +static inline void disable_ats_device (int seg,int bus,int devfn) +{ +BUG (); +} + +static inline int dev_invalidate_iotlb (struct iommu *iommu,u16 did,u64 addr, +unsigned int size_order,u64 type) +{ +return 0 ; +} +#endif + +int qinval_device_iotlb (struct iommu *iommu, +u32 max_invs_pend,u16 sid,u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);
xen/drivers/passthrough/vtd/ia64/Makefile +0 -1
@@ -1,2 +1 @@ obj-y += vtd.o -obj-y += ats.o
xen/drivers/passthrough/vtd/ia64/ats.c deleted +0 -59
59 lines not on this page · raw message
xen/drivers/passthrough/vtd/x86/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y += vtd.o -obj-y += ats.o +obj-$(CONFIG_X86_64) += ats.o
xen/drivers/passthrough/vtd/x86/ats.c +8 -28
@@ -127,23 +127,11 @@ int enable_ats_device(int seg, int bus,u32 value;int pos; -if ( !acpi_find_matched_atsr_unit (bus, devfn) ) - { - dprintk(XENLOG_WARNING VTDPREFIX, -"cannot find matched atsr for %x:%x.%x\n" , - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -return 0 ; - } - pos =pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS ); -if ( !pos ) - { - dprintk(XENLOG_ERR VTDPREFIX, "ats capability not found %x:%x.%x\n", - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); -return 0 ; - } -else - dprintk(XENLOG_ERR VTDPREFIX, "ats capability found %x:%x.%x\n", +BUG_ON (!pos); + +if ( iommu_verbose ) + dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS capability found\n", bus,PCI_SLOT (devfn),PCI_FUNC (devfn));/* BUGBUG: add back seg when multi-seg platform support is enabled */
@@ -189,16 +177,14 @@ int enable_ats_device(int seg, int bus,return pos; } -int disable_ats_device (int seg,int bus,int devfn) +void disable_ats_device (int seg,int bus,int devfn) { -struct list_head *pdev_list, *tmp;struct pci_ats_dev *pdev;u32 value;int pos; pos =pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS ); -if ( !pos ) -return 0 ; +BUG_ON (!pos);/* BUGBUG: add back seg when multi-seg platform support is enabled */ value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -207,9 +193,8 @@ int disable_ats_device(int seg, int bus,pci_conf_write16 (bus,PCI_SLOT (devfn),PCI_FUNC (devfn), pos +ATS_REG_CTL , value); -list_for_each_safe ( pdev_list, tmp, &ats_devices ) + list_for_each_entry ( pdev, &ats_devices, list ) { - pdev = list_entry(pdev_list, struct pci_ats_dev, list);if ( pdev->bus == bus && pdev->devfn == devfn ) {list_del (&pdev->list);
@@ -221,8 +206,6 @@ int disable_ats_device(int seg, int bus,if ( iommu_verbose ) dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS is disabled\n", bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); - -return 0 ; }
@@ -257,10 +240,7 @@ out:if ( ctxt_entry )unmap_vtd_domain_page (ctxt_entry); -if ( found ) -return 1 ; - -return 0 ; +return found; } int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel