/* find_iova - find's an iova for a given pfn @iovad - iova domain in question. pfn - page frame number This function finds and returns an iova belonging to the given doamin which matches the given pfn.  */
struct iova* find_iova(struct iova_domain *iovad, unsigned long pfn)
/* find_iova - find's an iova for a given pfn @iovad - iova domain in question. pfn - page frame number This function finds and returns an iova belonging to the given doamin which matches the given pfn.  */
struct iova* find_iova(struct iova_domain *iovad, unsigned long pfn)
{
	unsigned long flags;
	struct rb_node *node;
	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
	node = iovad->rbroot.rb_node;
	while (node) {
		struct iova *iova = container_of(node, struct iova, node);
		if ((pfn >= iova->pfn_lo) && (pfn <= iova->pfn_hi)) {
			spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
			return iova;
		}
		if (pfn < iova->pfn_lo)
			node = node->rb_left;
		else if (pfn > iova->pfn_lo)
			node = node->rb_right;
	}
	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
	return NULL;
}