mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
Currently the vGPU engine management rewrites a lot of the common device agnostic engine management code. With the new top HAL parsing one device at a time, it is now more easily possible to tie the vGPU into the new common device framework by implementing the top HAL but with the vGPU engine list backend. This lets the vGPU inherit all the common engine and device management code. By doing so the vGPU HAL need only implement a trivial and simple HAL. This also gets us a step closer to merging all of the CE init code: logically it just iterates through all CE engines whatever they may be. The only reason this differs between chips is because of the swap from CE0-2 to LCEs in the Pascal generation. This could be abstracted by the unit code easily enough. Also, the pbdma_id for each engine has to be added to the device struct. Eventually this was going to happen anyway, since the device struct will soon replace the nvgpu_engine_info struct. It's a little bit of an abuse but might be worth it long term. If not, it should not be difficult to replace uses of dev->pbdma_id with a proper lookup of PBDMA ID based on the device info. JIRA NVGPU-5421 Change-Id: Ie8dcd3b0150184d58ca0f78940c2e7ca72994e64 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2351877 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
111 lines
3.5 KiB
C
111 lines
3.5 KiB
C
/*
|
|
* Copyright (c) 2015-2020, 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/device.h>
|
|
#include <nvgpu/engines.h>
|
|
#include <nvgpu/log.h>
|
|
#include <nvgpu/errno.h>
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/static_analysis.h>
|
|
|
|
#include <nvgpu/hw/gp10b/hw_fifo_gp10b.h>
|
|
|
|
#include "engines_gp10b.h"
|
|
|
|
int gp10b_engine_init_ce_info(struct nvgpu_fifo *f)
|
|
{
|
|
struct gk20a *g = f->g;
|
|
enum nvgpu_fifo_engine engine_enum;
|
|
u32 i;
|
|
u32 gr_runlist_id;
|
|
u32 lce_num_entries = 0;
|
|
bool found;
|
|
|
|
gr_runlist_id = nvgpu_engine_get_gr_runlist_id(g);
|
|
nvgpu_log_info(g, "gr_runlist_id: %d", gr_runlist_id);
|
|
|
|
lce_num_entries = nvgpu_device_count(g, NVGPU_DEVTYPE_LCE);
|
|
nvgpu_log_info(g, "lce_num_entries: %d", lce_num_entries);
|
|
|
|
for (i = 0; i < lce_num_entries; i++) {
|
|
const struct nvgpu_device *dev;
|
|
struct nvgpu_device *dev_rw;
|
|
struct nvgpu_engine_info *info;
|
|
|
|
dev = nvgpu_device_get(g, NVGPU_DEVTYPE_LCE, i);
|
|
if (dev == NULL) {
|
|
nvgpu_err(g, "Failed to get LCE device %u", i);
|
|
return -EINVAL;
|
|
}
|
|
dev_rw = (struct nvgpu_device *)dev;
|
|
|
|
info = &g->fifo.engine_info[dev->engine_id];
|
|
|
|
/*
|
|
* vGPU consideration. Not present in older chips. See
|
|
* nvgpu_engine_init_from_device_info() for more details in the
|
|
* comments.
|
|
*/
|
|
if (g->ops.fifo.find_pbdma_for_runlist != NULL) {
|
|
found = g->ops.fifo.find_pbdma_for_runlist(g,
|
|
dev->runlist_id,
|
|
&dev_rw->pbdma_id);
|
|
if (!found) {
|
|
nvgpu_err(g, "busted pbdma map");
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
info->pbdma_id = dev->pbdma_id;
|
|
|
|
engine_enum = nvgpu_engine_enum_from_dev(g, dev);
|
|
/* GR and GR_COPY shares same runlist_id */
|
|
if ((engine_enum == NVGPU_ENGINE_ASYNC_CE) &&
|
|
(gr_runlist_id == dev->runlist_id)) {
|
|
engine_enum = NVGPU_ENGINE_GRCE;
|
|
}
|
|
info->engine_enum = engine_enum;
|
|
|
|
info->fault_id = dev->fault_id;
|
|
info->intr_mask |= BIT32(dev->intr_id);
|
|
info->reset_mask |= BIT32(dev->reset_id);
|
|
info->runlist_id = dev->runlist_id;
|
|
info->inst_id = dev->inst_id;
|
|
info->pri_base = dev->pri_base;
|
|
info->engine_id = dev->engine_id;
|
|
|
|
/* engine_id starts from 0 to NV_HOST_NUM_ENGINES */
|
|
f->active_engines_list[f->num_engines] = dev->engine_id;
|
|
f->num_engines = nvgpu_safe_add_u32(f->num_engines, 1U);
|
|
nvgpu_log_info(g, "gr info: engine_id %d runlist_id %d "
|
|
"intr_id %d reset_id %d engine_type %d "
|
|
"engine_enum %d inst_id %d",
|
|
dev->engine_id,
|
|
dev->runlist_id,
|
|
dev->intr_id,
|
|
dev->reset_id,
|
|
dev->type,
|
|
engine_enum,
|
|
dev->inst_id);
|
|
}
|
|
return 0;
|
|
}
|