mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: specify DMA_TO_DEVICE direction to map_attachment for RO maps
nvgpu does map attachment with DMA_BIDIRECTIONAL direction for buffers irrespective of the GPU mapping type. nvmap will allow map attachment with only DMA_TO_DEVICE direction for RO buffers for secure buffer access. nvgpu does RO GPU mapping if the buffer is RO for CPU or user requests to map as RO. In both cases the dma_buf map attachment should be done with DMA_TO_DEVICE direction as the intent for accessing the SGT is reading from GPU. Also, map the gpfifo buffer as read_only as it is intended to be read only. The userd buffer is accessed by the GPU through iova and is not GMMU mapped. Bug 200731819 Change-Id: Ifc60973f298f7cacab16c5dedecbb40c5f33ed1d Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2539312 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
7e1f9b8b19
commit
e099f8b1fd
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/dma-direction.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <uapi/linux/nvgpu.h>
|
||||
|
||||
@@ -265,7 +266,10 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm,
|
||||
return err;
|
||||
}
|
||||
|
||||
sgt = nvgpu_mm_pin(dev, dmabuf, &attachment);
|
||||
sgt = nvgpu_mm_pin(dev, dmabuf, &attachment,
|
||||
(buffer_rw_mode == gk20a_mem_flag_read_only) ||
|
||||
(map_access_requested == NVGPU_VM_MAP_ACCESS_READ_ONLY) ?
|
||||
DMA_TO_DEVICE : DMA_BIDIRECTIONAL);
|
||||
if (IS_ERR(sgt)) {
|
||||
nvgpu_warn(g, "Failed to pin dma_buf!");
|
||||
return PTR_ERR(sgt);
|
||||
|
||||
Reference in New Issue
Block a user