iommu/rockchip: disable iommu by attaching NULL

Iommu framework introduce default_domain for automatic
attach which we were not interesting before, now rockchip
iommu driver following this way that make things different:

iommu_detach_device function is not able to disable iommu anymore.
It just do following things either:

1. Just return
   Like Vcodec/ISP who does not allocate new domain

2. Attach default_domain
   Like vop who allocate new domain by vop driver

We have no way to temporary disable iommu,to fix this issue, master
driver need to attach a NULL domain,also master driver need more step:

1. iommu_attach_device(NULL, dev) -> disable iommu
2. iommu_detach_device(NULL, dev) -> attach default_domain

Above two steps must comes in pairs.

Following order called by driver is not permitted:

1. iommu_attach_device(domain, dev)
2. iommu_attach_device(NULL, dev)
3. iommu_detach_device(NULL, dev)
4. iommu_detach_device(domain, dev)

Correct is:

1. iommu_attach_device(domain, dev)
2. iommu_detach_device(domain, dev)
3. iommu_attach_device(NULL, dev)
4. iommu_detach_device(NULL, dev)

Change-Id: I12b1e27e5119fb1abd05ccce57c9e941f03e9498
Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
Simon Xue
2019-06-28 10:54:26 +08:00
committed by Tao Huang
parent 2819c94d56
commit c8410c0f81

View File

@@ -982,6 +982,10 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
iommu->domain = domain;
/* Attach NULL for disable iommu */
if (!domain)
return 0;
spin_lock_irqsave(&rk_domain->iommus_lock, flags);
list_add_tail(&iommu->node, &rk_domain->iommus);
spin_unlock_irqrestore(&rk_domain->iommus_lock, flags);