# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxxxx>
# Date 1299688192 0
# Node ID 71dae1b6417b18616598e72f23a8ed9e22e517c5
# Parent ba1685bc3ebfeecda9a77e87e2bdce3c06cfa225
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 <jbeulich@xxxxxxxxxx>
---
diff -r ba1685bc3ebf -r 71dae1b6417b xen/drivers/passthrough/vtd/extern.h
--- a/xen/drivers/passthrough/vtd/extern.h Wed Mar 09 16:28:58 2011 +0000
+++ b/xen/drivers/passthrough/vtd/extern.h Wed Mar 09 16:29:52 2011 +0000
@@ -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 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 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);
-int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
- u64 addr, unsigned int size_order, u64 type);
unsigned int get_cache_line_size(void);
void cacheline_flush(char *);
diff -r ba1685bc3ebf -r 71dae1b6417b xen/drivers/passthrough/vtd/ia64/Makefile
--- a/xen/drivers/passthrough/vtd/ia64/Makefile Wed Mar 09 16:28:58 2011 +0000
+++ b/xen/drivers/passthrough/vtd/ia64/Makefile Wed Mar 09 16:29:52 2011 +0000
@@ -1,2 +1,1 @@
obj-y += vtd.o
-obj-y += ats.o
diff -r ba1685bc3ebf -r 71dae1b6417b xen/drivers/passthrough/vtd/ia64/ats.c
--- a/xen/drivers/passthrough/vtd/ia64/ats.c Wed Mar 09 16:28:58 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2006, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Author: Allen Kay <allen.m.kay@xxxxxxxxx>
- */
-
-#include <xen/sched.h>
-#include <xen/iommu.h>
-#include <xen/time.h>
-#include <xen/pci.h>
-#include <xen/pci_regs.h>
-#include <asm/msi.h>
-#include "../iommu.h"
-#include "../dmar.h"
-#include "../vtd.h"
-#include "../extern.h"
-
-struct pci_ats_dev;
-
-bool_t __read_mostly ats_enabled = 0;
-
-struct acpi_drhd_unit * find_ats_dev_drhd(struct iommu *iommu)
-{
- return NULL;
-}
-
-int ats_device(int seg, int bus, int devfn)
-{
- return 0;
-}
-
-int enable_ats_device(int seg, int bus, int devfn)
-{
- return 0;
-}
-
-int disable_ats_device(int seg, int bus, int devfn)
-{
- return 0;
-}
-
-int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
- u64 addr, unsigned int size_order, u64 type)
-{
- return 0;
-}
diff -r ba1685bc3ebf -r 71dae1b6417b xen/drivers/passthrough/vtd/x86/Makefile
--- a/xen/drivers/passthrough/vtd/x86/Makefile Wed Mar 09 16:28:58 2011 +0000
+++ b/xen/drivers/passthrough/vtd/x86/Makefile Wed Mar 09 16:29:52 2011 +0000
@@ -1,2 +1,2 @@
obj-y += vtd.o
-obj-y += ats.o
+obj-$(CONFIG_X86_64) += ats.o
diff -r ba1685bc3ebf -r 71dae1b6417b xen/drivers/passthrough/vtd/x86/ats.c
--- a/xen/drivers/passthrough/vtd/x86/ats.c Wed Mar 09 16:28:58 2011 +0000
+++ b/xen/drivers/passthrough/vtd/x86/ats.c Wed Mar 09 16:29:52 2011 +0000
@@ -127,23 +127,11 @@
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);
+ BUG_ON(!pos);
- 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",
+ 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 @@
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 @@
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 @@
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 @@
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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|