*/
#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
-static DEFINE_SPINLOCK(amd_iommu_devtable_lock);
static DEFINE_SPINLOCK(pd_bitmap_lock);
/* List of all available dev_data structures */
static int __attach_device(struct iommu_dev_data *dev_data,
struct protection_domain *domain)
{
+ unsigned long flags;
int ret;
/* lock domain */
- spin_lock(&domain->lock);
+ spin_lock_irqsave(&domain->lock, flags);
ret = -EBUSY;
if (dev_data->domain != NULL)
out_unlock:
/* ready */
- spin_unlock(&domain->lock);
+ spin_unlock_irqrestore(&domain->lock, flags);
return ret;
}
{
struct pci_dev *pdev;
struct iommu_dev_data *dev_data;
- unsigned long flags;
int ret;
dev_data = get_dev_data(dev);
}
skip_ats_check:
- spin_lock_irqsave(&amd_iommu_devtable_lock, flags);
ret = __attach_device(dev_data, domain);
- spin_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
/*
* We might boot into a crash-kernel here. The crashed kernel
static void __detach_device(struct iommu_dev_data *dev_data)
{
struct protection_domain *domain;
+ unsigned long flags;
domain = dev_data->domain;
- spin_lock(&domain->lock);
+ spin_lock_irqsave(&domain->lock, flags);
do_detach(dev_data);
- spin_unlock(&domain->lock);
+ spin_unlock_irqrestore(&domain->lock, flags);
}
/*
{
struct protection_domain *domain;
struct iommu_dev_data *dev_data;
- unsigned long flags;
dev_data = get_dev_data(dev);
domain = dev_data->domain;
if (WARN_ON(!dev_data->domain))
return;
- /* lock device table */
- spin_lock_irqsave(&amd_iommu_devtable_lock, flags);
__detach_device(dev_data);
- spin_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
if (!dev_is_pci(dev))
return;
static void cleanup_domain(struct protection_domain *domain)
{
struct iommu_dev_data *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&amd_iommu_devtable_lock, flags);
while (!list_empty(&domain->dev_list)) {
entry = list_first_entry(&domain->dev_list,
BUG_ON(!entry->domain);
__detach_device(entry);
}
-
- spin_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
}
static void protection_domain_free(struct protection_domain *domain)