[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] pci: move ATS code to common directory



commit b4c3d45c26d22490c08872596fcd1f8db9153dfc
Author:     Rahul Singh <rahul.singh@xxxxxxx>
AuthorDate: Fri Apr 9 09:22:26 2021 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Apr 9 09:22:26 2021 +0200

    pci: move ATS code to common directory
    
    PCI ATS code is common for all architecture, move code to common
    directory to be usable for other architectures.
    
    No functional change intended.
    
    Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
---
 xen/drivers/passthrough/Makefile     |  1 +
 xen/drivers/passthrough/ats.c        | 86 ++++++++++++++++++++++++++++++++++++
 xen/drivers/passthrough/x86/Makefile |  1 -
 xen/drivers/passthrough/x86/ats.c    | 86 ------------------------------------
 4 files changed, 87 insertions(+), 87 deletions(-)

diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Makefile
index cc646612c7..445690e3e5 100644
--- a/xen/drivers/passthrough/Makefile
+++ b/xen/drivers/passthrough/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_ARM) += arm/
 obj-y += iommu.o
 obj-$(CONFIG_HAS_PCI) += pci.o
 obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o
+obj-$(CONFIG_HAS_PCI) += ats.o
diff --git a/xen/drivers/passthrough/ats.c b/xen/drivers/passthrough/ats.c
new file mode 100644
index 0000000000..7f7b16dc49
--- /dev/null
+++ b/xen/drivers/passthrough/ats.c
@@ -0,0 +1,86 @@
+/*
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/param.h>
+#include <xen/sched.h>
+#include <xen/pci.h>
+#include <xen/pci_regs.h>
+#include "ats.h"
+
+bool_t __read_mostly ats_enabled = 0;
+boolean_param("ats", ats_enabled);
+
+int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list)
+{
+    u32 value;
+    u16 seg = pdev->seg;
+    u8 bus = pdev->bus, devfn = pdev->devfn;
+    int pos;
+
+    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
+    BUG_ON(!pos);
+
+    if ( iommu_verbose )
+        dprintk(XENLOG_INFO, "%pp: ATS capability found\n", &pdev->sbdf);
+
+    value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CTL);
+    if ( value & ATS_ENABLE )
+    {
+        struct pci_dev *other;
+
+        list_for_each_entry ( other, ats_list, ats.list )
+            if ( other == pdev )
+            {
+                pos = 0;
+                break;
+            }
+    }
+
+    if ( !(value & ATS_ENABLE) )
+    {
+        value |= ATS_ENABLE;
+        pci_conf_write16(pdev->sbdf, pos + ATS_REG_CTL, value);
+    }
+
+    if ( pos )
+    {
+        pdev->ats.cap_pos = pos;
+        value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CAP);
+        pdev->ats.queue_depth = value & ATS_QUEUE_DEPTH_MASK ?:
+                                ATS_QUEUE_DEPTH_MASK + 1;
+        list_add(&pdev->ats.list, ats_list);
+    }
+
+    if ( iommu_verbose )
+        dprintk(XENLOG_INFO, "%pp: ATS %s enabled\n",
+                &pdev->sbdf, pos ? "is" : "was");
+
+    return pos;
+}
+
+void disable_ats_device(struct pci_dev *pdev)
+{
+    u32 value;
+
+    BUG_ON(!pdev->ats.cap_pos);
+
+    value = pci_conf_read16(pdev->sbdf, pdev->ats.cap_pos + ATS_REG_CTL);
+    value &= ~ATS_ENABLE;
+    pci_conf_write16(pdev->sbdf, pdev->ats.cap_pos + ATS_REG_CTL, value);
+
+    list_del(&pdev->ats.list);
+
+    if ( iommu_verbose )
+        dprintk(XENLOG_INFO, "%pp: ATS is disabled\n", &pdev->sbdf);
+}
diff --git a/xen/drivers/passthrough/x86/Makefile 
b/xen/drivers/passthrough/x86/Makefile
index 69284a5d19..75b2885336 100644
--- a/xen/drivers/passthrough/x86/Makefile
+++ b/xen/drivers/passthrough/x86/Makefile
@@ -1,3 +1,2 @@
-obj-y += ats.o
 obj-y += iommu.o
 obj-$(CONFIG_HVM) += hvm.o
diff --git a/xen/drivers/passthrough/x86/ats.c 
b/xen/drivers/passthrough/x86/ats.c
deleted file mode 100644
index 4628ffde45..0000000000
--- a/xen/drivers/passthrough/x86/ats.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include <xen/param.h>
-#include <xen/sched.h>
-#include <xen/pci.h>
-#include <xen/pci_regs.h>
-#include "../ats.h"
-
-bool_t __read_mostly ats_enabled = 0;
-boolean_param("ats", ats_enabled);
-
-int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list)
-{
-    u32 value;
-    u16 seg = pdev->seg;
-    u8 bus = pdev->bus, devfn = pdev->devfn;
-    int pos;
-
-    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
-    BUG_ON(!pos);
-
-    if ( iommu_verbose )
-        dprintk(XENLOG_INFO, "%pp: ATS capability found\n", &pdev->sbdf);
-
-    value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CTL);
-    if ( value & ATS_ENABLE )
-    {
-        struct pci_dev *other;
-
-        list_for_each_entry ( other, ats_list, ats.list )
-            if ( other == pdev )
-            {
-                pos = 0;
-                break;
-            }
-    }
-
-    if ( !(value & ATS_ENABLE) )
-    {
-        value |= ATS_ENABLE;
-        pci_conf_write16(pdev->sbdf, pos + ATS_REG_CTL, value);
-    }
-
-    if ( pos )
-    {
-        pdev->ats.cap_pos = pos;
-        value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CAP);
-        pdev->ats.queue_depth = value & ATS_QUEUE_DEPTH_MASK ?:
-                                ATS_QUEUE_DEPTH_MASK + 1;
-        list_add(&pdev->ats.list, ats_list);
-    }
-
-    if ( iommu_verbose )
-        dprintk(XENLOG_INFO, "%pp: ATS %s enabled\n",
-                &pdev->sbdf, pos ? "is" : "was");
-
-    return pos;
-}
-
-void disable_ats_device(struct pci_dev *pdev)
-{
-    u32 value;
-
-    BUG_ON(!pdev->ats.cap_pos);
-
-    value = pci_conf_read16(pdev->sbdf, pdev->ats.cap_pos + ATS_REG_CTL);
-    value &= ~ATS_ENABLE;
-    pci_conf_write16(pdev->sbdf, pdev->ats.cap_pos + ATS_REG_CTL, value);
-
-    list_del(&pdev->ats.list);
-
-    if ( iommu_verbose )
-        dprintk(XENLOG_INFO, "%pp: ATS is disabled\n", &pdev->sbdf);
-}
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.