x86/amd-iommu: Use check_device for amd_iommu_dma_supported
The check_device logic needs to include the dma_supported checks to be really sure. Merge the dma_supported logic into check_device and use it to implement dma_supported. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
This commit is contained in:
parent
318afd41d2
commit
420aef8a3a
1 changed files with 19 additions and 16 deletions
|
@ -1375,9 +1375,27 @@ static struct notifier_block device_nb = {
|
||||||
*/
|
*/
|
||||||
static bool check_device(struct device *dev)
|
static bool check_device(struct device *dev)
|
||||||
{
|
{
|
||||||
|
u16 bdf;
|
||||||
|
struct pci_dev *pcidev;
|
||||||
|
|
||||||
if (!dev || !dev->dma_mask)
|
if (!dev || !dev->dma_mask)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* No device or no PCI device */
|
||||||
|
if (!dev || dev->bus != &pci_bus_type)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pcidev = to_pci_dev(dev);
|
||||||
|
|
||||||
|
bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
|
||||||
|
|
||||||
|
/* Out of our scope? */
|
||||||
|
if (bdf > amd_iommu_last_bdf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (amd_iommu_rlookup_table[bdf] == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2065,22 +2083,7 @@ free_mem:
|
||||||
*/
|
*/
|
||||||
static int amd_iommu_dma_supported(struct device *dev, u64 mask)
|
static int amd_iommu_dma_supported(struct device *dev, u64 mask)
|
||||||
{
|
{
|
||||||
u16 bdf;
|
return check_device(dev);
|
||||||
struct pci_dev *pcidev;
|
|
||||||
|
|
||||||
/* No device or no PCI device */
|
|
||||||
if (!dev || dev->bus != &pci_bus_type)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pcidev = to_pci_dev(dev);
|
|
||||||
|
|
||||||
bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
|
|
||||||
|
|
||||||
/* Out of our scope? */
|
|
||||||
if (bdf > amd_iommu_last_bdf)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue