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 1 of 6] amd iommu: Use pci access function to detect

To: <JBeulich@xxxxxxxx>
Subject: [Xen-devel] [PATCH 1 of 6] amd iommu: Use pci access function to detect msi capabilities
From: Wei Wang <wei.wang2@xxxxxxx>
Date: Wed, 9 Nov 2011 16:50:56 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 09 Nov 2011 07:56:00 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1320853855@xxxxxxxxxxxx>
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>
References: <patchbomb.1320853855@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.9.3
# HG changeset patch
# User Wei Wang <wei.wang2@xxxxxxx>
# Date 1320841109 -3600
# Node ID 4769713326a876c25bdc0f9d1f90594f90fba9c5
# Parent  452d9143687f826a30d0e56b7ba3b9783fb6bf24
amd iommu: Use pci access function to detect msi capabilities.

Signed-off-by: Wei Wang <wei.wang2@xxxxxxx>

diff -r 452d9143687f -r 4769713326a8 xen/drivers/passthrough/amd/iommu_detect.c
--- a/xen/drivers/passthrough/amd/iommu_detect.c        Tue Nov 08 11:26:53 
2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_detect.c        Wed Nov 09 13:18:29 
2011 +0100
@@ -30,38 +30,19 @@
 static int __init get_iommu_msi_capabilities(
     u16 seg, u8 bus, u8 dev, u8 func, struct amd_iommu *iommu)
 {
-    int cap_ptr, cap_id;
-    u32 cap_header;
+    int pos;
     u16 control;
-    int count = 0;
 
-    cap_ptr = pci_conf_read8(seg, bus, dev, func,
-            PCI_CAPABILITY_LIST);
+    pos = pci_find_cap_offset(seg, bus, dev, func, PCI_CAP_ID_MSI);
 
-    while ( cap_ptr >= PCI_MIN_CAP_OFFSET &&
-        count < PCI_MAX_CAP_BLOCKS )
-    {
-        cap_ptr &= PCI_CAP_PTR_MASK;
-        cap_header = pci_conf_read32(seg, bus, dev, func, cap_ptr);
-        cap_id = get_field_from_reg_u32(cap_header,
-                PCI_CAP_ID_MASK, PCI_CAP_ID_SHIFT);
-
-        if ( cap_id == PCI_CAP_ID_MSI )
-        {
-            iommu->msi_cap = cap_ptr;
-            break;
-        }
-        cap_ptr = get_field_from_reg_u32(cap_header,
-                PCI_CAP_NEXT_PTR_MASK, PCI_CAP_NEXT_PTR_SHIFT);
-        count++;
-    }
-
-    if ( !iommu->msi_cap )
+    if ( !pos )
         return -ENODEV;
 
-    AMD_IOMMU_DEBUG("Found MSI capability block \n");
+    AMD_IOMMU_DEBUG("Found MSI capability block at 0x%x\n", pos);
+
+    iommu->msi_cap = pos;
     control = pci_conf_read16(seg, bus, dev, func,
-            iommu->msi_cap + PCI_MSI_FLAGS);
+                              iommu->msi_cap + PCI_MSI_FLAGS);
     iommu->maskbit = control & PCI_MSI_FLAGS_MASKBIT;
     return 0;
 }


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