drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers

Both coherent (uncached) and non-coherent (cached) buffers can have
their pages mapped to the device through the DMA mapping API. Make sure
to unmap any mapped page when freeing a buffer, regardless of its type.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
Laurent Pinchart 2017-04-21 00:33:57 +03:00 committed by Tomi Valkeinen
parent 24fbaca0e2
commit 930dc19c0b

View File

@ -316,18 +316,13 @@ static int get_pages(struct drm_gem_object *obj, struct page ***pages)
static void omap_gem_detach_pages(struct drm_gem_object *obj) static void omap_gem_detach_pages(struct drm_gem_object *obj)
{ {
struct omap_gem_object *omap_obj = to_omap_bo(obj); struct omap_gem_object *omap_obj = to_omap_bo(obj);
unsigned int npages = obj->size >> PAGE_SHIFT;
unsigned int i;
/* for non-cached buffers, ensure the new pages are clean because for (i = 0; i < npages; i++) {
* DSS, GPU, etc. are not cache coherent: if (omap_obj->dma_addrs[i])
*/ dma_unmap_page(obj->dev->dev, omap_obj->dma_addrs[i],
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) { PAGE_SIZE, DMA_BIDIRECTIONAL);
int i, npages = obj->size >> PAGE_SHIFT;
for (i = 0; i < npages; i++) {
if (omap_obj->dma_addrs[i])
dma_unmap_page(obj->dev->dev,
omap_obj->dma_addrs[i],
PAGE_SIZE, DMA_BIDIRECTIONAL);
}
} }
kfree(omap_obj->dma_addrs); kfree(omap_obj->dma_addrs);