ia64/xen-unstable

changeset 18160:7b6942ad565c

vt-d: Map RMRR in intel_iommu_add_device() if the device has RMRR;
move domain_context_mapping() to be in front of list_move() in
reassign_device_ownership().

Signed-off-by: Weidong Han <weidong.han@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 25 09:44:48 2008 +0100 (2008-07-25)
parents 804d29cfd083
children 5e44f5d76432
files xen/drivers/passthrough/vtd/iommu.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Fri Jul 25 09:40:14 2008 +0100
     1.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Fri Jul 25 09:44:48 2008 +0100
     1.3 @@ -1409,12 +1409,15 @@ static int reassign_device_ownership(
     1.4      pdev_iommu = drhd->iommu;
     1.5      domain_context_unmap(source, bus, devfn);
     1.6  
     1.7 +    ret = domain_context_mapping(target, bus, devfn);
     1.8 +    if ( ret )
     1.9 +        return ret;
    1.10 +
    1.11      write_lock(&pcidevs_lock);
    1.12      list_move(&pdev->domain_list, &target->arch.pdev_list);
    1.13      write_unlock(&pcidevs_lock);
    1.14      pdev->domain = target;
    1.15  
    1.16 -    ret = domain_context_mapping(target, bus, devfn);
    1.17      spin_unlock(&pdev->lock);
    1.18  
    1.19      read_lock(&pcidevs_lock);
    1.20 @@ -1583,9 +1586,35 @@ static int iommu_prepare_rmrr_dev(struct
    1.21  
    1.22  static int intel_iommu_add_device(struct pci_dev *pdev)
    1.23  {
    1.24 +    struct acpi_rmrr_unit *rmrr;
    1.25 +    u16 bdf;
    1.26 +    int ret, i;
    1.27 +
    1.28      if ( !pdev->domain )
    1.29          return -EINVAL;
    1.30 -    return domain_context_mapping(pdev->domain, pdev->bus, pdev->devfn);
    1.31 +
    1.32 +    ret = domain_context_mapping(pdev->domain, pdev->bus, pdev->devfn);
    1.33 +    if ( ret )
    1.34 +    {
    1.35 +        gdprintk(XENLOG_ERR VTDPREFIX,
    1.36 +                 "intel_iommu_add_device: context mapping failed\n");
    1.37 +        return ret;
    1.38 +    }
    1.39 +
    1.40 +    for_each_rmrr_device ( rmrr, bdf, i )
    1.41 +    {
    1.42 +        if ( PCI_BUS(bdf) == pdev->bus && PCI_DEVFN2(bdf) == pdev->devfn )
    1.43 +        {
    1.44 +            ret = iommu_prepare_rmrr_dev(pdev->domain, rmrr,
    1.45 +                                         pdev->bus, pdev->devfn);
    1.46 +            if ( ret )
    1.47 +                gdprintk(XENLOG_ERR VTDPREFIX,
    1.48 +                         "intel_iommu_add_device: RMRR mapping failed\n");
    1.49 +            break;
    1.50 +        }
    1.51 +    }
    1.52 +
    1.53 +    return ret;
    1.54  }
    1.55  
    1.56  static int intel_iommu_remove_device(struct pci_dev *pdev)