Commit Graph

8 Commits

Author SHA1 Message Date
Patrick Daly
03f60c8a10 mem-buf: Fix refcount issue with mem_buf_remove_mem
RemoteAlloc allocates memory and provides it to the tui carveout heap.
Other clients may suballocate from this heap. Both of these uses are
represented via a fd. Clearly, we cannot free the memory from RemoteAlloc,
until all clients of the tui carveout heap have closed their fd.

Previously, we assumed that the client would simply place these calls in
the proper order - release dma_buf fds first, followed by RemoteAlloc fds.
However, there are situations where this does not occur. One example is
a process crash, where fds are closed in no particular order. Another
example is when a kthread calls fput(). In this case the actual file
release callback is defered onto a workqueue.

To solve these issues, modify the carveout heap to increase the refcount
of the RemoteAlloc fd when carveout_alloc() is called.

Change-Id: I878d4883ec17bccf5c6c08711ba7150d9ea76597
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-09-12 22:03:39 -07:00
Chris Goldsworthy
898db71bec dma-heap: qcom: Implement prefetch and drain
Bring over the prefetch and drain implementation from
drivers/staging/android/ion/heaps/ion_system_secure_heap.c from
msm-5.4, as of commit 48a845e5f683 ("ion: Use a freezable unbound
workqueue for the memory prefetch work items"), which is used for
asynchronously pre-loading the pools for clients who want the pools
filled with a certain amount of memory in advance of their use case
starting.

Change-Id: I5a2df4b75d86eb917cd0848107e7f920fb735434
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2021-04-02 14:14:05 -07:00
Patrick Daly
b65d850644 dma-heaps: qcom: Export carveout_heap_add_memory
Allow this symbols to be used by kernel modules, specifically
mem-buf for its usecase which allows SVM to request memory from
the PVM, and add it to a SVM carveout heap.

Change-Id: I9f285f890285f320d2237b03441d6b8c66ef539a
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-02-17 18:19:12 -08:00
Chris Goldsworthy
b6742595b0 dma-heap: qcom: Add SPU TZ, Modem carveout support
Make the needed changes in the secure memory handling code to support
TZ and modem use cases.

Change-Id: I3905f7d6eed50c0f511f19dba1776d85b82b2396
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2020-12-09 14:11:43 -08:00
Chris Goldsworthy
18a8ed0372 dma-heap: qcom: Add VMID field for SG ops
Add a VMID field so that clients who currently use DMA-BUF get flags
can continue to check the security status of a buffer.

Change-Id: If012f01f521cb30d817529194561183187c3f227
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2020-12-09 14:11:41 -08:00
Chris Goldsworthy
37d2967551 dma-heap: qcom: Add the carveout heap
Add the carveout heap, which is to be used for devices requiring
contiguous memory on other VMs.

Change-Id: I54154f94f1c315ce2bc5ef5a5b7ac1918464a073
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2020-12-09 14:11:36 -08:00
Chris Goldsworthy
a969318ee8 dma-heap: qcom: Create base DMA-BUF heap module
Add the base file for our DMA-BUF heap module, which will create all
of our DMA-BUF heaps. Add the needed utilities and constants to
support the DMA-BUF Heap DT file, which will be used for the CMA and
carveout heap on our device.

Change-Id: I079587aedab385f4fac3c7d46ebdd72eb0aa5a20
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2020-10-06 10:40:58 -07:00
Chris Goldsworthy
f9ce4c0c37 dma-heap: qcom: Rename headers and remove unused header
Rename our kernel-internal DMA-BUF Heap headers. Remove header define
our version of the heap helper buffer, which will not longer be used.

Change-Id: Ib1c7f1c00aa922ef81b45f23306e91faab32be92
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
2020-09-30 09:50:31 -07:00