vtd: avoid redundant context mapping
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jan 2009 11:13:22 +0000 (11:13 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jan 2009 11:13:22 +0000 (11:13 +0000)
commit19e94db94935b6a5ecfd532cc890d9cc04a781dd
tree06cab699332b0043c5f99d75ff289fcb62b973d9
parent1d6e30c679759da989ceee55aa3699f0542ab596
vtd: avoid redundant context mapping

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>
xen/drivers/passthrough/vtd/iommu.c