Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281428
b: refs/heads/master
c: f3bc9d2
h: refs/heads/master
v: v3
  • Loading branch information
Rob Clark authored and Greg Kroah-Hartman committed Dec 22, 2011
1 parent e25aa2c commit 396e635
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c25b3c9a43ced0affb77be68d2ddcb89ddd17917
refs/heads/master: f3bc9d24cb4a221bd3530c445fa08e33775e7707
30 changes: 30 additions & 0 deletions trunk/drivers/staging/omapdrm/omap_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct omap_gem_object {
*/
struct page **pages;

/** addresses corresponding to pages in above array */
dma_addr_t *addrs;

/**
* Virtual address, if mapped.
*/
Expand Down Expand Up @@ -208,6 +211,19 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
return PTR_ERR(pages);
}

/* for non-cached buffers, ensure the new pages are clean because
* DSS, GPU, etc. are not cache coherent:
*/
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
int i, npages = obj->size >> PAGE_SHIFT;
dma_addr_t *addrs = kmalloc(npages * sizeof(addrs), GFP_KERNEL);
for (i = 0; i < npages; i++) {
addrs[i] = dma_map_page(obj->dev->dev, pages[i],
0, PAGE_SIZE, DMA_BIDIRECTIONAL);
}
omap_obj->addrs = addrs;
}

omap_obj->pages = pages;
return 0;
}
Expand All @@ -216,6 +232,20 @@ static int omap_gem_attach_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);

/* for non-cached buffers, ensure the new pages are clean because
* DSS, GPU, etc. are not cache coherent:
*/
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
int i, npages = obj->size >> PAGE_SHIFT;
for (i = 0; i < npages; i++) {
dma_unmap_page(obj->dev->dev, omap_obj->addrs[i],
PAGE_SIZE, DMA_BIDIRECTIONAL);
}
kfree(omap_obj->addrs);
omap_obj->addrs = NULL;
}

_drm_gem_put_pages(obj, omap_obj->pages, true, false);
omap_obj->pages = NULL;
}
Expand Down

0 comments on commit 396e635

Please sign in to comment.