mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 02:33:57 +00:00
iommu/ipmmu: Add an IOMMU_IDENTITIY_DOMAIN
This brings back the ops->detach_dev() code that commit1b932ceddd
("iommu: Remove detach_dev callbacks") deleted and turns it into an IDENTITY domain. Also reverts commit584d334b13
("iommu/ipmmu-vmsa: Remove ipmmu_utlb_disable()") Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/17-v8-81230027b2fa+9d-iommu_all_defdom_jgg@nvidia.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
786478a902
commit
666c9f1ef7
@ -295,6 +295,18 @@ static void ipmmu_utlb_enable(struct ipmmu_vmsa_domain *domain,
|
||||
mmu->utlb_ctx[utlb] = domain->context_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable MMU translation for the microTLB.
|
||||
*/
|
||||
static void ipmmu_utlb_disable(struct ipmmu_vmsa_domain *domain,
|
||||
unsigned int utlb)
|
||||
{
|
||||
struct ipmmu_vmsa_device *mmu = domain->mmu;
|
||||
|
||||
ipmmu_imuctr_write(mmu, utlb, 0);
|
||||
mmu->utlb_ctx[utlb] = IPMMU_CTX_INVALID;
|
||||
}
|
||||
|
||||
static void ipmmu_tlb_flush_all(void *cookie)
|
||||
{
|
||||
struct ipmmu_vmsa_domain *domain = cookie;
|
||||
@ -627,6 +639,36 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ipmmu_iommu_identity_attach(struct iommu_domain *identity_domain,
|
||||
struct device *dev)
|
||||
{
|
||||
struct iommu_domain *io_domain = iommu_get_domain_for_dev(dev);
|
||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||
struct ipmmu_vmsa_domain *domain;
|
||||
unsigned int i;
|
||||
|
||||
if (io_domain == identity_domain || !io_domain)
|
||||
return 0;
|
||||
|
||||
domain = to_vmsa_domain(io_domain);
|
||||
for (i = 0; i < fwspec->num_ids; ++i)
|
||||
ipmmu_utlb_disable(domain, fwspec->ids[i]);
|
||||
|
||||
/*
|
||||
* TODO: Optimize by disabling the context when no device is attached.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct iommu_domain_ops ipmmu_iommu_identity_ops = {
|
||||
.attach_dev = ipmmu_iommu_identity_attach,
|
||||
};
|
||||
|
||||
static struct iommu_domain ipmmu_iommu_identity_domain = {
|
||||
.type = IOMMU_DOMAIN_IDENTITY,
|
||||
.ops = &ipmmu_iommu_identity_ops,
|
||||
};
|
||||
|
||||
static int ipmmu_map(struct iommu_domain *io_domain, unsigned long iova,
|
||||
phys_addr_t paddr, size_t pgsize, size_t pgcount,
|
||||
int prot, gfp_t gfp, size_t *mapped)
|
||||
@ -849,6 +891,7 @@ static struct iommu_group *ipmmu_find_group(struct device *dev)
|
||||
}
|
||||
|
||||
static const struct iommu_ops ipmmu_ops = {
|
||||
.identity_domain = &ipmmu_iommu_identity_domain,
|
||||
.domain_alloc = ipmmu_domain_alloc,
|
||||
.probe_device = ipmmu_probe_device,
|
||||
.release_device = ipmmu_release_device,
|
||||
|
Loading…
Reference in New Issue
Block a user