UPSTREAM: dma-buf: cma_heap: Fix mutex locking section
Fix cma_heap_buffer mutex locking critical section to protect vmap_cnt and vaddr. Bug: 254441685 Fixes:a5d2d29e24("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation") Signed-off-by: Weizhao Ouyang <o451686892@gmail.com> Acked-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20220104073545.124244-1-o451686892@gmail.com (cherry picked from commit54329e6f7b) Signed-off-by: Lee Jones <joneslee@google.com> Change-Id: Ie83cf515450576799364d2e7476a4ff7286ff271
This commit is contained in:
parent
8d34761975
commit
01a7ade4e5
1 changed files with 4 additions and 2 deletions
|
|
@ -126,10 +126,11 @@ static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
|
||||||
struct cma_heap_buffer *buffer = dmabuf->priv;
|
struct cma_heap_buffer *buffer = dmabuf->priv;
|
||||||
struct dma_heap_attachment *a;
|
struct dma_heap_attachment *a;
|
||||||
|
|
||||||
|
mutex_lock(&buffer->lock);
|
||||||
|
|
||||||
if (buffer->vmap_cnt)
|
if (buffer->vmap_cnt)
|
||||||
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
|
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
|
||||||
|
|
||||||
mutex_lock(&buffer->lock);
|
|
||||||
list_for_each_entry(a, &buffer->attachments, list) {
|
list_for_each_entry(a, &buffer->attachments, list) {
|
||||||
if (!a->mapped)
|
if (!a->mapped)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -146,10 +147,11 @@ static int cma_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
|
||||||
struct cma_heap_buffer *buffer = dmabuf->priv;
|
struct cma_heap_buffer *buffer = dmabuf->priv;
|
||||||
struct dma_heap_attachment *a;
|
struct dma_heap_attachment *a;
|
||||||
|
|
||||||
|
mutex_lock(&buffer->lock);
|
||||||
|
|
||||||
if (buffer->vmap_cnt)
|
if (buffer->vmap_cnt)
|
||||||
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
|
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
|
||||||
|
|
||||||
mutex_lock(&buffer->lock);
|
|
||||||
list_for_each_entry(a, &buffer->attachments, list) {
|
list_for_each_entry(a, &buffer->attachments, list) {
|
||||||
if (!a->mapped)
|
if (!a->mapped)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue