mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: pass alloc_gpfifo args to gk20a_channel_alloc_gpfifo
The patch defines 'struct nvgpu_gpfifo_args' to be filled by alloc_gpfifo(_ex) ioctls and passed to the gk20a_channel_alloc_gpfifo function. This is required as a prep towards having the usermode submission support in the core channel core. Change-Id: I72acc00cc5558dd3623604da7d716bf849f0152c Signed-off-by: Sourab Gupta <sourabg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1683391 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@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
077de38dfb
commit
03b8768902
@@ -1277,6 +1277,7 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx)
|
||||
struct channel_gk20a *ch;
|
||||
struct tsg_gk20a *tsg;
|
||||
struct gr_gk20a *gr = &g->gr;
|
||||
struct nvgpu_gpfifo_args gpfifo_args;
|
||||
int err = 0;
|
||||
u64 vaddr;
|
||||
|
||||
@@ -1316,8 +1317,11 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx)
|
||||
goto err_alloc_gpfifo;
|
||||
}
|
||||
|
||||
gpfifo_args.num_entries = 1024;
|
||||
gpfifo_args.num_inflight_jobs = 0;
|
||||
gpfifo_args.flags = 0;
|
||||
/* allocate gpfifo (1024 should be more than enough) */
|
||||
err = gk20a_channel_alloc_gpfifo(ch, 1024, 0, 0);
|
||||
err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args);
|
||||
if (err) {
|
||||
nvgpu_warn(g, "cde: unable to allocate gpfifo");
|
||||
goto err_alloc_gpfifo;
|
||||
|
||||
@@ -589,16 +589,30 @@ static u32 nvgpu_gpfifo_user_flags_to_common_flags(u32 user_flags)
|
||||
return flags;
|
||||
}
|
||||
|
||||
static int nvgpu_channel_ioctl_alloc_gpfifo(struct channel_gk20a *c,
|
||||
unsigned int num_entries,
|
||||
unsigned int num_inflight_jobs,
|
||||
u32 user_flags)
|
||||
static void nvgpu_get_gpfifo_ex_args(
|
||||
struct nvgpu_alloc_gpfifo_ex_args *alloc_gpfifo_ex_args,
|
||||
struct nvgpu_gpfifo_args *gpfifo_args)
|
||||
{
|
||||
return gk20a_channel_alloc_gpfifo(c, num_entries,
|
||||
num_inflight_jobs,
|
||||
nvgpu_gpfifo_user_flags_to_common_flags(user_flags));
|
||||
gpfifo_args->num_entries = alloc_gpfifo_ex_args->num_entries;
|
||||
gpfifo_args->num_inflight_jobs = alloc_gpfifo_ex_args->num_inflight_jobs;
|
||||
gpfifo_args->flags = nvgpu_gpfifo_user_flags_to_common_flags(
|
||||
alloc_gpfifo_ex_args->flags);
|
||||
}
|
||||
|
||||
static void nvgpu_get_gpfifo_args(
|
||||
struct nvgpu_alloc_gpfifo_args *alloc_gpfifo_args,
|
||||
struct nvgpu_gpfifo_args *gpfifo_args)
|
||||
{
|
||||
/*
|
||||
* Kernel can insert one extra gpfifo entry before user
|
||||
* submitted gpfifos and another one after, for internal usage.
|
||||
* Triple the requested size.
|
||||
*/
|
||||
gpfifo_args->num_entries = alloc_gpfifo_args->num_entries * 3;
|
||||
gpfifo_args->num_inflight_jobs = 0;
|
||||
gpfifo_args->flags = nvgpu_gpfifo_user_flags_to_common_flags(
|
||||
alloc_gpfifo_args->flags);
|
||||
}
|
||||
|
||||
static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch,
|
||||
ulong id, u32 offset,
|
||||
@@ -1075,6 +1089,9 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
{
|
||||
struct nvgpu_alloc_gpfifo_ex_args *alloc_gpfifo_ex_args =
|
||||
(struct nvgpu_alloc_gpfifo_ex_args *)buf;
|
||||
struct nvgpu_gpfifo_args gpfifo_args;
|
||||
|
||||
nvgpu_get_gpfifo_ex_args(alloc_gpfifo_ex_args, &gpfifo_args);
|
||||
|
||||
err = gk20a_busy(ch->g);
|
||||
if (err) {
|
||||
@@ -1089,10 +1106,7 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
gk20a_idle(ch->g);
|
||||
break;
|
||||
}
|
||||
err = nvgpu_channel_ioctl_alloc_gpfifo(ch,
|
||||
alloc_gpfifo_ex_args->num_entries,
|
||||
alloc_gpfifo_ex_args->num_inflight_jobs,
|
||||
alloc_gpfifo_ex_args->flags);
|
||||
err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args);
|
||||
gk20a_idle(ch->g);
|
||||
break;
|
||||
}
|
||||
@@ -1100,6 +1114,9 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
{
|
||||
struct nvgpu_alloc_gpfifo_args *alloc_gpfifo_args =
|
||||
(struct nvgpu_alloc_gpfifo_args *)buf;
|
||||
struct nvgpu_gpfifo_args gpfifo_args;
|
||||
|
||||
nvgpu_get_gpfifo_args(alloc_gpfifo_args, &gpfifo_args);
|
||||
|
||||
err = gk20a_busy(ch->g);
|
||||
if (err) {
|
||||
@@ -1109,15 +1126,7 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel can insert one extra gpfifo entry before user
|
||||
* submitted gpfifos and another one after, for internal usage.
|
||||
* Triple the requested size.
|
||||
*/
|
||||
err = nvgpu_channel_ioctl_alloc_gpfifo(ch,
|
||||
alloc_gpfifo_args->num_entries * 3,
|
||||
0,
|
||||
alloc_gpfifo_args->flags);
|
||||
err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args);
|
||||
gk20a_idle(ch->g);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -406,6 +406,7 @@ u32 gk20a_ce_create_context(struct gk20a *g,
|
||||
{
|
||||
struct gk20a_gpu_ctx *ce_ctx;
|
||||
struct gk20a_ce_app *ce_app = &g->ce_app;
|
||||
struct nvgpu_gpfifo_args gpfifo_args;
|
||||
u32 ctx_id = ~0;
|
||||
int err = 0;
|
||||
|
||||
@@ -458,8 +459,11 @@ u32 gk20a_ce_create_context(struct gk20a *g,
|
||||
goto end;
|
||||
}
|
||||
|
||||
gpfifo_args.num_entries = 1024;
|
||||
gpfifo_args.num_inflight_jobs = 0;
|
||||
gpfifo_args.flags = 0;
|
||||
/* allocate gpfifo (1024 should be more than enough) */
|
||||
err = gk20a_channel_alloc_gpfifo(ce_ctx->ch, 1024, 0, 0);
|
||||
err = gk20a_channel_alloc_gpfifo(ce_ctx->ch, &gpfifo_args);
|
||||
if (err) {
|
||||
nvgpu_err(g, "ce: unable to allocate gpfifo");
|
||||
goto end;
|
||||
|
||||
@@ -1034,9 +1034,7 @@ static void channel_gk20a_free_prealloc_resources(struct channel_gk20a *c)
|
||||
}
|
||||
|
||||
int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
||||
unsigned int num_entries,
|
||||
unsigned int num_inflight_jobs,
|
||||
u32 flags)
|
||||
struct nvgpu_gpfifo_args *gpfifo_args)
|
||||
{
|
||||
struct gk20a *g = c->g;
|
||||
struct vm_gk20a *ch_vm;
|
||||
@@ -1044,13 +1042,13 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
||||
int err = 0;
|
||||
unsigned long acquire_timeout;
|
||||
|
||||
gpfifo_size = num_entries;
|
||||
gpfifo_size = gpfifo_args->num_entries;
|
||||
gpfifo_entry_size = nvgpu_get_gpfifo_entry_size();
|
||||
|
||||
if (flags & NVGPU_GPFIFO_FLAGS_SUPPORT_VPR)
|
||||
if (gpfifo_args->flags & NVGPU_GPFIFO_FLAGS_SUPPORT_VPR)
|
||||
c->vpr = true;
|
||||
|
||||
if (flags & NVGPU_GPFIFO_FLAGS_SUPPORT_DETERMINISTIC) {
|
||||
if (gpfifo_args->flags & NVGPU_GPFIFO_FLAGS_SUPPORT_DETERMINISTIC) {
|
||||
nvgpu_rwsem_down_read(&g->deterministic_busy);
|
||||
/*
|
||||
* Railgating isn't deterministic; instead of disallowing
|
||||
@@ -1137,15 +1135,15 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
||||
|
||||
err = g->ops.fifo.setup_ramfc(c, c->gpfifo.mem.gpu_va,
|
||||
c->gpfifo.entry_num,
|
||||
acquire_timeout, flags);
|
||||
acquire_timeout, gpfifo_args->flags);
|
||||
if (err)
|
||||
goto clean_up_sync;
|
||||
|
||||
/* TBD: setup engine contexts */
|
||||
|
||||
if (num_inflight_jobs) {
|
||||
if (gpfifo_args->num_inflight_jobs) {
|
||||
err = channel_gk20a_prealloc_resources(c,
|
||||
num_inflight_jobs);
|
||||
gpfifo_args->num_inflight_jobs);
|
||||
if (err)
|
||||
goto clean_up_sync;
|
||||
}
|
||||
@@ -1166,7 +1164,7 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
||||
clean_up_priv_cmd:
|
||||
channel_gk20a_free_priv_cmdbuf(c);
|
||||
clean_up_prealloc:
|
||||
if (num_inflight_jobs)
|
||||
if (gpfifo_args->num_inflight_jobs)
|
||||
channel_gk20a_free_prealloc_resources(c);
|
||||
clean_up_sync:
|
||||
if (c->sync) {
|
||||
|
||||
@@ -46,6 +46,12 @@ struct fifo_profile_gk20a;
|
||||
#define NVGPU_GPFIFO_FLAGS_SUPPORT_DETERMINISTIC (1 << 1)
|
||||
#define NVGPU_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE (1 << 2)
|
||||
|
||||
struct nvgpu_gpfifo_args {
|
||||
u32 num_entries;
|
||||
u32 num_inflight_jobs;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
struct notification {
|
||||
struct {
|
||||
u32 nanoseconds[2];
|
||||
@@ -324,9 +330,7 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g,
|
||||
bool is_privileged_channel);
|
||||
|
||||
int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
|
||||
unsigned int num_entries,
|
||||
unsigned int num_inflight_jobs,
|
||||
u32 flags);
|
||||
struct nvgpu_gpfifo_args *gpfifo_args);
|
||||
|
||||
void gk20a_channel_timeout_restart_all_channels(struct gk20a *g);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user