All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] IOMMU: Add two generic functions to vendor neutral interface
Date: Thu, 18 Jun 2009 15:27:54 +0200	[thread overview]
Message-ID: <200906181527.54979.wei.wang2@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

Hi,
This patch adds 2 generic functions into the vendor neutral iommu interface, 
The reason is that from changeset 19732, there is only one global 
flag "iommu_enabled" that controls iommu enablement for both vtd and amd 
systems, so we need different code paths for vtd and amd iommu systems if this 
flag has been turned on. Also, the early checking  of "iommu_enabled" in  
iommu_setup() is removed to prevent iommu functionalities from been disabled 
on amd systems.
Thanks,
-Wei

Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
 AMD GmbH, Germany
 Operating System Research Center
 
 Legal Information:
 Advanced Micro Devices GmbH
 Karl-Hammerschmidt-Str. 34
 85609 Dornach b. München
 
 Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni
 Sitz: Dornach, Gemeinde Aschheim, Landkreis München
 Registergericht München, HRB Nr. 43632

[-- Attachment #2: fix_global_variable.patch --]
[-- Type: text/x-diff, Size: 5419 bytes --]

diff -r 64a932c92a7c xen/arch/x86/msi.c
--- a/xen/arch/x86/msi.c	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/arch/x86/msi.c	Wed Jun 17 18:38:34 2009 +0200
@@ -192,7 +192,7 @@ static void read_msi_msg(struct msi_desc
     }
 
     if ( iommu_enabled )
-        msi_msg_read_remap_rte(entry, msg);
+        iommu_read_msi_from_ire(entry, msg);
 }
 
 static int set_vector_msi(struct msi_desc *entry)
diff -r 64a932c92a7c xen/drivers/passthrough/amd/iommu_intr.c
--- a/xen/drivers/passthrough/amd/iommu_intr.c	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/drivers/passthrough/amd/iommu_intr.c	Wed Jun 17 18:38:34 2009 +0200
@@ -231,6 +231,18 @@ void amd_iommu_msi_msg_update_ire(
     update_intremap_entry_from_msi_msg(iommu, pdev, msg);
 }
 
+unsigned int amd_iommu_read_ioapic_from_ire(
+    unsigned int apic, unsigned int reg)
+{
+    *IO_APIC_BASE(apic) = reg;
+    return *(IO_APIC_BASE(apic)+4);
+}
+
+void amd_iommu_read_msi_from_ire(
+    struct msi_desc *msi_desc, struct msi_msg *msg)
+{
+}
+
 int __init deallocate_intremap_table(void)
 {
     if ( int_remap_table )
diff -r 64a932c92a7c xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Wed Jun 17 18:38:34 2009 +0200
@@ -439,4 +439,6 @@ struct iommu_ops amd_iommu_ops = {
     .get_device_group_id = amd_iommu_group_id,
     .update_ire_from_apic = amd_iommu_ioapic_update_ire,
     .update_ire_from_msi = amd_iommu_msi_msg_update_ire,
+    .read_apic_from_ire = amd_iommu_read_ioapic_from_ire,
+    .read_msi_from_ire = amd_iommu_read_msi_from_ire,
 };
diff -r 64a932c92a7c xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/drivers/passthrough/iommu.c	Wed Jun 17 18:38:34 2009 +0200
@@ -263,14 +263,10 @@ static int iommu_setup(void)
 {
     int rc = -ENODEV;
 
-    if ( !iommu_enabled )
-        goto out;
-
     rc = iommu_hardware_setup();
 
     iommu_enabled = (rc == 0);
 
- out:
     if ( force_iommu && !iommu_enabled )
         panic("IOMMU setup failed, crash Xen for security purpose!\n");
 
@@ -336,6 +332,20 @@ void iommu_update_ire_from_msi(
     struct iommu_ops *ops = iommu_get_ops();
     ops->update_ire_from_msi(msi_desc, msg);
 }
+
+void iommu_read_msi_from_ire(
+    struct msi_desc *msi_desc, struct msi_msg *msg)
+{
+    struct iommu_ops *ops = iommu_get_ops();
+    ops->read_msi_from_ire(msi_desc, msg);
+}
+
+unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg)
+{
+    struct iommu_ops *ops = iommu_get_ops();
+    return ops->read_apic_from_ire(apic, reg);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 64a932c92a7c xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c	Wed Jun 17 18:38:34 2009 +0200
@@ -1989,6 +1989,8 @@ struct iommu_ops intel_iommu_ops = {
     .get_device_group_id = intel_iommu_group_id,
     .update_ire_from_apic = io_apic_write_remap_rte,
     .update_ire_from_msi = msi_msg_write_remap_rte,
+    .read_apic_from_ire = io_apic_read_remap_rte,
+    .read_msi_from_ire = msi_msg_read_remap_rte,
 };
 
 /*
diff -r 64a932c92a7c xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Wed Jun 17 18:38:34 2009 +0200
@@ -87,6 +87,10 @@ void amd_iommu_ioapic_update_ire(
     unsigned int apic, unsigned int reg, unsigned int value);
 void amd_iommu_msi_msg_update_ire(
     struct msi_desc *msi_desc, struct msi_msg *msg);
+void amd_iommu_read_msi_from_ire(
+    struct msi_desc *msi_desc, struct msi_msg *msg);
+unsigned int amd_iommu_read_ioapic_from_ire(
+    unsigned int apic, unsigned int reg);
 
 static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift)
 {
diff -r 64a932c92a7c xen/include/asm-x86/io_apic.h
--- a/xen/include/asm-x86/io_apic.h	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/include/asm-x86/io_apic.h	Wed Jun 17 18:38:34 2009 +0200
@@ -131,7 +131,7 @@ static inline unsigned int io_apic_read(
 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
 {
 	if (ioapic_reg_remapped(reg))
-		return io_apic_read_remap_rte(apic, reg);
+		return iommu_read_apic_from_ire(apic, reg);
 	*IO_APIC_BASE(apic) = reg;
 	return *(IO_APIC_BASE(apic)+4);
 }
diff -r 64a932c92a7c xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h	Tue Jun 16 14:19:34 2009 +0100
+++ b/xen/include/xen/iommu.h	Wed Jun 17 18:38:34 2009 +0200
@@ -107,10 +107,14 @@ struct iommu_ops {
     int (*get_device_group_id)(u8 bus, u8 devfn);
     void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
     void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
+    void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
+    unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
 };
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
 void iommu_update_ire_from_msi(struct msi_desc *msi_desc, struct msi_msg *msg);
+void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg);
+unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
 
 void iommu_suspend(void);
 void iommu_resume(void);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-06-18 13:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200906181527.54979.wei.wang2@amd.com \
    --to=wei.wang2@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.