On Wed, Aug 29, 2012 at 11:52 AM, Zhangfei Gao zhangfei.gao@marvell.com wrote:
Extend dirty bit per PAGE_SIZE Page wised cache flush is supported and only takes effect for dirty buffer
Signed-off-by: Zhangfei Gao zhangfei.gao@marvell.com
drivers/gpu/ion/ion_carveout_heap.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/ion/ion_carveout_heap.c b/drivers/gpu/ion/ion_carveout_heap.c index 13f6e8d..24f8ef2 100644 --- a/drivers/gpu/ion/ion_carveout_heap.c +++ b/drivers/gpu/ion/ion_carveout_heap.c @@ -88,25 +88,36 @@ struct sg_table *ion_carveout_heap_map_dma(struct ion_heap *heap, struct ion_buffer *buffer) { struct sg_table *table;
int ret;
struct scatterlist *sg;
int ret, i;
int nents = PAGE_ALIGN(buffer->size) / PAGE_SIZE;
You can't use PAGE_ALIGN() & PAGE_SIZE so simply. Look at these code in below.
struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *heap_data) { struct ion_carveout_heap *carveout_heap;
carveout_heap = kzalloc(sizeof(struct ion_carveout_heap), GFP_KERNEL); if (!carveout_heap) return ERR_PTR(-ENOMEM);
carveout_heap->pool = gen_pool_create(12, -1);
Although 12 means PAGE_SIZE, you need to make 12 & your PAGE_SIZE consistent. So you need to change it to gen_pool_create(PAGE_SHIFT, -1).
Because PAGE_SIZE may be different on different architecture.
struct page *page = phys_to_page(buffer->priv_phys); table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) return ERR_PTR(-ENOMEM);
ret = sg_alloc_table(table, 1, GFP_KERNEL);
ret = sg_alloc_table(table, nents, GFP_KERNEL); if (ret) { kfree(table); return ERR_PTR(ret); }
sg_set_page(table->sgl, phys_to_page(buffer->priv_phys), buffer->size,
0);
sg = table->sgl;
for (i = 0; i < nents; i++) {
sg_set_page(sg, page + i, PAGE_SIZE, 0);
sg = sg_next(sg);
}
return table;
}
void ion_carveout_heap_unmap_dma(struct ion_heap *heap, struct ion_buffer *buffer) {
sg_free_table(buffer->sg_table);
if (buffer->sg_table)
sg_free_table(buffer->sg_table);
kfree(buffer->sg_table);
What's this? You needn't change anything at here. Please read sg_free_table().
}
void *ion_carveout_heap_map_kernel(struct ion_heap *heap,
1.7.1