[prev in list] [next in list] [prev in thread] [next in thread]
List: xen-devel
Subject: [Xen-devel] [PATCH] vtd: avoid redundant context mapping
From: "Cui, Dexuan" <dexuan.cui () intel ! com>
Date: 2008-12-30 9:02:26
Message-ID: EADF0A36011179459010BDF5142A4575045D5065 () pdsmsx502 ! ccr ! corp ! intel ! com
[Download RAW message or body]
After changeset 18934 (VT-d: Fix PCI-X device assignment), my assigned PCI E1000 NIC \
doesn't work in guest. The NIC is 03:00.0. Its parent bridge is: 00:1e.0.
In domain_context_mapping():
case DEV_TYPE_PCI:
After we domain_context_mapping_one() 03:00.0 and 00:1e.0, the 'secbus' is 3 and \
'bus' is 0, so we domain_context_mapping_one() 03:00.0 again -- this redundant \
invocation returns -EINVAL because we have created the mapping but haven't changed \
pdev->domain from Dom0 to a new domain at this time and eventually the \
XEN_DOMCTL_assign_device hypercall returns a failure. The attached patch detects \
this case and avoids the redundant invocation.
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
["avoid_redundant_mapping.patch" (application/octet-stream)]
diff -r e2f36d066b7b xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c Mon Dec 22 13:48:40 2008 +0000
+++ b/xen/drivers/passthrough/vtd/iommu.c Mon Dec 26 18:43:16 2008 +0800
@@ -1209,7 +1209,7 @@ static int domain_context_mapping(struct
int ret = 0;
u16 sec_bus, sub_bus;
u32 type;
- u8 secbus;
+ u8 secbus, secdevfn;
drhd = acpi_find_matched_drhd_unit(bus, devfn);
if ( !drhd )
@@ -1256,10 +1256,12 @@ static int domain_context_mapping(struct
break;
secbus = bus;
+ secdevfn = devfn;
/* dependent devices mapping */
while ( bus2bridge[bus].map )
{
secbus = bus;
+ secdevfn = devfn;
devfn = bus2bridge[bus].devfn;
bus = bus2bridge[bus].bus;
ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn);
@@ -1267,7 +1269,7 @@ static int domain_context_mapping(struct
return ret;
}
- if ( secbus != bus )
+ if ( (secbus != bus) && (secdevfn != 0) )
/*
* The source-id for transactions on non-PCIe buses seem
* to originate from devfn=0 on the secondary bus behind
@@ -1333,7 +1335,7 @@ static int domain_context_unmap(struct d
struct acpi_drhd_unit *drhd;
int ret = 0;
u32 type;
- u8 secbus;
+ u8 secbus, secdevfn;
drhd = acpi_find_matched_drhd_unit(bus, devfn);
if ( !drhd )
@@ -1362,10 +1364,12 @@ static int domain_context_unmap(struct d
break;
secbus = bus;
+ secdevfn = devfn;
/* dependent devices unmapping */
while ( bus2bridge[bus].map )
{
secbus = bus;
+ secdevfn = devfn;
devfn = bus2bridge[bus].devfn;
bus = bus2bridge[bus].bus;
ret = domain_context_unmap_one(domain, drhd->iommu, bus, devfn);
@@ -1373,7 +1377,7 @@ static int domain_context_unmap(struct d
return ret;
}
- if ( bus != secbus )
+ if ( (secbus != bus) && (secdevfn != 0) )
ret = domain_context_unmap_one(domain, drhd->iommu, secbus, 0);
break;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic