summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2018-10-17 14:25:52 -0700
committerVincent Guittot <vincent.guittot@linaro.org>2019-01-17 12:25:56 +0100
commit6316cc651f35793b9b45eb0d3e9b65d1688b15ef (patch)
tree6bc5586fe3cb36195e96bffa2ff4e3d9718a1321
parent3bd14718d50ac16e4ed0762da895479cf688ae94 (diff)
HACK: staging: ion: Try to cache mappings to avoid cache invalidations
Since 4.12, much later narrowed down to commit 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and mapping"), we have seen graphics performance issues on the HiKey960. After chasing a number of other leads, I found that reverting the ION code to 4.11-era got the majority of the graphics performance back (there may yet be further EAS tweaks needed), which lead me to the dma_map_sg change. In talking w/ Laura and Liam, it was suspected that the extra cache operations were causing the trouble. Additionally, I found that part of the reason we didn't see this w/ the original HiKey board is that its (proprietary blob) GL code uses ion_mmap and ion_map_dma_buf is called very rarely, where as with HiKey960, the (also proprietary blob) GL code calls ion_map_dma_buf much more frequently via the kernel driver. Anyway, with the cause of the performance regression isolated, I've tried to find a way to improve the performance of the current code. This approach, which reworks my previous attempt, tries to use the dma-attributes to avoid doing cache operations if the current direction is the same. NOTE: Technically, this probably isn't the right solution for every ION user, thus the HACK prefix. However, for HiKey960 it resolves a pretty big interactive performance issue, and I think we should consider merging it so we can switch to 4.14 as the default kernel in the near term. Once a proper fix is found upstream, we can backport it. Change-Id: Ic7ce3dde5efe4c4dc7a1f3cdf138f0c572a2ba35 Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--drivers/staging/android/ion/ion.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 24cb666c9224..eea939be6306 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -219,6 +219,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
+ enum dma_data_direction dir;
};
static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
@@ -240,6 +241,7 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
a->table = table;
a->dev = dev;
+ a->dir = DMA_NONE;
INIT_LIST_HEAD(&a->list);
attachment->priv = a;
@@ -270,12 +272,19 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
{
struct ion_dma_buf_attachment *a = attachment->priv;
struct sg_table *table;
+ unsigned long dma_attr = 0;
table = a->table;
- if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
- direction))
- return ERR_PTR(-ENOMEM);
+ if (a->dir == direction)
+ dma_attr = DMA_ATTR_SKIP_CPU_SYNC;
+
+ if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents,
+ direction, dma_attr)) {
+ table = ERR_PTR(-ENOMEM);
+ } else {
+ a->dir = direction;
+ }
return table;
}
@@ -284,7 +293,14 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
struct sg_table *table,
enum dma_data_direction direction)
{
- dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+ struct ion_dma_buf_attachment *a = attachment->priv;
+ unsigned long dma_attr = 0;
+
+ if (direction == a->dir)
+ dma_attr = DMA_ATTR_SKIP_CPU_SYNC;
+
+ dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents,
+ direction, dma_attr);
}
static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)