WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 08/11] VT-d: cleanup ATS code

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 08/11] VT-d: cleanup ATS code
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Wed, 09 Mar 2011 12:29:25 +0000
Delivery-date: Wed, 09 Mar 2011 04:36:48 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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>

--- 2011-01-17.orig/xen/drivers/passthrough/vtd/extern.h
+++ 2011-01-17/xen/drivers/passthrough/vtd/extern.h
@@ -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(unsigned 
 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 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 *);
--- 2011-01-17.orig/xen/drivers/passthrough/vtd/ia64/Makefile
+++ 2011-01-17/xen/drivers/passthrough/vtd/ia64/Makefile
@@ -1,2 +1 @@
 obj-y += vtd.o
-obj-y += ats.o
--- 2011-01-17.orig/xen/drivers/passthrough/vtd/ia64/ats.c
+++ /dev/null
@@ -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;
-}
--- 2011-01-17.orig/xen/drivers/passthrough/vtd/x86/Makefile
+++ 2011-01-17/xen/drivers/passthrough/vtd/x86/Makefile
@@ -1,2 +1,2 @@
 obj-y += vtd.o
-obj-y += ats.o
+obj-$(CONFIG_X86_64) += ats.o
--- 2011-01-17.orig/xen/drivers/passthrough/vtd/x86/ats.c
+++ 2011-01-17/xen/drivers/passthrough/vtd/x86/ats.c
@@ -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,


Attachment: vtd-ats-cleanup.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 08/11] VT-d: cleanup ATS code, Jan Beulich <=