video: adf: memblock: map buffer for dma
Change-Id: I4df13c8b45b57fd0594b5e7bf351a4da33a8cb11 Signed-off-by: Greg Hackmann <ghackmann@google.com>
This commit is contained in:
parent
5bd7300657
commit
8e5174c52b
1 changed files with 13 additions and 3 deletions
|
@ -28,7 +28,7 @@ static struct sg_table *adf_memblock_map(struct dma_buf_attachment *attach,
|
||||||
unsigned long pfn = PFN_DOWN(pdata->base);
|
unsigned long pfn = PFN_DOWN(pdata->base);
|
||||||
struct page *page = pfn_to_page(pfn);
|
struct page *page = pfn_to_page(pfn);
|
||||||
struct sg_table *table;
|
struct sg_table *table;
|
||||||
int ret;
|
int nents, ret;
|
||||||
|
|
||||||
table = kzalloc(sizeof(*table), GFP_KERNEL);
|
table = kzalloc(sizeof(*table), GFP_KERNEL);
|
||||||
if (!table)
|
if (!table)
|
||||||
|
@ -36,12 +36,21 @@ static struct sg_table *adf_memblock_map(struct dma_buf_attachment *attach,
|
||||||
|
|
||||||
ret = sg_alloc_table(table, 1, GFP_KERNEL);
|
ret = sg_alloc_table(table, 1, GFP_KERNEL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err_alloc;
|
||||||
|
|
||||||
sg_set_page(table->sgl, page, attach->dmabuf->size, 0);
|
sg_set_page(table->sgl, page, attach->dmabuf->size, 0);
|
||||||
|
|
||||||
|
nents = dma_map_sg(attach->dev, table->sgl, 1, direction);
|
||||||
|
if (!nents) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto err_map;
|
||||||
|
}
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
|
|
||||||
err:
|
err_map:
|
||||||
|
sg_free_table(table);
|
||||||
|
err_alloc:
|
||||||
kfree(table);
|
kfree(table);
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +58,7 @@ err:
|
||||||
static void adf_memblock_unmap(struct dma_buf_attachment *attach,
|
static void adf_memblock_unmap(struct dma_buf_attachment *attach,
|
||||||
struct sg_table *table, enum dma_data_direction direction)
|
struct sg_table *table, enum dma_data_direction direction)
|
||||||
{
|
{
|
||||||
|
dma_unmap_sg(attach->dev, table->sgl, 1, direction);
|
||||||
sg_free_table(table);
|
sg_free_table(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue