Skip to content

Commit 834f304

Browse files
suijingfenglynxeye-dev
authored andcommitted
drm/etnaviv: Fix page property being used for non writecombine buffers
In the etnaviv_gem_vmap_impl() function, the driver vmap whatever buffers with write combine(WC) page property, this is incorrect. Cached buffers should be mapped with the cached page property and uncached buffers should be mapped with the uncached page property. Fixes: a0a5ab3 ("drm/etnaviv: call correct function when trying to vmap a DMABUF") Signed-off-by: Sui Jingfeng <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 2db0005 commit 834f304

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gem.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,27 @@ void *etnaviv_gem_vmap(struct drm_gem_object *obj)
342342
static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj)
343343
{
344344
struct page **pages;
345+
pgprot_t prot;
345346

346347
lockdep_assert_held(&obj->lock);
347348

348349
pages = etnaviv_gem_get_pages(obj);
349350
if (IS_ERR(pages))
350351
return NULL;
351352

352-
return vmap(pages, obj->base.size >> PAGE_SHIFT,
353-
VM_MAP, pgprot_writecombine(PAGE_KERNEL));
353+
switch (obj->flags & ETNA_BO_CACHE_MASK) {
354+
case ETNA_BO_CACHED:
355+
prot = PAGE_KERNEL;
356+
break;
357+
case ETNA_BO_UNCACHED:
358+
prot = pgprot_noncached(PAGE_KERNEL);
359+
break;
360+
case ETNA_BO_WC:
361+
default:
362+
prot = pgprot_writecombine(PAGE_KERNEL);
363+
}
364+
365+
return vmap(pages, obj->base.size >> PAGE_SHIFT, VM_MAP, prot);
354366
}
355367

356368
static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op)

0 commit comments

Comments
 (0)