gpu: nvgpu: add bvec check for common.fifo input

This patch adds boundary value check for common.fifo parameters as
listed below.
1. nvgpu_channel_setup_bind() includes a condition to check that value
of num_gpfifo_entries does not exceed 2^31. Otherwise prints message and
returns error.
2. nvgpu_tsg_bind_channel() includes a condition to check if channel
subctx had ASYNC id. If true, runqueue selector is set to 1 and 0
otherwise. This check is to be moved from devctl to common.fifo.

Jira NVGPU-4817

Change-Id: Id1c9253945859c245e584b5c42b3285a6b620055
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2278613
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2020-01-10 13:24:14 -08:00
committed by Alex Waterman
parent df7631efc8
commit 2fb56f2cea
6 changed files with 31 additions and 3 deletions

View File

@@ -2205,6 +2205,13 @@ static int channel_setup_bind_prechecks(struct nvgpu_channel *c,
struct nvgpu_tsg *tsg;
int err = 0;
if (args->num_gpfifo_entries > 0x80000000U) {
nvgpu_err(g,
"num_gpfifo_entries exceeds max limit of 2^31");
err = -EINVAL;
goto fail;
}
/* an address space needs to have been bound at this point. */
if (!nvgpu_channel_as_bound(c)) {
nvgpu_err(g,

View File

@@ -104,6 +104,11 @@ int nvgpu_tsg_bind_channel(struct nvgpu_tsg *tsg, struct nvgpu_channel *ch)
return -EINVAL;
}
/* Use runqueue selector 1 for all ASYNC ids */
if (ch->subctx_id > CHANNEL_INFO_VEID0) {
ch->runqueue_sel = 1;
}
/* all the channel part of TSG should need to be same runlist_id */
if (tsg->runlist_id == NVGPU_INVALID_TSG_ID) {
tsg->runlist_id = ch->runlist_id;

View File

@@ -1025,6 +1025,7 @@ struct nvgpu_channel *nvgpu_channel_open_new(struct gk20a *g,
* @return 0 in case of success, < 0 in case of failure.
* @retval -EINVAL if channel is not bound to an address space.
* @retval -EINVAL if attempting to use kernel mode submit in a safety build.
* @retval -EINVAL if num_gpfifo_entries in #args is greater than 2^31.
* @retval -EEXIST if gpfifo has already been allocated for this channel.
* @retval -E2BIG if there is no space available to append channel to runlist.
* @retval -ETIMEDOUT if runlist update timed out.

View File

@@ -312,6 +312,7 @@ void nvgpu_tsg_disable(struct nvgpu_tsg *tsg);
*
* - Make sure channel is not already bound to a TSG.
* - Make sure channel is not part of any runlists.
* - If channel had ASYNC subctx id, then set runqueue selector to 1.
* - Set runlist id of TSG to channel's runlist_id if runlist_id of TSG
* is set to #NVGPU_INVALID_TSG_ID.
* - Call HAL to bind channel to TSG.