gpu: nvgpu: update device management framework to remove unusable engines

On certain platforms, not all copy engine instances are usable. The user
shouldn't submit any work to these engines. To enforce this, remove
these engines from active/host_engine list, this should ensure that these
engines do not get advertised to userspace. In order to accomplish this
introduce the following functions:
- nvgpu_engine_remove_one_dev: This function removes the specified device
  entry from following device lists: fifo->host_engines, fifo->active_engines,
  runlist->rl_dev_list, runlist->eng_bitmask.

Replace iteration over LCE device type entries using
nvgpu_device_for_each(g, dev, NVGPU_DEVTYPE_LCE), along with this introduce
macro nvgpu_device_for_each_safe.

Introduce gpu_dbg_ce flag for CE debugging.

Bug 3370462

Change-Id: I2e21f18363c6e53630d129da241c8fece106cd33
Signed-off-by: Antony Clince Alex <aalex@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2616711
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Antony Clince Alex
2021-10-26 10:09:20 +00:00
committed by mobile promotions
parent 79ee724b04
commit cce1d7ad84
7 changed files with 82 additions and 32 deletions

View File

@@ -170,10 +170,7 @@ u32 nvgpu_ce_engine_interrupt_mask(struct gk20a *g)
/*
* Now take care of LCEs.
*/
for (i = 0U; i < nvgpu_device_count(g, NVGPU_DEVTYPE_LCE); i++) {
dev = nvgpu_device_get(g, NVGPU_DEVTYPE_LCE, i);
nvgpu_assert(dev != NULL);
nvgpu_device_for_each(g, dev, NVGPU_DEVTYPE_LCE) {
mask |= BIT32(dev->intr_id);
}
@@ -803,6 +800,55 @@ static int nvgpu_engine_init_one_dev(struct nvgpu_fifo *f,
return 0;
}
void nvgpu_engine_remove_one_dev(struct nvgpu_fifo *f,
const struct nvgpu_device *dev)
{
u32 i, j;
struct gk20a *g = f->g;
/*
* First remove the engine from fifo->host_engines list, for this, it
* suffices to set the entry corresponding to the dev->engine_id to
* NULL, this should prevent the entry from being used.
*/
f->host_engines[dev->engine_id] = NULL;
#if defined(CONFIG_NVGPU_NON_FUSA)
/*
* Remove the device from the runlist device list.
*/
f->runlists[dev->runlist_id]->rl_dev_list[dev->rleng_id] = NULL;
/*
* Remove the engine id from runlist->eng_bitmask
*/
f->runlists[dev->runlist_id]->eng_bitmask &= (~BIT32(dev->engine_id));
#endif
/*
* For fifo->active_engines, we have to figure out the index of the
* device to be removed and shift the remaining elements up to that
* index.
*/
for (i = 0U; i < f->num_engines; i++) {
if (f->active_engines[i] == dev) {
nvgpu_log(g, gpu_dbg_device, "deleting device with"
" engine_id(%d) from active_engines list",
dev->engine_id);
for (j = i; j < nvgpu_safe_sub_u32(f->num_engines, 1U);
j++) {
f->active_engines[j] = f->active_engines[
nvgpu_safe_add_u32(j, 1U)];
}
break;
}
}
/*
* Update f->num_engines if a device was removed from f->active_engines
* list.
*/
f->num_engines = (i < f->num_engines) ?
nvgpu_safe_sub_u32(f->num_engines, 1U) : f->num_engines;
}
int nvgpu_engine_init_info(struct nvgpu_fifo *f)
{
int err;