Loading drivers/media/platform/msm/vidc/msm_smem.c +23 −22 Original line number Diff line number Diff line /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -147,9 +147,6 @@ static int msm_dma_put_device_address(u32 flags, } trace_msm_smem_buffer_iommu_op_start("UNMAP", 0, 0, 0, 0, 0); msm_dma_unmap_sg(mapping_info->dev, mapping_info->table->sgl, mapping_info->table->nents, DMA_BIDIRECTIONAL, mapping_info->buf); dma_buf_unmap_attachment(mapping_info->attach, mapping_info->table, DMA_BIDIRECTIONAL); dma_buf_detach(mapping_info->buf, mapping_info->attach); Loading Loading @@ -402,9 +399,25 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mem->size = size; mem->dma_buf = dbuf; rc = msm_dma_get_device_address(dbuf, align, &iova, &buffer_size, flags, buffer_type, session_type, res, &mem->mapping_info); if (rc) { dprintk(VIDC_ERR, "Failed to get device address: %d\n", rc); goto fail_device_address; } mem->device_addr = (u32)iova; if ((dma_addr_t)mem->device_addr != iova) { dprintk(VIDC_ERR, "iova(%pa) truncated to %#x", &iova, mem->device_addr); goto fail_device_address; } if (map_kernel) { mem->pages = size/PAGE_SIZE; for (page_count = 1; page_count <= mem->pages; page_count++) { dma_buf_begin_cpu_access(dbuf, DMA_BIDIRECTIONAL); for (page_count = 0; page_count < mem->pages; page_count++) { kvaddr = dma_buf_kmap(dbuf, page_count); if (IS_ERR_OR_NULL(kvaddr)) { dprintk(VIDC_ERR, Loading @@ -412,7 +425,7 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, rc = -EIO; goto fail_map; } if (page_count == 1) if (!page_count) mem->kvaddr = kvaddr; } } else { Loading @@ -420,20 +433,6 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mem->pages = 0; } rc = msm_dma_get_device_address(dbuf, align, &iova, &buffer_size, flags, buffer_type, session_type, res, &mem->mapping_info); if (rc) { dprintk(VIDC_ERR, "Failed to get device address: %d\n", rc); goto fail_device_address; } mem->device_addr = (u32)iova; if ((dma_addr_t)mem->device_addr != iova) { dprintk(VIDC_ERR, "iova(%pa) truncated to %#x", &iova, mem->device_addr); goto fail_device_address; } dprintk(VIDC_DBG, "%s: dma_buf = %pK, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x, flags = %#lx\n", __func__, mem->dma_buf, mem->device_addr, mem->size, Loading @@ -446,12 +445,13 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mapped_pages = page_count; if (mem->kvaddr) { kvaddr = mem->kvaddr; for (page_count = 1; page_count < mapped_pages; page_count++) { for (page_count = 0; page_count < mapped_pages; page_count++) { dma_buf_kunmap(mem->dma_buf, page_count, kvaddr); kvaddr += PAGE_SIZE; } mem->pages = 0; mem->kvaddr = NULL; dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL); } dma_buf_put(dbuf); fail_shared_mem_alloc: Loading @@ -477,12 +477,13 @@ static int free_dma_mem(struct msm_smem *mem) if (mem->kvaddr) { kvaddr = mem->kvaddr; for (page_count = 1; page_count <= mem->pages; page_count++) { for (page_count = 0; page_count < mem->pages; page_count++) { dma_buf_kunmap(mem->dma_buf, page_count, kvaddr); kvaddr += PAGE_SIZE; } mem->pages = 0; mem->kvaddr = NULL; dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL); } if (mem->dma_buf) { Loading drivers/media/platform/msm/vidc/msm_vidc.h +4 −4 Original line number Diff line number Diff line /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -26,9 +26,9 @@ enum smem_type { }; enum smem_prop { SMEM_UNCACHED = 1, SMEM_CACHED = 2, SMEM_SECURE = 3, SMEM_UNCACHED = 0x1, SMEM_CACHED = 0x2, SMEM_SECURE = 0x4, }; /* NOTE: if you change this enum you MUST update the Loading Loading
drivers/media/platform/msm/vidc/msm_smem.c +23 −22 Original line number Diff line number Diff line /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -147,9 +147,6 @@ static int msm_dma_put_device_address(u32 flags, } trace_msm_smem_buffer_iommu_op_start("UNMAP", 0, 0, 0, 0, 0); msm_dma_unmap_sg(mapping_info->dev, mapping_info->table->sgl, mapping_info->table->nents, DMA_BIDIRECTIONAL, mapping_info->buf); dma_buf_unmap_attachment(mapping_info->attach, mapping_info->table, DMA_BIDIRECTIONAL); dma_buf_detach(mapping_info->buf, mapping_info->attach); Loading Loading @@ -402,9 +399,25 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mem->size = size; mem->dma_buf = dbuf; rc = msm_dma_get_device_address(dbuf, align, &iova, &buffer_size, flags, buffer_type, session_type, res, &mem->mapping_info); if (rc) { dprintk(VIDC_ERR, "Failed to get device address: %d\n", rc); goto fail_device_address; } mem->device_addr = (u32)iova; if ((dma_addr_t)mem->device_addr != iova) { dprintk(VIDC_ERR, "iova(%pa) truncated to %#x", &iova, mem->device_addr); goto fail_device_address; } if (map_kernel) { mem->pages = size/PAGE_SIZE; for (page_count = 1; page_count <= mem->pages; page_count++) { dma_buf_begin_cpu_access(dbuf, DMA_BIDIRECTIONAL); for (page_count = 0; page_count < mem->pages; page_count++) { kvaddr = dma_buf_kmap(dbuf, page_count); if (IS_ERR_OR_NULL(kvaddr)) { dprintk(VIDC_ERR, Loading @@ -412,7 +425,7 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, rc = -EIO; goto fail_map; } if (page_count == 1) if (!page_count) mem->kvaddr = kvaddr; } } else { Loading @@ -420,20 +433,6 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mem->pages = 0; } rc = msm_dma_get_device_address(dbuf, align, &iova, &buffer_size, flags, buffer_type, session_type, res, &mem->mapping_info); if (rc) { dprintk(VIDC_ERR, "Failed to get device address: %d\n", rc); goto fail_device_address; } mem->device_addr = (u32)iova; if ((dma_addr_t)mem->device_addr != iova) { dprintk(VIDC_ERR, "iova(%pa) truncated to %#x", &iova, mem->device_addr); goto fail_device_address; } dprintk(VIDC_DBG, "%s: dma_buf = %pK, device_addr = %x, size = %d, kvaddr = %pK, buffer_type = %#x, flags = %#lx\n", __func__, mem->dma_buf, mem->device_addr, mem->size, Loading @@ -446,12 +445,13 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, mapped_pages = page_count; if (mem->kvaddr) { kvaddr = mem->kvaddr; for (page_count = 1; page_count < mapped_pages; page_count++) { for (page_count = 0; page_count < mapped_pages; page_count++) { dma_buf_kunmap(mem->dma_buf, page_count, kvaddr); kvaddr += PAGE_SIZE; } mem->pages = 0; mem->kvaddr = NULL; dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL); } dma_buf_put(dbuf); fail_shared_mem_alloc: Loading @@ -477,12 +477,13 @@ static int free_dma_mem(struct msm_smem *mem) if (mem->kvaddr) { kvaddr = mem->kvaddr; for (page_count = 1; page_count <= mem->pages; page_count++) { for (page_count = 0; page_count < mem->pages; page_count++) { dma_buf_kunmap(mem->dma_buf, page_count, kvaddr); kvaddr += PAGE_SIZE; } mem->pages = 0; mem->kvaddr = NULL; dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL); } if (mem->dma_buf) { Loading
drivers/media/platform/msm/vidc/msm_vidc.h +4 −4 Original line number Diff line number Diff line /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -26,9 +26,9 @@ enum smem_type { }; enum smem_prop { SMEM_UNCACHED = 1, SMEM_CACHED = 2, SMEM_SECURE = 3, SMEM_UNCACHED = 0x1, SMEM_CACHED = 0x2, SMEM_SECURE = 0x4, }; /* NOTE: if you change this enum you MUST update the Loading