diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c index 1c10ce73d..a98c5cb07 100644 --- a/drivers/gpu/nvgpu/os/linux/cde.c +++ b/drivers/gpu/nvgpu/os/linux/cde.c @@ -1,7 +1,7 @@ /* * Color decompression engine support * - * Copyright (c) 2014-2020, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2014-2021, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -1042,6 +1042,9 @@ __releases(&l->cde_app->mutex) const s16 compbits_kind = 0; u32 submit_op; struct dma_buf_attachment *attachment; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif nvgpu_log(g, gpu_dbg_cde, "compbits_byte_offset=%llu scatterbuffer_byte_offset=%llu", compbits_byte_offset, scatterbuffer_byte_offset); @@ -1128,10 +1131,14 @@ __releases(&l->cde_app->mutex) struct sg_table *sgt; void *scatter_buffer; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + err = dma_buf_vmap(compbits_scatter_buf, &map); + surface = err ? NULL : map.vaddr; +#else surface = dma_buf_vmap(compbits_scatter_buf); - if (IS_ERR(surface)) { - nvgpu_warn(g, - "dma_buf_vmap failed"); +#endif + if (!surface) { + nvgpu_warn(g, "dma_buf_vmap failed"); err = -EINVAL; goto exit_unmap_vaddr; } @@ -1178,7 +1185,11 @@ __releases(&l->cde_app->mutex) goto exit_unmap_surface; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_vunmap(compbits_scatter_buf, &map); +#else dma_buf_vunmap(compbits_scatter_buf, surface); +#endif surface = NULL; } @@ -1268,7 +1279,11 @@ __releases(&l->cde_app->mutex) exit_unmap_surface: if (surface) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_vunmap(compbits_scatter_buf, &map); +#else dma_buf_vunmap(compbits_scatter_buf, surface); +#endif } exit_unmap_vaddr: nvgpu_vm_unmap(cde_ctx->vm, map_vaddr, NULL); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 8e417d85c..d0648cdc7 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -1,7 +1,7 @@ /* * GK20A Graphics channel * - * Copyright (c) 2011-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2021, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -136,8 +136,15 @@ void gk20a_channel_free_cycle_stats_buffer(struct nvgpu_channel *ch) /* disable existing cyclestats buffer */ nvgpu_mutex_acquire(&ch->cyclestate.cyclestate_buffer_mutex); if (priv->cyclestate_buffer_handler) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; + + dma_buf_map_set_vaddr(&map, ch->cyclestate.cyclestate_buffer); + dma_buf_vunmap(priv->cyclestate_buffer_handler, &map); +#else dma_buf_vunmap(priv->cyclestate_buffer_handler, ch->cyclestate.cyclestate_buffer); +#endif dma_buf_put(priv->cyclestate_buffer_handler); priv->cyclestate_buffer_handler = NULL; ch->cyclestate.cyclestate_buffer = NULL; @@ -149,6 +156,10 @@ void gk20a_channel_free_cycle_stats_buffer(struct nvgpu_channel *ch) int gk20a_channel_cycle_stats(struct nvgpu_channel *ch, int dmabuf_fd) { struct dma_buf *dmabuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; + int err; +#endif void *virtual_address; struct nvgpu_channel_linux *priv = ch->os_priv; @@ -162,7 +173,12 @@ int gk20a_channel_cycle_stats(struct nvgpu_channel *ch, int dmabuf_fd) dmabuf = dma_buf_get(dmabuf_fd); if (IS_ERR(dmabuf)) return PTR_ERR(dmabuf); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + err = dma_buf_vmap(dmabuf, &map); + virtual_address = err ? NULL : map.vaddr; +#else virtual_address = dma_buf_vmap(dmabuf); +#endif if (!virtual_address) return -ENOMEM; @@ -208,6 +224,9 @@ int gk20a_attach_cycle_stats_snapshot(struct nvgpu_channel *ch, struct gk20a *g = ch->g; struct gk20a_cs_snapshot_client_linux *client_linux; struct gk20a_cs_snapshot_client *client; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif nvgpu_mutex_acquire(&ch->cs_client_mutex); if (ch->cs_client) { @@ -236,8 +255,14 @@ int gk20a_attach_cycle_stats_snapshot(struct nvgpu_channel *ch, goto err_put; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + ret = dma_buf_vmap(client_linux->dma_handler, &map); + client->snapshot = ret ? NULL : + (struct gk20a_cs_snapshot_fifo *)map.vaddr; +#else client->snapshot = (struct gk20a_cs_snapshot_fifo *) dma_buf_vmap(client_linux->dma_handler); +#endif if (!client->snapshot) { ret = -ENOMEM; goto err_put; @@ -281,9 +306,18 @@ int gk20a_channel_free_cycle_stats_snapshot(struct nvgpu_channel *ch) ret = nvgpu_css_detach(ch, ch->cs_client); if (client_linux->dma_handler) { - if (ch->cs_client->snapshot) + if (ch->cs_client->snapshot) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; + + dma_buf_map_set_vaddr(&map, ch->cs_client->snapshot); + dma_buf_vunmap(client_linux->dma_handler, &map); +#else dma_buf_vunmap(client_linux->dma_handler, ch->cs_client->snapshot); +#endif + } + dma_buf_put(client_linux->dma_handler); } @@ -340,7 +374,14 @@ static void gk20a_channel_free_error_notifiers(struct nvgpu_channel *ch) nvgpu_mutex_acquire(&priv->error_notifier.mutex); if (priv->error_notifier.dmabuf) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; + + dma_buf_map_set_vaddr(&map, priv->error_notifier.vaddr); + dma_buf_vunmap(priv->error_notifier.dmabuf, &map); +#else dma_buf_vunmap(priv->error_notifier.dmabuf, priv->error_notifier.vaddr); +#endif dma_buf_put(priv->error_notifier.dmabuf); priv->error_notifier.dmabuf = NULL; priv->error_notifier.notification = NULL; @@ -353,6 +394,10 @@ static int gk20a_init_error_notifier(struct nvgpu_channel *ch, struct nvgpu_set_error_notifier *args) { struct dma_buf *dmabuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; + int err; +#endif void *va; u64 end = args->offset + sizeof(struct nvgpu_notification); struct nvgpu_channel_linux *priv = ch->os_priv; @@ -380,7 +425,12 @@ static int gk20a_init_error_notifier(struct nvgpu_channel *ch, nvgpu_speculation_barrier(); /* map handle */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + err = dma_buf_vmap(dmabuf, &map); + va = err ? NULL : map.vaddr; +#else va = dma_buf_vmap(dmabuf); +#endif if (!va) { dma_buf_put(dmabuf); pr_err("Cannot map notifier handle\n"); @@ -697,6 +747,9 @@ static int gk20a_channel_wait_semaphore(struct nvgpu_channel *ch, u32 payload, u32 timeout) { struct dma_buf *dmabuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif void *data; int ret = 0; @@ -724,7 +777,12 @@ static int gk20a_channel_wait_semaphore(struct nvgpu_channel *ch, nvgpu_speculation_barrier(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + ret = dma_buf_vmap(dmabuf, &map); + data = ret ? NULL : map.vaddr; +#else data = dma_buf_vmap(dmabuf); +#endif if (!data) { nvgpu_err(ch->g, "failed to map semaphore memory"); ret = -EINVAL; @@ -737,7 +795,11 @@ static int gk20a_channel_wait_semaphore(struct nvgpu_channel *ch, nvgpu_channel_check_unserviceable(ch), timeout); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_vunmap(dmabuf, &map); +#else dma_buf_vunmap(dmabuf, data); +#endif cleanup_put: dma_buf_put(dmabuf); return ret; @@ -747,6 +809,9 @@ static int gk20a_channel_wait(struct nvgpu_channel *ch, struct nvgpu_wait_args *args) { struct dma_buf *dmabuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif struct gk20a *g = ch->g; struct notification *notif; struct timespec64 tv; @@ -783,12 +848,16 @@ static int gk20a_channel_wait(struct nvgpu_channel *ch, nvgpu_speculation_barrier(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + ret = dma_buf_vmap(dmabuf, &map); + notif = ret ? NULL : map.vaddr; +#else notif = dma_buf_vmap(dmabuf); +#endif if (!notif) { nvgpu_err(g, "failed to map notifier memory"); return -ENOMEM; } - notif = (struct notification *)((uintptr_t)notif + offset); /* user should set status pending before @@ -816,7 +885,11 @@ static int gk20a_channel_wait(struct nvgpu_channel *ch, notif->info16 = ch->chid; /* should be method offset */ notif_clean_up: +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_vunmap(dmabuf, &map); +#else dma_buf_vunmap(dmabuf, notif); +#endif return ret; case NVGPU_WAIT_TYPE_SEMAPHORE: diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_prof.c b/drivers/gpu/nvgpu/os/linux/ioctl_prof.c index d38cb49e8..ce060dbc0 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_prof.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_prof.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -351,6 +351,9 @@ static int nvgpu_prof_ioctl_alloc_pma_stream(struct nvgpu_profiler_object_priv * struct mm_gk20a *mm = &g->mm; u64 pma_bytes_available_buffer_offset; struct dma_buf *dmabuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif void *cpuva; u32 pma_buffer_size; int err; @@ -405,7 +408,12 @@ static int nvgpu_prof_ioctl_alloc_pma_stream(struct nvgpu_profiler_object_priv * goto err_unmap_pma; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + err = dma_buf_vmap(dmabuf, &map); + cpuva = err ? NULL : map.vaddr; +#else cpuva = dma_buf_vmap(dmabuf); +#endif if (cpuva == NULL) { err = -ENOMEM; nvgpu_err(g, "failed to vmap available bytes buffer FD"); @@ -444,6 +452,9 @@ static void nvgpu_prof_free_pma_stream_priv_data(struct nvgpu_profiler_object_pr struct nvgpu_profiler_object *prof = priv->prof; struct gk20a *g = prof->g; struct mm_gk20a *mm = &g->mm; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif if (priv->pma_bytes_available_buffer_dmabuf == NULL) { return; @@ -456,8 +467,13 @@ static void nvgpu_prof_free_pma_stream_priv_data(struct nvgpu_profiler_object_pr prof->pma_buffer_va = 0U; prof->pma_buffer_size = 0U; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_map_set_vaddr(&map, prof->pma_bytes_available_buffer_cpuva); + dma_buf_vunmap(priv->pma_bytes_available_buffer_dmabuf, &map); +#else dma_buf_vunmap(priv->pma_bytes_available_buffer_dmabuf, prof->pma_bytes_available_buffer_cpuva); +#endif dma_buf_put(priv->pma_bytes_available_buffer_dmabuf); priv->pma_bytes_available_buffer_dmabuf = NULL; prof->pma_bytes_available_buffer_cpuva = NULL; diff --git a/drivers/gpu/nvgpu/os/linux/linux-channel.c b/drivers/gpu/nvgpu/os/linux/linux-channel.c index 774ea5786..69aa859c0 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-channel.c +++ b/drivers/gpu/nvgpu/os/linux/linux-channel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2017-2021, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -655,6 +655,9 @@ static void trace_write_pushbuffer(struct nvgpu_channel *c, unsigned int words; u64 offset; struct dma_buf *dmabuf = NULL; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + struct dma_buf_map map; +#endif if (gk20a_debug_trace_cmdbuf) { u64 gpu_va = (u64)g->entry0 | @@ -663,8 +666,14 @@ static void trace_write_pushbuffer(struct nvgpu_channel *c, words = pbdma_gp_entry1_length_v(g->entry1); err = nvgpu_vm_find_buf(c->vm, gpu_va, &dmabuf, &offset); - if (!err) + if (!err) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + err = dma_buf_vmap(dmabuf, &map); + mem = err ? NULL : map.vaddr; +#else mem = dma_buf_vmap(dmabuf); +#endif + } } if (mem) { @@ -683,7 +692,11 @@ static void trace_write_pushbuffer(struct nvgpu_channel *c, mem); } #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + dma_buf_vunmap(dmabuf, &map); +#else dma_buf_vunmap(dmabuf, mem); +#endif } }