All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] iommu: make interrupt remapping more generic
Date: Fri, 11 Jul 2008 13:35:59 +0200	[thread overview]
Message-ID: <1215776159.22625.68.camel@gran.amd.com> (raw)

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

Keir,
Attached patch adds 2 more iommu_ops to make interrupt remapping more
generic.
-Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>

-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy 


[-- Attachment #2: xen.patch --]
[-- Type: text/x-patch, Size: 3972 bytes --]

diff -r d5efa03793a2 xen/arch/x86/msi.c
--- a/xen/arch/x86/msi.c	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/arch/x86/msi.c	Fri Jul 11 11:51:53 2008 +0200
@@ -173,8 +173,8 @@ static int unset_vector_msi(int vector)
 
 static void write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 {
-    if ( vtd_enabled )
-        msi_msg_write_remap_rte(entry, msg);
+    if ( iommu_enabled )
+        iommu_update_ire_from_msi(entry, msg);
 
     switch ( entry->msi_attrib.type )
     {
diff -r d5efa03793a2 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Fri Jul 11 11:51:53 2008 +0200
@@ -638,4 +638,6 @@ struct iommu_ops amd_iommu_ops = {
     .unmap_page = amd_iommu_unmap_page,
     .reassign_device = amd_iommu_return_device,
     .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,
 };
diff -r d5efa03793a2 xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/drivers/passthrough/iommu.c	Fri Jul 11 11:51:53 2008 +0200
@@ -290,6 +290,43 @@ int iommu_get_device_group(struct domain
 
     return i;
 }
+
+void iommu_update_ire_from_apic(
+    unsigned int apic, unsigned int reg, unsigned int value)
+{
+    struct iommu_ops *ops = NULL;
+
+    switch ( boot_cpu_data.x86_vendor )
+    {
+    case X86_VENDOR_INTEL:
+        ops = &intel_iommu_ops;
+        break;
+    case X86_VENDOR_AMD:
+        ops = &amd_iommu_ops;
+        break;
+    default:
+        BUG();
+    }
+    ops->update_ire_from_apic(apic, reg, value);
+}
+void iommu_update_ire_from_msi(
+    struct msi_desc *msi_desc, struct msi_msg *msg)
+{
+    struct iommu_ops *ops = NULL;
+
+    switch ( boot_cpu_data.x86_vendor )
+    {
+    case X86_VENDOR_INTEL:
+        ops = &intel_iommu_ops;
+        break;
+    case X86_VENDOR_AMD:
+        ops = &amd_iommu_ops;
+        break;
+    default:
+        BUG();
+    }
+    ops->update_ire_from_msi(msi_desc, msg);
+}
 /*
  * Local variables:
  * mode: C
diff -r d5efa03793a2 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c	Fri Jul 11 11:51:53 2008 +0200
@@ -1866,6 +1866,8 @@ struct iommu_ops intel_iommu_ops = {
     .unmap_page = intel_iommu_unmap_page,
     .reassign_device = reassign_device_ownership,
     .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,
 };
 
 /*
diff -r d5efa03793a2 xen/include/asm-x86/io_apic.h
--- a/xen/include/asm-x86/io_apic.h	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/include/asm-x86/io_apic.h	Fri Jul 11 11:51:53 2008 +0200
@@ -133,8 +133,8 @@ static inline unsigned int io_apic_read(
 
 static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
 {
-	if (vtd_enabled)
-		return io_apic_write_remap_rte(apic, reg, value);
+	if (iommu_enabled)
+		return iommu_update_ire_from_apic(apic, reg, value);
 	*IO_APIC_BASE(apic) = reg;
 	*(IO_APIC_BASE(apic)+4) = value;
 }
diff -r d5efa03793a2 xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h	Thu Jul 10 16:15:37 2008 +0100
+++ b/xen/include/xen/iommu.h	Fri Jul 11 11:51:53 2008 +0200
@@ -103,6 +103,10 @@ struct iommu_ops {
     int (*reassign_device)(struct domain *s, struct domain *t,
 			   u8 bus, u8 devfn);
     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 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);
 #endif /* _IOMMU_H_ */

[-- 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:[~2008-07-11 11:35 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=1215776159.22625.68.camel@gran.amd.com \
    --to=wei.wang2@amd.com \
    --cc=keir.fraser@eu.citrix.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.