diff options
author | Yuri Nudelman <ynudelman@habana.ai> | 2022-03-23 16:08:22 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-22 22:01:19 +0300 |
commit | 4e63ce6af63f3db7f922e3c564f23ac606218a3d (patch) | |
tree | d5780c545caae783db86458399c4bdf0e2860799 /drivers/misc/habanalabs/common/memory.c | |
parent | de3484dfaa04a97cd0a11e5367635d36f5b49fee (diff) | |
download | linux-4e63ce6af63f3db7f922e3c564f23ac606218a3d.tar.xz |
habanalabs: hide memory manager page shift
The new unified memory manager uses page offset to pass buffer handle
during the mmap operation. One problem with this approach is that it
requires the handle to always be divisible by the page size, else, the
user would not be able to pass it correctly as an argument to the mmap
system call.
Previously, this was achieved by shifting the handle left after alloc
operation, and shifting it right before get operation. This was done in
the user code. This creates code duplication, and, what's worse,
requires some knowledge from the user regarding the handle internal
structure, hurting the encapsulation.
This patch encloses all the page shifts inside memory manager functions.
This way, the user can take the handle as a black box, and simply use
it, without any concert about how it actually works.
Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/habanalabs/common/memory.c')
-rw-r--r-- | drivers/misc/habanalabs/common/memory.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c index 6face45c57e3..e7a0c44c487d 100644 --- a/drivers/misc/habanalabs/common/memory.c +++ b/drivers/misc/habanalabs/common/memory.c @@ -2140,7 +2140,8 @@ free_mem: return -ENOMEM; } -static struct hl_mmap_mem_buf_ops hl_ts_behavior = { +static struct hl_mmap_mem_buf_behavior hl_ts_behavior = { + .mem_id = HL_MMAP_TYPE_TS_BUFF, .mmap = hl_ts_mmap, .alloc = hl_ts_alloc_buf, .release = ts_buff_release, @@ -2175,12 +2176,7 @@ static int allocate_timestamps_buffers(struct hl_fpriv *hpriv, struct hl_mem_in if (!buf) return -ENOMEM; - /* TODO: - * Remove HL_MMAP_TYPE_TS_BUFF. - * Embedding type in handle will no longer be needed as soon as we - * switch to using a single memory manager for all memory types. - */ - *handle = ((u64)buf->handle | HL_MMAP_TYPE_TS_BUFF) << PAGE_SHIFT; + *handle = buf->handle; return 0; } |