Files
linux-nvgpu/drivers/gpu/nvgpu/hal/fifo/tsg_gv11b.c
Thomas Fleury 1160f083d4 gpu: nvgpu: move ce code to common/ce and hal/ce
Merged gk20a_ce_delete_context and gk20a_ce_delete_context_priv.

Renamed
- gk20a_init_ce_support -> nvgpu_ce_init_support
- gk20a_ce_destroy -> nvgpu_ce_destroy
- gk20a_ce_suspend -> nvgpu_ce_suspend
- gk20a_ce_create_context -> nvgpu_ce_create_context
- gk20a_ce_delete_context -> nvgpu_ce_delete_context
- gk20a_ce_execute_ops -> nvgpu_ce_execute_ops
- gk20a_ce_prepare_submit -> nvgpu_ce_prepare_submit
- gk20a_ce_put_fences -> nvgpu_ce_put_fences
- gk20a_ce_delete_gpu_context -> nvgpu_ce_delete_gpu_context
- gk20a_ce_get_method_size -> nvgpu_ce_get_method_size
- gk20a_gpu_ctx -> nvgpu_ce_gpu_ctx
- gk20a_gpu_ctx_from_list -> nvgpu_ce_gpu_ctx_from_list
- gk20a_ce_app -> nvgpu_ce_app
- gk20a_ce_debugfs_init -> nvgpu_ce_debugfs_init
- gk20a_get_valid_launch_flags -> nvgpu_ce_get_valid_launch_flags
- gk20a_ce2_isr -> gk20a_ce2_stall_isr
- gp10b_ce_isr -> gp10b_ce_stall_isr
- gv11b_ce_isr -> gv11b_ce_stall_isr

Inlined
- ce*_nonblockpipe_isr
- ce*_blockpipe_isr
- ce*_launcherr_isr

Added ce_priv.h for ce private definitions.

Moved files to common/ce and hal/fifo/ce
- ce2.c -> common/ce2/ce.c
- ce2_gk20a.c -> hal/ce/ce2_gk20a.c
- ce2_gk20a.h -> hal/ce/ce2_gk20a.h
- ce_gp10b.c -> hal/ce/ce_gp10b.c
- ce_gp10b.h -> hal/ce/ce_gp10b.h
- ce_gv11b.c -> hal/ce/ce_gv11b.c
- ce_gv11b.h -> hal/ce/ce_gv11b.h

Updated makefiles and #include directives

Jira NVGPU-1992

Change-Id: Ia6064bf51b7a254085be43a112d056cb6fb6c3b2
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2093503
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-04-19 13:55:11 -07:00

178 lines
4.9 KiB
C

