Commit 2c1296d9 authored by Joerg Roedel's avatar Joerg Roedel

iommu: Add iommu_get_domain_for_dev function

This function can be used to request the current domain a
device is attached to.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent e39cb8a3
...@@ -1076,6 +1076,24 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev) ...@@ -1076,6 +1076,24 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
} }
EXPORT_SYMBOL_GPL(iommu_detach_device); EXPORT_SYMBOL_GPL(iommu_detach_device);
struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
{
struct iommu_domain *domain;
struct iommu_group *group;
group = iommu_group_get(dev);
/* FIXME: Remove this when groups a mandatory for iommu drivers */
if (group == NULL)
return NULL;
domain = group->domain;
iommu_group_put(group);
return domain;
}
EXPORT_SYMBOL_GPL(iommu_get_domain_for_dev);
/* /*
* IOMMU groups are really the natrual working unit of the IOMMU, but * IOMMU groups are really the natrual working unit of the IOMMU, but
* the IOMMU API works on domains and devices. Bridge that gap by * the IOMMU API works on domains and devices. Bridge that gap by
......
...@@ -193,6 +193,7 @@ extern int iommu_attach_device(struct iommu_domain *domain, ...@@ -193,6 +193,7 @@ extern int iommu_attach_device(struct iommu_domain *domain,
struct device *dev); struct device *dev);
extern void iommu_detach_device(struct iommu_domain *domain, extern void iommu_detach_device(struct iommu_domain *domain,
struct device *dev); struct device *dev);
extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
extern int iommu_map(struct iommu_domain *domain, unsigned long iova, extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, size_t size, int prot); phys_addr_t paddr, size_t size, int prot);
extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
...@@ -332,6 +333,11 @@ static inline void iommu_detach_device(struct iommu_domain *domain, ...@@ -332,6 +333,11 @@ static inline void iommu_detach_device(struct iommu_domain *domain,
{ {
} }
static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
{
return NULL;
}
static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, int gfp_order, int prot) phys_addr_t paddr, int gfp_order, int prot)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment