Skip to content

Commit 878ebc1

Browse files
Tomer Tayarogabbay
authored andcommitted
accel/habanalabs: set hl_dmabuf_priv.device_address only when needed
The device_address member of 'struct hl_dmabuf_priv' is used only when virtual device memory is not supported and dma-buf is exported from address. Set the value of this field only when it is relevant, and add "phys" to its name so it would be clearer that it can't be a device virtual address. 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 bb644f6 commit 878ebc1

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/accel/habanalabs/common/habanalabs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,16 +1811,16 @@ struct hl_cs_counters_atomic {
18111811
* @phys_pg_pack: pointer to physical page pack if the dma-buf was exported
18121812
* where virtual memory is supported.
18131813
* @memhash_hnode: pointer to the memhash node. this object holds the export count.
1814-
* @device_address: physical address of the device's memory. Relevant only
1815-
* if phys_pg_pack is NULL (dma-buf was exported from address).
1816-
* The total size can be taken from the dmabuf object.
1814+
* device_phys_addr: physical address of the device's memory. Relevant only
1815+
* if phys_pg_pack is NULL (dma-buf was exported from address).
1816+
* The total size can be taken from the dmabuf object.
18171817
*/
18181818
struct hl_dmabuf_priv {
18191819
struct dma_buf *dmabuf;
18201820
struct hl_ctx *ctx;
18211821
struct hl_vm_phys_pg_pack *phys_pg_pack;
18221822
struct hl_vm_hash_node *memhash_hnode;
1823-
uint64_t device_address;
1823+
u64 device_phys_addr;
18241824
};
18251825

18261826
#define HL_CS_OUTCOME_HISTORY_LEN 256

drivers/accel/habanalabs/common/memory.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ static struct sg_table *hl_map_dmabuf(struct dma_buf_attachment *attachment,
17311731
npages = phys_pg_pack->npages;
17321732
page_size = phys_pg_pack->page_size;
17331733
} else {
1734-
pages = &hl_dmabuf->device_address;
1734+
pages = &hl_dmabuf->device_phys_addr;
17351735
npages = 1;
17361736
page_size = hl_dmabuf->dmabuf->size;
17371737
}
@@ -2064,9 +2064,9 @@ static int export_dmabuf_from_addr(struct hl_ctx *ctx, u64 addr, u64 size, u64 o
20642064
rc = validate_export_params_no_mmu(hdev, export_addr, size);
20652065
if (rc)
20662066
goto err_free_dmabuf_wrapper;
2067-
}
20682067

2069-
hl_dmabuf->device_address = export_addr;
2068+
hl_dmabuf->device_phys_addr = export_addr;
2069+
}
20702070

20712071
rc = export_dmabuf(ctx, hl_dmabuf, size, flags, dmabuf_fd);
20722072
if (rc)

0 commit comments

Comments
 (0)