/*
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <nvgpu/channel.h>
#include <nvgpu/engines.h>
#include <nvgpu/nvgpu_mem.h>
#include <nvgpu/tsg.h>
#include <nvgpu/dma.h>
#include <nvgpu/gk20a.h>
#include "hal/fifo/tsg_gv11b.h"
/* can be removed after runque support is added */
#define GR_RUNQUE 0U /* pbdma 0 */
#define ASYNC_CE_RUNQUE 2U /* pbdma 2 */
/* TSG enable sequence applicable for Volta and onwards */
void gv11b_tsg_enable(struct tsg_gk20a *tsg)
{
struct gk20a *g = tsg->g;
struct channel_gk20a *ch;
struct channel_gk20a *last_ch = NULL;
nvgpu_rwsem_down_read(&tsg->ch_list_lock);
nvgpu_list_for_each_entry(ch, &tsg->ch_list, channel_gk20a, ch_entry) {
g->ops.channel.enable(ch);
last_ch = ch;
}
nvgpu_rwsem_up_read(&tsg->ch_list_lock);
if (last_ch != NULL) {
g->ops.usermode.ring_doorbell(last_ch);
}
}
void gv11b_tsg_unbind_channel_check_eng_faulted(struct tsg_gk20a *tsg,
struct channel_gk20a *ch,
struct nvgpu_channel_hw_state *hw_state)
{
struct gk20a *g = tsg->g;
struct nvgpu_mem *mem;
/*
* If channel has FAULTED set, clear the CE method buffer
* if saved out channel is same as faulted channel
*/
if (!hw_state->eng_faulted || (tsg->eng_method_buffers == NULL)) {
return;
}
/*
* CE method buffer format :
* DWord0 = method count
* DWord1 = channel id
*
* It is sufficient to write 0 to method count to invalidate
*/
mem = &tsg->eng_method_buffers[ASYNC_CE_RUNQUE];
if (ch->chid == nvgpu_mem_rd32(g, mem, 1)) {
nvgpu_mem_wr32(g, mem, 0, 0);
}
}
void gv11b_tsg_bind_channel_eng_method_buffers(struct tsg_gk20a *tsg,
struct channel_gk20a *ch)
{
struct gk20a *g = tsg->g;
u64 gpu_va;
if (tsg->eng_method_buffers == NULL) {
nvgpu_log_info(g, "eng method buffer NULL");
return;
}
if (tsg->runlist_id == nvgpu_engine_get_fast_ce_runlist_id(g)) {
gpu_va = tsg->eng_method_buffers[ASYNC_CE_RUNQUE].gpu_va;
} else {
gpu_va = tsg->eng_method_buffers[GR_RUNQUE].gpu_va;
}
g->ops.ramin.set_eng_method_buffer(g, &ch->inst_block, gpu_va);
}
static unsigned int gv11b_tsg_get_eng_method_buffer_size(struct gk20a *g)
{
unsigned int buffer_size;
buffer_size = ((9U + 1U + 3U) * g->ops.ce.get_num_pce(g)) + 2U;
buffer_size = (27U * 5U * buffer_size);
buffer_size = roundup(buffer_size, PAGE_SIZE);
nvgpu_log_info(g, "method buffer size in bytes %d", buffer_size);
return buffer_size;
}
void gv11b_tsg_init_eng_method_buffers(struct gk20a *g, struct tsg_gk20a *tsg)
{
struct vm_gk20a *vm = g->mm.bar2.vm;
int err = 0;
int i;
unsigned int runque, method_buffer_size;
unsigned int num_pbdma = g->fifo.num_pbdma;
if (tsg->eng_method_buffers != NULL) {
return;
}
method_buffer_size = gv11b_tsg_get_eng_method_buffer_size(g);
if (method_buffer_size == 0U) {
nvgpu_info(g, "ce will hit MTHD_BUFFER_FAULT");
return;
}
tsg->eng_method_buffers = nvgpu_kzalloc(g,
num_pbdma * sizeof(struct nvgpu_mem));
for (runque = 0; runque < num_pbdma; runque++) {
err = nvgpu_dma_alloc_map_sys(vm, method_buffer_size,
&tsg->eng_method_buffers[runque]);
if (err != 0) {
break;
}
}
if (err != 0) {
for (i = ((int)runque - 1); i >= 0; i--) {
nvgpu_dma_unmap_free(vm,
&tsg->eng_method_buffers[i]);
}
nvgpu_kfree(g, tsg->eng_method_buffers);
tsg->eng_method_buffers = NULL;
nvgpu_err(g, "could not alloc eng method buffers");
return;
}
nvgpu_log_info(g, "eng method buffers allocated");
}
void gv11b_tsg_deinit_eng_method_buffers(struct gk20a *g,
struct tsg_gk20a *tsg)
{
struct vm_gk20a *vm = g->mm.bar2.vm;
unsigned int runque;
if (tsg->eng_method_buffers == NULL) {
return;
}
for (runque = 0; runque < g->fifo.num_pbdma; runque++) {
nvgpu_dma_unmap_free(vm, &tsg->eng_method_buffers[runque]);
}
nvgpu_kfree(g, tsg->eng_method_buffers);
tsg->eng_method_buffers = NULL;
nvgpu_log_info(g, "eng method buffers de-allocated");
}