mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: use own usermode gpfifo object
Add usermode_gpfifo member to channel to store the usermode-owned buffer data. This makes it more explicit about which (user or kernel) memory is accessed. Jira NVGPU-967 Change-Id: I98e4f4568f04aa31e00e497794fadd4997ba8aab Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1807503 Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Sourab Gupta <sourabg@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
bc6625b9b2
commit
268c298f45
@@ -1057,6 +1057,7 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
|||||||
struct gk20a *g = c->g;
|
struct gk20a *g = c->g;
|
||||||
struct vm_gk20a *ch_vm;
|
struct vm_gk20a *ch_vm;
|
||||||
u32 gpfifo_size, gpfifo_entry_size;
|
u32 gpfifo_size, gpfifo_entry_size;
|
||||||
|
u64 gpfifo_gpu_va;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned long acquire_timeout;
|
unsigned long acquire_timeout;
|
||||||
|
|
||||||
@@ -1097,7 +1098,8 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
|||||||
}
|
}
|
||||||
ch_vm = c->vm;
|
ch_vm = c->vm;
|
||||||
|
|
||||||
if (c->gpfifo.mem.size) {
|
if (nvgpu_mem_is_valid(&c->gpfifo.mem) ||
|
||||||
|
c->usermode_submit_enabled) {
|
||||||
nvgpu_err(g, "channel %d :"
|
nvgpu_err(g, "channel %d :"
|
||||||
"gpfifo already allocated", c->chid);
|
"gpfifo already allocated", c->chid);
|
||||||
err = -EEXIST;
|
err = -EEXIST;
|
||||||
@@ -1120,30 +1122,32 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
|||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
}
|
}
|
||||||
}
|
gpfifo_gpu_va = c->usermode_gpfifo.gpu_va;
|
||||||
|
} else {
|
||||||
err = nvgpu_dma_alloc_map_sys(ch_vm,
|
err = nvgpu_dma_alloc_map_sys(ch_vm,
|
||||||
gpfifo_size * gpfifo_entry_size,
|
gpfifo_size * gpfifo_entry_size,
|
||||||
&c->gpfifo.mem);
|
&c->gpfifo.mem);
|
||||||
if (err) {
|
if (err) {
|
||||||
nvgpu_err(g, "%s: memory allocation failed", __func__);
|
nvgpu_err(g, "memory allocation failed");
|
||||||
goto clean_up_usermode;
|
goto clean_up;
|
||||||
}
|
|
||||||
|
|
||||||
if (c->gpfifo.mem.aperture == APERTURE_VIDMEM) {
|
|
||||||
c->gpfifo.pipe = nvgpu_big_malloc(g,
|
|
||||||
gpfifo_size * gpfifo_entry_size);
|
|
||||||
if (!c->gpfifo.pipe) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto clean_up_unmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->gpfifo.mem.aperture == APERTURE_VIDMEM) {
|
||||||
|
c->gpfifo.pipe = nvgpu_big_malloc(g,
|
||||||
|
gpfifo_size * gpfifo_entry_size);
|
||||||
|
if (!c->gpfifo.pipe) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto clean_up_unmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gpfifo_gpu_va = c->gpfifo.mem.gpu_va;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->gpfifo.entry_num = gpfifo_size;
|
c->gpfifo.entry_num = gpfifo_size;
|
||||||
c->gpfifo.get = c->gpfifo.put = 0;
|
c->gpfifo.get = c->gpfifo.put = 0;
|
||||||
|
|
||||||
nvgpu_log_info(g, "channel %d : gpfifo_base 0x%016llx, size %d",
|
nvgpu_log_info(g, "channel %d : gpfifo_base 0x%016llx, size %d",
|
||||||
c->chid, c->gpfifo.mem.gpu_va, c->gpfifo.entry_num);
|
c->chid, gpfifo_gpu_va, c->gpfifo.entry_num);
|
||||||
|
|
||||||
g->ops.fifo.setup_userd(c);
|
g->ops.fifo.setup_userd(c);
|
||||||
|
|
||||||
@@ -1169,7 +1173,7 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
|||||||
else
|
else
|
||||||
acquire_timeout = c->timeout.limit_ms;
|
acquire_timeout = c->timeout.limit_ms;
|
||||||
|
|
||||||
err = g->ops.fifo.setup_ramfc(c, c->gpfifo.mem.gpu_va,
|
err = g->ops.fifo.setup_ramfc(c, gpfifo_gpu_va,
|
||||||
c->gpfifo.entry_num,
|
c->gpfifo.entry_num,
|
||||||
acquire_timeout, gpfifo_args->flags);
|
acquire_timeout, gpfifo_args->flags);
|
||||||
if (err)
|
if (err)
|
||||||
@@ -1210,7 +1214,6 @@ clean_up_sync:
|
|||||||
clean_up_unmap:
|
clean_up_unmap:
|
||||||
nvgpu_big_free(g, c->gpfifo.pipe);
|
nvgpu_big_free(g, c->gpfifo.pipe);
|
||||||
nvgpu_dma_unmap_free(ch_vm, &c->gpfifo.mem);
|
nvgpu_dma_unmap_free(ch_vm, &c->gpfifo.mem);
|
||||||
clean_up_usermode:
|
|
||||||
if (c->usermode_submit_enabled) {
|
if (c->usermode_submit_enabled) {
|
||||||
gk20a_channel_free_usermode_buffers(c);
|
gk20a_channel_free_usermode_buffers(c);
|
||||||
c->userd_iova = nvgpu_mem_get_addr(g, &g->fifo.userd) +
|
c->userd_iova = nvgpu_mem_get_addr(g, &g->fifo.userd) +
|
||||||
@@ -1234,6 +1237,8 @@ void gk20a_channel_free_usermode_buffers(struct channel_gk20a *c)
|
|||||||
{
|
{
|
||||||
if (nvgpu_mem_is_valid(&c->usermode_userd))
|
if (nvgpu_mem_is_valid(&c->usermode_userd))
|
||||||
nvgpu_dma_free(c->g, &c->usermode_userd);
|
nvgpu_dma_free(c->g, &c->usermode_userd);
|
||||||
|
if (nvgpu_mem_is_valid(&c->usermode_gpfifo))
|
||||||
|
nvgpu_dma_free(c->g, &c->usermode_gpfifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update with this periodically to determine how the gpfifo is draining. */
|
/* Update with this periodically to determine how the gpfifo is draining. */
|
||||||
|
|||||||
@@ -341,14 +341,14 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c,
|
|||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nvgpu_mem_is_valid(&c->gpfifo.mem)) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c->usermode_submit_enabled) {
|
if (c->usermode_submit_enabled) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nvgpu_mem_is_valid(&c->gpfifo.mem)) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* fifo not large enough for request. Return error immediately.
|
/* fifo not large enough for request. Return error immediately.
|
||||||
* Kernel can insert gpfifo entries before and after user gpfifos.
|
* Kernel can insert gpfifo entries before and after user gpfifos.
|
||||||
* So, add extra_entries in user request. Also, HW with fifo size N
|
* So, add extra_entries in user request. Also, HW with fifo size N
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ struct channel_gk20a {
|
|||||||
struct gpfifo_desc gpfifo;
|
struct gpfifo_desc gpfifo;
|
||||||
|
|
||||||
struct nvgpu_mem usermode_userd; /* Used for Usermode Submission */
|
struct nvgpu_mem usermode_userd; /* Used for Usermode Submission */
|
||||||
|
struct nvgpu_mem usermode_gpfifo;
|
||||||
struct nvgpu_mem inst_block;
|
struct nvgpu_mem inst_block;
|
||||||
|
|
||||||
u64 userd_iova;
|
u64 userd_iova;
|
||||||
|
|||||||
Reference in New Issue
Block a user