Skip to content

Commit

Permalink
iommu: Retire iommu_capable()
Browse files Browse the repository at this point in the history
With all callers now converted to the device-specific version, retire
the old bus-based interface, and give drivers the chance to indicate
accurate per-instance capabilities.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/d8bd8777d06929ad8f49df7fc80e1b9af32a41b5.1660574547.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Robin Murphy authored and Joerg Roedel committed Sep 7, 2022
1 parent bf75eb4 commit 359ad15
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion drivers/iommu/amd/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,7 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
return ops->iova_to_phys(ops, iova);
}

static bool amd_iommu_capable(enum iommu_cap cap)
static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ static const struct iommu_flush_ops arm_smmu_flush_ops = {
};

/* IOMMU API */
static bool arm_smmu_capable(enum iommu_cap cap)
static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/arm/arm-smmu/arm-smmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
return ops->iova_to_phys(ops, iova);
}

static bool arm_smmu_capable(enum iommu_cap cap)
static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/arm/arm-smmu/qcom_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ static phys_addr_t qcom_iommu_iova_to_phys(struct iommu_domain *domain,
return ret;
}

static bool qcom_iommu_capable(enum iommu_cap cap)
static bool qcom_iommu_capable(struct device *dev, enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/fsl_pamu_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static phys_addr_t fsl_pamu_iova_to_phys(struct iommu_domain *domain,
return iova;
}

static bool fsl_pamu_capable(enum iommu_cap cap)
static bool fsl_pamu_capable(struct device *dev, enum iommu_cap cap)
{
return cap == IOMMU_CAP_CACHE_COHERENCY;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/intel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,7 @@ static bool intel_iommu_enforce_cache_coherency(struct iommu_domain *domain)
return true;
}

static bool intel_iommu_capable(enum iommu_cap cap)
static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap)
{
if (cap == IOMMU_CAP_CACHE_COHERENCY)
return true;
Expand Down
11 changes: 1 addition & 10 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,19 +1868,10 @@ bool device_iommu_capable(struct device *dev, enum iommu_cap cap)
if (!ops->capable)
return false;

return ops->capable(cap);
return ops->capable(dev, cap);
}
EXPORT_SYMBOL_GPL(device_iommu_capable);

bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
{
if (!bus->iommu_ops || !bus->iommu_ops->capable)
return false;

return bus->iommu_ops->capable(cap);
}
EXPORT_SYMBOL_GPL(iommu_capable);

/**
* iommu_set_fault_handler() - set a fault handler for an iommu domain
* @domain: iommu domain
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/s390-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static struct s390_domain *to_s390_domain(struct iommu_domain *dom)
return container_of(dom, struct s390_domain, domain);
}

static bool s390_iommu_capable(enum iommu_cap cap)
static bool s390_iommu_capable(struct device *dev, enum iommu_cap cap)
{
switch (cap) {
case IOMMU_CAP_CACHE_COHERENCY:
Expand Down
8 changes: 1 addition & 7 deletions include/linux/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct iommu_iotlb_gather {
* @owner: Driver module providing these ops
*/
struct iommu_ops {
bool (*capable)(enum iommu_cap);
bool (*capable)(struct device *dev, enum iommu_cap);

/* Domain allocation and freeing by the iommu driver */
struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
Expand Down Expand Up @@ -420,7 +420,6 @@ extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
extern int bus_iommu_probe(struct bus_type *bus);
extern bool iommu_present(struct bus_type *bus);
extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap);
extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
extern struct iommu_group *iommu_group_get_by_id(int id);
extern void iommu_domain_free(struct iommu_domain *domain);
Expand Down Expand Up @@ -697,11 +696,6 @@ static inline bool device_iommu_capable(struct device *dev, enum iommu_cap cap)
return false;
}

static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
{
return false;
}

static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
{
return NULL;
Expand Down

0 comments on commit 359ad15

Please sign in to comment.