drm/rockchip: gem: add IOMMU_TLB_SHOT_ENTIRE when call iommu_map_sg

Add IOMMU_TLB_SHOT_ENTIRE prot for iommu_map_sg, this shoot down entire
iommu tlb one time after iommu_map_sg.This may save about 5ms when DRM
mapping 12MB buffer.

Change-Id: I618aff1b3928bd1ec1dd3d896db746e09e96acdc
Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
Simon Xue
2020-02-25 14:25:03 +08:00
committed by Tao Huang
parent 5bb0884f84
commit 7636d59e28
4 changed files with 11 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
{
struct drm_device *drm = rk_obj->base.dev;
struct rockchip_drm_private *private = drm->dev_private;
int prot = IOMMU_READ | IOMMU_WRITE;
int prot = IOMMU_READ | IOMMU_WRITE | IOMMU_TLB_SHOT_ENTIRE;
ssize_t ret;
mutex_lock(&private->mm_lock);

View File

@@ -1717,6 +1717,9 @@ size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
mapped += s->length;
}
if (domain->ops->flush_iotlb_all && (prot & IOMMU_TLB_SHOT_ENTIRE))
domain->ops->flush_iotlb_all(domain);
return mapped;
out_err:

View File

@@ -771,7 +771,10 @@ static int rk_iommu_map_iova(struct rk_iommu_domain *rk_domain, u32 *pte_addr,
* We only zap the first and last iova, since only they could have
* dte or pte shared with an existing mapping.
*/
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
/* Do not zap tlb cache line if IOMMU_TLB_SHOT_ENTIRE set */
if (!(prot & IOMMU_TLB_SHOT_ENTIRE))
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
return 0;
unwind:

View File

@@ -42,6 +42,9 @@
*/
#define IOMMU_PRIV (1 << 5)
/* For shoting entire IOMMU tlb once */
#define IOMMU_TLB_SHOT_ENTIRE (1 << 6)
struct iommu_ops;
struct iommu_group;
struct bus_type;