Skip to content

Refactor memory mapping with DSP address tracking#299

Open
quic-vkatoch wants to merge 2 commits intoqualcomm:developmentfrom
quic-vkatoch:fix-mmap
Open

Refactor memory mapping with DSP address tracking#299
quic-vkatoch wants to merge 2 commits intoqualcomm:developmentfrom
quic-vkatoch:fix-mmap

Conversation

@quic-vkatoch
Copy link
Contributor

@quic-vkatoch quic-vkatoch commented Feb 20, 2026

Refactor memory mapping implementation to use internal functions with DSP virtual address tracking and simplify allocation logic.

  • Remove unused rpcmem_set_dmabuf_name() dummy function
  • Add fastrpc_mmap_internal() and fastrpc_munmap_internal() for DSP address management
  • Extract common mmap logic into fastrpc_mmap_helper() to eliminate code duplication
  • Simplify apps_mem_request_map64() to always allocate in userspace
  • Route unmap operations based on mapping type in apps_mem_request_unmap64()

Remove rpcmem_set_dmabuf_name() which was a no-op dummy function.
Cleaned up declaration, implementation, and all call sites.

Signed-off-by: Vinayak Katoch <[email protected]>
@quic-vkatoch quic-vkatoch changed the title Add internal mmap/munmap functions with DSP address tracking Refactor memory mapping with DSP address tracking Feb 22, 2026
@quic-vkatoch quic-vkatoch marked this pull request as ready for review February 23, 2026 06:08
ekanshibu
ekanshibu previously approved these changes Feb 26, 2026
@ekanshibu ekanshibu enabled auto-merge February 26, 2026 15:04
auto-merge was automatically disabled February 26, 2026 17:25

Head branch was pushed to by a user without write access

Introduce fastrpc_mmap_internal() and fastrpc_munmap_internal() to handle
buffer mapping with DSP virtual address management. These functions maintain
mappings in the static map list and enable lookup by DSP virtual address.

Extract common mmap logic into fastrpc_mmap_helper() to eliminate code
duplication between fastrpc_mmap() and fastrpc_mmap_internal().

Simplify apps_mem_request_map64() by removing conditional allocation logic
and always allocating in userspace, then using fastrpc_mmap_internal() for
mapping. Update apps_mem_request_unmap64() to route to appropriate unmap
function based on mapping type:
- FASTRPC_ALLOC_HLOS_FD: use fastrpc_munmap()
- ADSP_MMAP_HEAP_ADDR/ADSP_MMAP_REMOTE_HEAP_ADDR: use remote_munmap64()
- Other allocations: use fastrpc_munmap_internal()

Signed-off-by: Vinayak Katoch <[email protected]>
fd = rpcmem_to_fd_internal(buf);
VERIFYC(fd > 0, AEE_EBADPARM);
}
VERIFYC(NULL != (buf = rpcmem_alloc_internal(heapid, lflags, len)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for signed or unsigned we will allocate in user space always now, why? is okay to allocate signed memory in user space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn’t a clear or specific technical reason for this. However, allocating it in user space is acceptable and works for our use case.

*
* @return 0 on success, error code on failure
*/
int fastrpc_mmap_internal(int domain, int fd, void *vaddr, int offset, size_t length, uint32_t flags, uint64_t *raddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for offset shouldn't we use unsigned vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since fastrpc_mmap uses an int for the offset, we are keeping it the same here.


VERIFY(AEE_SUCCESS == (nErr = fastrpc_init_once()));

VERIFYC(raddr != NULL, AEE_EBADPARM);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify requested length is greater than 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already handled earlier inside the rpcmem_alloc_internal function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants