Merge branches 'iommu/fixes', 'arm/qcom', 'arm/omap', 'arm/smmu', 'x86/amd', 'x86/vt-d', 'virtio' and 'core' into next
This commit is contained in:

@@ -466,7 +466,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)
|
||||
struct virtio_iommu_req_probe *probe;
|
||||
struct virtio_iommu_probe_property *prop;
|
||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||
struct viommu_endpoint *vdev = fwspec->iommu_priv;
|
||||
struct viommu_endpoint *vdev = dev_iommu_priv_get(dev);
|
||||
|
||||
if (!fwspec->num_ids)
|
||||
return -EINVAL;
|
||||
@@ -607,24 +607,36 @@ static struct iommu_domain *viommu_domain_alloc(unsigned type)
|
||||
return &vdomain->domain;
|
||||
}
|
||||
|
||||
static int viommu_domain_finalise(struct viommu_dev *viommu,
|
||||
static int viommu_domain_finalise(struct viommu_endpoint *vdev,
|
||||
struct iommu_domain *domain)
|
||||
{
|
||||
int ret;
|
||||
unsigned long viommu_page_size;
|
||||
struct viommu_dev *viommu = vdev->viommu;
|
||||
struct viommu_domain *vdomain = to_viommu_domain(domain);
|
||||
|
||||
vdomain->viommu = viommu;
|
||||
vdomain->map_flags = viommu->map_flags;
|
||||
viommu_page_size = 1UL << __ffs(viommu->pgsize_bitmap);
|
||||
if (viommu_page_size > PAGE_SIZE) {
|
||||
dev_err(vdev->dev,
|
||||
"granule 0x%lx larger than system page size 0x%lx\n",
|
||||
viommu_page_size, PAGE_SIZE);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,
|
||||
viommu->last_domain, GFP_KERNEL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
vdomain->id = (unsigned int)ret;
|
||||
|
||||
domain->pgsize_bitmap = viommu->pgsize_bitmap;
|
||||
domain->geometry = viommu->geometry;
|
||||
|
||||
ret = ida_alloc_range(&viommu->domain_ids, viommu->first_domain,
|
||||
viommu->last_domain, GFP_KERNEL);
|
||||
if (ret >= 0)
|
||||
vdomain->id = (unsigned int)ret;
|
||||
vdomain->map_flags = viommu->map_flags;
|
||||
vdomain->viommu = viommu;
|
||||
|
||||
return ret > 0 ? 0 : ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void viommu_domain_free(struct iommu_domain *domain)
|
||||
@@ -648,7 +660,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)
|
||||
int ret = 0;
|
||||
struct virtio_iommu_req_attach req;
|
||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||
struct viommu_endpoint *vdev = fwspec->iommu_priv;
|
||||
struct viommu_endpoint *vdev = dev_iommu_priv_get(dev);
|
||||
struct viommu_domain *vdomain = to_viommu_domain(domain);
|
||||
|
||||
mutex_lock(&vdomain->mutex);
|
||||
@@ -657,7 +669,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)
|
||||
* Properly initialize the domain now that we know which viommu
|
||||
* owns it.
|
||||
*/
|
||||
ret = viommu_domain_finalise(vdev->viommu, domain);
|
||||
ret = viommu_domain_finalise(vdev, domain);
|
||||
} else if (vdomain->viommu != vdev->viommu) {
|
||||
dev_err(dev, "cannot attach to foreign vIOMMU\n");
|
||||
ret = -EXDEV;
|
||||
@@ -807,8 +819,7 @@ static void viommu_iotlb_sync(struct iommu_domain *domain,
|
||||
static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
|
||||
{
|
||||
struct iommu_resv_region *entry, *new_entry, *msi = NULL;
|
||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||
struct viommu_endpoint *vdev = fwspec->iommu_priv;
|
||||
struct viommu_endpoint *vdev = dev_iommu_priv_get(dev);
|
||||
int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
|
||||
|
||||
list_for_each_entry(entry, &vdev->resv_regions, list) {
|
||||
@@ -876,7 +887,7 @@ static int viommu_add_device(struct device *dev)
|
||||
vdev->dev = dev;
|
||||
vdev->viommu = viommu;
|
||||
INIT_LIST_HEAD(&vdev->resv_regions);
|
||||
fwspec->iommu_priv = vdev;
|
||||
dev_iommu_priv_set(dev, vdev);
|
||||
|
||||
if (viommu->probe_size) {
|
||||
/* Get additional information for this endpoint */
|
||||
@@ -920,7 +931,7 @@ static void viommu_remove_device(struct device *dev)
|
||||
if (!fwspec || fwspec->ops != &viommu_ops)
|
||||
return;
|
||||
|
||||
vdev = fwspec->iommu_priv;
|
||||
vdev = dev_iommu_priv_get(dev);
|
||||
|
||||
iommu_group_remove_device(dev);
|
||||
iommu_device_unlink(&vdev->viommu->iommu, dev);
|
||||
@@ -1082,7 +1093,6 @@ static int viommu_probe(struct virtio_device *vdev)
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (pci_bus_type.iommu_ops != &viommu_ops) {
|
||||
pci_request_acs();
|
||||
ret = bus_set_iommu(&pci_bus_type, &viommu_ops);
|
||||
if (ret)
|
||||
goto err_unregister;
|
||||
|
Reference in New Issue
Block a user