Skip to content

Commit efbca04

Browse files
Tomer Tayarogabbay
authored andcommitted
accel/habanalabs: use exported size from dma_buf and not from phys_pg_pack
The 'exported_size' member in 'struct hl_vm_phys_pg_pack' is used to keep the exported dma-buf size, to be later used when the buffer is mapped. However it is possible that the same phys_pg_pack will be exported more than once, and independently of when the mapping takes place. Remove this member from the phys_pg_pack structure, and simply use the size in the dma-buf object as the exported size when mapping. Signed-off-by: Tomer Tayar <ttayar@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
1 parent dfdbc55 commit efbca04

2 files changed

Lines changed: 1 addition & 4 deletions

File tree

drivers/accel/habanalabs/common/habanalabs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,6 @@ struct hl_vm_hw_block_list_node {
21592159
* @pages: the physical page array.
21602160
* @npages: num physical pages in the pack.
21612161
* @total_size: total size of all the pages in this list.
2162-
* @exported_size: buffer exported size.
21632162
* @node: used to attach to deletion list that is used when all the allocations are cleared
21642163
* at the teardown of the context.
21652164
* @mapping_cnt: number of shared mappings.
@@ -2176,7 +2175,6 @@ struct hl_vm_phys_pg_pack {
21762175
u64 *pages;
21772176
u64 npages;
21782177
u64 total_size;
2179-
u64 exported_size;
21802178
struct list_head node;
21812179
atomic_t mapping_cnt;
21822180
u32 asid;

drivers/accel/habanalabs/common/memory.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ static struct sg_table *hl_map_dmabuf(struct dma_buf_attachment *attachment,
17191719
phys_pg_pack->pages,
17201720
phys_pg_pack->npages,
17211721
phys_pg_pack->page_size,
1722-
phys_pg_pack->exported_size,
1722+
hl_dmabuf->dmabuf->size,
17231723
attachment->dev,
17241724
dir);
17251725
else
@@ -2044,7 +2044,6 @@ static int export_dmabuf_from_addr(struct hl_ctx *ctx, u64 addr, u64 size, u64 o
20442044
if (rc)
20452045
goto dec_memhash_export_cnt;
20462046

2047-
phys_pg_pack->exported_size = size;
20482047
hl_dmabuf->phys_pg_pack = phys_pg_pack;
20492048
hl_dmabuf->memhash_hnode = hnode;
20502049
} else {

0 commit comments

Comments
 (0)