Commit 8b6c32e8 authored by Will Deacon's avatar Will Deacon
Browse files

Merge branch 'iommu/iommufd/paging-domain-alloc' into iommu/next

* iommu/iommufd/paging-domain-alloc:
  RDMA/usnic: Use iommu_paging_domain_alloc()
  wifi: ath11k: Use iommu_paging_domain_alloc()
  wifi: ath10k: Use iommu_paging_domain_alloc()
  drm/msm: Use iommu_paging_domain_alloc()
  vhost-vdpa: Use iommu_paging_domain_alloc()
  vfio/type1: Use iommu_paging_domain_alloc()
  iommufd: Use iommu_paging_domain_alloc()
  iommu: Add iommu_paging_domain_alloc() interface
parents 74e54d53 3b10f257
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -407,10 +407,13 @@ struct msm_mmu *msm_iommu_new(struct device *dev, unsigned long quirks)
	struct msm_iommu *iommu;
	int ret;

	domain = iommu_domain_alloc(dev->bus);
	if (!domain)
	if (!device_iommu_mapped(dev))
		return NULL;

	domain = iommu_paging_domain_alloc(dev);
	if (IS_ERR(domain))
		return ERR_CAST(domain);

	iommu_set_pgtable_quirks(domain, quirks);

	iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
+3 −3
Original line number Diff line number Diff line
@@ -443,11 +443,11 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev)
	if (!pd)
		return ERR_PTR(-ENOMEM);

	pd->domain = domain = iommu_domain_alloc(dev->bus);
	if (!domain) {
	pd->domain = domain = iommu_paging_domain_alloc(dev);
	if (IS_ERR(domain)) {
		usnic_err("Failed to allocate IOMMU domain");
		kfree(pd);
		return ERR_PTR(-ENOMEM);
		return ERR_CAST(domain);
	}

	iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
+20 −0
Original line number Diff line number Diff line
@@ -2010,6 +2010,10 @@ static int __iommu_domain_alloc_dev(struct device *dev, void *data)
	return 0;
}

/*
 * The iommu ops in bus has been retired. Do not use this interface in
 * new drivers.
 */
struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
{
	const struct iommu_ops *ops = NULL;
@@ -2026,6 +2030,22 @@ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(iommu_domain_alloc);

/**
 * iommu_paging_domain_alloc() - Allocate a paging domain
 * @dev: device for which the domain is allocated
 *
 * Allocate a paging domain which will be managed by a kernel driver. Return
 * allocated domain if successful, or a ERR pointer for failure.
 */
struct iommu_domain *iommu_paging_domain_alloc(struct device *dev)
{
	if (!dev_has_iommu(dev))
		return ERR_PTR(-ENODEV);

	return __iommu_domain_alloc(dev_iommu_ops(dev), dev, IOMMU_DOMAIN_UNMANAGED);
}
EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc);

void iommu_domain_free(struct iommu_domain *domain)
{
	if (domain->type == IOMMU_DOMAIN_SVA)
+4 −3
Original line number Diff line number Diff line
@@ -140,9 +140,10 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
		}
		hwpt->domain->owner = ops;
	} else {
		hwpt->domain = iommu_domain_alloc(idev->dev->bus);
		if (!hwpt->domain) {
			rc = -ENOMEM;
		hwpt->domain = iommu_paging_domain_alloc(idev->dev);
		if (IS_ERR(hwpt->domain)) {
			rc = PTR_ERR(hwpt->domain);
			hwpt->domain = NULL;
			goto out_abort;
		}
	}
+3 −3
Original line number Diff line number Diff line
@@ -1635,10 +1635,10 @@ static int ath10k_fw_init(struct ath10k *ar)

	ar_snoc->fw.dev = &pdev->dev;

	iommu_dom = iommu_domain_alloc(&platform_bus_type);
	if (!iommu_dom) {
	iommu_dom = iommu_paging_domain_alloc(ar_snoc->fw.dev);
	if (IS_ERR(iommu_dom)) {
		ath10k_err(ar, "failed to allocate iommu domain\n");
		ret = -ENOMEM;
		ret = PTR_ERR(iommu_dom);
		goto err_unregister;
	}

Loading