diff options
author | Yuri Nudelman <ynudelman@habana.ai> | 2022-03-23 14:08:22 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-22 21:01:19 +0200 |
commit | 4e63ce6af63f3db7f922e3c564f23ac606218a3d (patch) | |
tree | d5780c545caae783db86458399c4bdf0e2860799 /drivers/misc/habanalabs/common/command_submission.c | |
parent | habanalabs: Add separate poll interval value for protocol (diff) | |
download | linux-4e63ce6af63f3db7f922e3c564f23ac606218a3d.tar.xz linux-4e63ce6af63f3db7f922e3c564f23ac606218a3d.zip |
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/command_submission.c')
-rw-r--r-- | drivers/misc/habanalabs/common/command_submission.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/misc/habanalabs/common/command_submission.c b/drivers/misc/habanalabs/common/command_submission.c index 6c13ae3ffa7c..a189157be104 100644 --- a/drivers/misc/habanalabs/common/command_submission.c +++ b/drivers/misc/habanalabs/common/command_submission.c @@ -2952,7 +2952,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, bool register_ts_record, u64 ts_handle, u64 ts_offset, u32 *status, u64 *timestamp) { - u32 cq_patched_handle, ts_patched_handle; + u32 cq_patched_handle; struct hl_user_pending_interrupt *pend; struct hl_mmap_mem_buf *buf; struct hl_cb *cq_cb; @@ -2974,15 +2974,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, if (register_ts_record) { dev_dbg(hdev->dev, "Timestamp registration: interrupt id: %u, ts offset: %llu, cq_offset: %llu\n", interrupt->interrupt_id, ts_offset, cq_counters_offset); - - /* TODO: - * See if this can be removed. - * Embedding type in handle will no longer be needed as soon as we - * switch to using a single memory manager for all memory types. - * We may still need the page shift, though. - */ - ts_patched_handle = lower_32_bits(ts_handle >> PAGE_SHIFT); - buf = hl_mmap_mem_buf_get(mmg, ts_patched_handle); + buf = hl_mmap_mem_buf_get(mmg, ts_handle); if (!buf) { rc = -EINVAL; goto put_cq_cb; |