[PATCH 43/48] staging: etnaviv: map all buffers to the GPU

Lucas Stach l.stach at pengutronix.de
Fri Sep 25 04:57:55 PDT 2015


This redefines how we do cache handling in the following way:

All buffer are pushed into the GPU domain initially, this will only
be done when populating the buffers backing store, but for simplicity
userspace can assume that the buffer is owned by the GPU as soon as it
constructs a GEM handle. The memory is only implicitly pulled back into
the CPU domain when destroying the handle.

Uncached and writecombined buffers can stay in the GPU domain for their
entire lifetime, as any modification to them will be seen by the GPU
either immediately or latest when the write buffers get flushed when
linking a new submit into the GPUs command stream.

If any modifications needs to be done to a cached buffer they must be
pulled into the CPU domain before and pushed to the GPU afterwards in
an explicit manner.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 drivers/staging/etnaviv/etnaviv_gem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 3e08f0694021..5ee43861095d 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -31,9 +31,8 @@ static void etnaviv_gem_scatter_map(struct etnaviv_gem_object *etnaviv_obj)
 	 * For non-cached buffers, ensure the new pages are clean
 	 * because display controller, GPU, etc. are not coherent.
 	 */
-	if (etnaviv_obj->flags & (ETNA_BO_WC|ETNA_BO_CACHED)) {
+	if (etnaviv_obj->flags & ETNA_BO_CACHE_MASK) {
 		dma_map_sg(dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
-		dma_unmap_sg(dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
 	} else {
 		struct scatterlist *sg;
 		unsigned int i;
@@ -67,8 +66,7 @@ static void etnaviv_gem_scatterlist_unmap(struct etnaviv_gem_object *etnaviv_obj
 	 * written into the remainder of the region, this can
 	 * discard those writes.
 	 */
-	if (etnaviv_obj->flags & (ETNA_BO_WC|ETNA_BO_CACHED)) {
-		dma_map_sg(dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
+	if (etnaviv_obj->flags & ETNA_BO_CACHE_MASK) {
 		dma_unmap_sg(dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
 	}
 }
-- 
2.5.1



More information about the dri-devel mailing list