/* In this function the list of preallocated protection domains is traversed to find the domain for a specific device  */
static struct dma_ops_domain* find_protection_domain(u16 devid)
/* In this function the list of preallocated protection domains is traversed to find the domain for a specific device  */
static struct dma_ops_domain* find_protection_domain(u16 devid)
{
	struct dma_ops_domain *entry, *ret = NULL;
	unsigned long flags;
	u16 alias = amd_iommu_alias_table[devid];
	if (list_empty(&iommu_pd_list))
		return NULL;
	spin_lock_irqsave(&iommu_pd_list_lock, flags);
	list_for_each_entry(entry, &iommu_pd_list, list) {
		if (entry->target_dev == devid ||
		    entry->target_dev == alias) {
			ret = entry;
			break;
		}
	}
	spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
	return ret;
}