iommu/vt-d: Make iommu_should_identity_map() take struct device

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
David Woodhouse 2014-03-09 16:03:08 -07:00
parent 0b9d975315
commit 3bdb259116
1 changed files with 59 additions and 52 deletions

View File

@ -2518,9 +2518,12 @@ static bool device_has_rmrr(struct device *dev)
return false;
}
static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
static int iommu_should_identity_map(struct device *dev, int startup)
{
if (dev_is_pci(dev)) {
struct pci_dev *pdev = to_pci_dev(dev);
/*
* We want to prevent any device associated with an RMRR from
* getting placed into the SI Domain. This is done because
@ -2529,7 +2532,7 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
* from this process due to their usage of RMRRs that are known
* to not be needed after BIOS hand-off to OS.
*/
if (device_has_rmrr(&pdev->dev) &&
if (device_has_rmrr(dev) &&
(pdev->class >> 8) != PCI_CLASS_SERIAL_USB)
return 0;
@ -2566,10 +2569,14 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
return 0;
} else if (pci_pcie_type(pdev) == PCI_EXP_TYPE_PCI_BRIDGE)
return 0;
} else {
if (device_has_rmrr(dev))
return 0;
}
/*
* At boot time, we don't yet know if devices will be 64-bit capable.
* Assume that they will -- if they turn out not to be, then we can
* Assume that they will if they turn out not to be, then we can
* take them out of the 1:1 domain later.
*/
if (!startup) {
@ -2577,13 +2584,13 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
* If the device's dma_mask is less than the system's memory
* size then this is not a candidate for identity mapping.
*/
u64 dma_mask = pdev->dma_mask;
u64 dma_mask = *dev->dma_mask;
if (pdev->dev.coherent_dma_mask &&
pdev->dev.coherent_dma_mask < dma_mask)
dma_mask = pdev->dev.coherent_dma_mask;
if (dev->coherent_dma_mask &&
dev->coherent_dma_mask < dma_mask)
dma_mask = dev->coherent_dma_mask;
return dma_mask >= dma_get_required_mask(&pdev->dev);
return dma_mask >= dma_get_required_mask(dev);
}
return 1;
@ -2599,7 +2606,7 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
return -EFAULT;
for_each_pci_dev(pdev) {
if (iommu_should_identity_map(pdev, 1)) {
if (iommu_should_identity_map(&pdev->dev, 1)) {
ret = domain_add_dev_info(si_domain, pdev,
hw ? CONTEXT_TT_PASS_THROUGH :
CONTEXT_TT_MULTI_LEVEL);
@ -2917,7 +2924,7 @@ static int iommu_no_mapping(struct device *dev)
pdev = to_pci_dev(dev);
found = identity_mapping(dev);
if (found) {
if (iommu_should_identity_map(pdev, 0))
if (iommu_should_identity_map(&pdev->dev, 0))
return 1;
else {
/*
@ -2934,7 +2941,7 @@ static int iommu_no_mapping(struct device *dev)
* In case of a detached 64 bit DMA device from vm, the device
* is put into si_domain for identity mapping.
*/
if (iommu_should_identity_map(pdev, 0)) {
if (iommu_should_identity_map(&pdev->dev, 0)) {
int ret;
ret = domain_add_dev_info(si_domain, pdev,
hw_pass_through ?