diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2016-11-16 04:49:12 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-11-30 05:18:17 -0500 |
commit | af5d2d208ada4d84c7a7bd0e4e0c288d1276225f (patch) | |
tree | a822054d7a576fc5f6e839d7ffebd91147061540 /drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |
parent | 5f6a2aa02b6927432c9f37e29c592e7efc4cb656 (diff) |
gpu: nvgpu: API to access fb memory
Add IOCTL API NVGPU_DBG_GPU_IOCTL_ACCESS_FB_MEMORY
to read/write fb/vidmem memory
Interface will accept dmabuf_fd of the buffer in vidmem,
offset into the buffer to access, temporary buffer
to copy data across API, size of read/write and
command indicating either read or write operation
API will first parse all the inputs, and then call
gk20a_vidbuf_access_memory() to complete fb access
gk20a_vidbuf_access_memory() will then just use
gk20a_mem_rd_n() or gk20a_mem_wr_n() depending
on the command issued
Bug 1804714
Jira DNVGPU-192
Change-Id: Iba3c42410abe12c2884d3b603fa33d27782e4c56
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1255556
(cherry picked from commit 2c49a8a79d93fc526adbf6f808484fa9a3fa2498)
Reviewed-on: http://git-master/r/1260471
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 5faff04b..dcc16fba 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -2301,6 +2301,39 @@ int gk20a_vidmem_get_space(struct gk20a *g, u64 *space) | |||
2301 | #endif | 2301 | #endif |
2302 | } | 2302 | } |
2303 | 2303 | ||
2304 | int gk20a_vidbuf_access_memory(struct gk20a *g, struct dma_buf *dmabuf, | ||
2305 | void *buffer, u64 offset, u64 size, u32 cmd) | ||
2306 | { | ||
2307 | #if defined(CONFIG_GK20A_VIDMEM) | ||
2308 | struct gk20a_vidmem_buf *vidmem_buf; | ||
2309 | struct mem_desc *mem; | ||
2310 | int err = 0; | ||
2311 | |||
2312 | if (gk20a_dmabuf_aperture(g, dmabuf) != APERTURE_VIDMEM) | ||
2313 | return -EINVAL; | ||
2314 | |||
2315 | vidmem_buf = dmabuf->priv; | ||
2316 | mem = vidmem_buf->mem; | ||
2317 | |||
2318 | switch (cmd) { | ||
2319 | case NVGPU_DBG_GPU_IOCTL_ACCESS_FB_MEMORY_CMD_READ: | ||
2320 | gk20a_mem_rd_n(g, mem, offset, buffer, size); | ||
2321 | break; | ||
2322 | |||
2323 | case NVGPU_DBG_GPU_IOCTL_ACCESS_FB_MEMORY_CMD_WRITE: | ||
2324 | gk20a_mem_wr_n(g, mem, offset, buffer, size); | ||
2325 | break; | ||
2326 | |||
2327 | default: | ||
2328 | err = -EINVAL; | ||
2329 | } | ||
2330 | |||
2331 | return err; | ||
2332 | #else | ||
2333 | return -ENOSYS; | ||
2334 | #endif | ||
2335 | } | ||
2336 | |||
2304 | static u64 gk20a_mm_get_align(struct gk20a *g, struct scatterlist *sgl, | 2337 | static u64 gk20a_mm_get_align(struct gk20a *g, struct scatterlist *sgl, |
2305 | enum gk20a_aperture aperture) | 2338 | enum gk20a_aperture aperture) |
2306 | { | 2339 | { |