mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
nvgpu: ga10b: gsp: implement runlist submit apis
- implemented device info cmd to send device info to the gsp for runlist submission. Currently GSP scheduler support only GR engine '0' instance. - implemented runlist submit cmd. GSP firmware will submit the corresponding runlist by writing into submit registers. This command is direct replacement of hw_submit ga10b hal for GR engine. NVGPU-6790 Signed-off-by: Ramesh Mylavarapu <rmylavarapu@nvidia.com> Change-Id: I5dc573a6ad698fe20b49a3466a8e50b94cae74df Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2608923 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
6c1a77dfa9
commit
2a98d20263
171
drivers/gpu/nvgpu/common/gsp_scheduler/gsp_runlist.c
Normal file
171
drivers/gpu/nvgpu/common/gsp_scheduler/gsp_runlist.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 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 "gsp_runlist.h"
|
||||
|
||||
#include <nvgpu/gk20a.h>
|
||||
#include <nvgpu/log.h>
|
||||
#include <nvgpu/gsp.h>
|
||||
#include <nvgpu/io.h>
|
||||
#include <nvgpu/device.h>
|
||||
#include <nvgpu/nvgpu_mem.h>
|
||||
#include <nvgpu/runlist.h>
|
||||
|
||||
#include "ipc/gsp_cmd.h"
|
||||
#include "ipc/gsp_msg.h"
|
||||
|
||||
static void gsp_handle_cmd_ack(struct gk20a *g, struct nv_flcn_msg_gsp *msg,
|
||||
void *param, u32 status)
|
||||
{
|
||||
bool *command_ack = param;
|
||||
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
switch (msg->hdr.unit_id) {
|
||||
case NV_GSP_UNIT_NULL:
|
||||
nvgpu_info(g, "Reply to NV_GSP_UNIT_NULL");
|
||||
*command_ack = true;
|
||||
break;
|
||||
case NV_GSP_UNIT_SUBMIT_RUNLIST:
|
||||
nvgpu_info(g, "Reply to NV_GSP_UNIT_RUNLIST_INFO");
|
||||
*command_ack = true;
|
||||
break;
|
||||
case NV_GSP_UNIT_DEVICES_INFO:
|
||||
nvgpu_info(g, "Reply to NV_GSP_UNIT_DEVICES_INFO");
|
||||
*command_ack = true;
|
||||
break;
|
||||
default:
|
||||
nvgpu_err(g, "Un-handled response from GSP");
|
||||
*command_ack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gsp_get_runlist_info(struct gk20a *g,
|
||||
struct nvgpu_gsp_runlist_info *rl_info, struct nvgpu_runlist *runlist)
|
||||
{
|
||||
u64 runlist_iova;
|
||||
u32 aperture, num_entries;
|
||||
|
||||
runlist_iova = nvgpu_mem_get_addr(g, &runlist->domain->mem_hw->mem);
|
||||
|
||||
num_entries = runlist->domain->mem_hw->count;
|
||||
|
||||
aperture = g->ops.runlist.get_runlist_aperture(g, runlist);
|
||||
|
||||
rl_info->runlist_base_lo = u64_lo32(runlist_iova);
|
||||
rl_info->runlist_base_hi = u64_hi32(runlist_iova);
|
||||
rl_info->aperture = aperture;
|
||||
rl_info->num_entries = num_entries;
|
||||
rl_info->runlist_id = runlist->id;
|
||||
}
|
||||
|
||||
int nvgpu_gsp_runlist_submit(struct gk20a *g, struct nvgpu_runlist *runlist)
|
||||
{
|
||||
struct nv_flcn_cmd_gsp cmd;
|
||||
bool command_ack = false;
|
||||
int err = 0;
|
||||
size_t tmp_size;
|
||||
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
(void) memset(&cmd, 0, sizeof(struct nv_flcn_cmd_gsp));
|
||||
cmd.hdr.unit_id = NV_GSP_UNIT_SUBMIT_RUNLIST;
|
||||
tmp_size = GSP_CMD_HDR_SIZE + sizeof(struct nvgpu_gsp_runlist_info);
|
||||
nvgpu_assert(tmp_size <= U64(U8_MAX));
|
||||
cmd.hdr.size = (u8)tmp_size;
|
||||
|
||||
/* copy domain info into cmd buffer */
|
||||
gsp_get_runlist_info(g, &cmd.cmd.runlist, runlist);
|
||||
|
||||
err = nvgpu_gsp_cmd_post(g, &cmd, GSP_NV_CMDQ_LOG_ID,
|
||||
gsp_handle_cmd_ack, &command_ack, U32_MAX);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "command post failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = nvgpu_gsp_wait_message_cond(g, nvgpu_get_poll_timeout(g),
|
||||
&command_ack, U8(true));
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "command ack receive failed");
|
||||
}
|
||||
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static void gsp_get_device_info(struct gk20a *g,
|
||||
struct nvgpu_gsp_device_info *dev_info)
|
||||
{
|
||||
const struct nvgpu_device *device;
|
||||
|
||||
/* Only GRAPHICS 0-instance is supported by GSP scheduler.
|
||||
* In future, more devices can be looped through and send it to the GSP.
|
||||
*/
|
||||
device = nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS, 0);
|
||||
|
||||
/* copy domain info into cmd buffer */
|
||||
dev_info->device_id = NVGPU_DEVTYPE_GRAPHICS;
|
||||
dev_info->is_engine = true;
|
||||
dev_info->engine_type = device->type;
|
||||
dev_info->engine_id = device->engine_id;
|
||||
dev_info->instance_id = device->inst_id;
|
||||
dev_info->rl_engine_id = device->rleng_id;
|
||||
dev_info->dev_pri_base = device->pri_base;
|
||||
dev_info->runlist_pri_base = device->rl_pri_base;
|
||||
}
|
||||
|
||||
int nvgpu_gsp_send_devices_info(struct gk20a *g)
|
||||
{
|
||||
struct nv_flcn_cmd_gsp cmd;
|
||||
bool command_ack = false;
|
||||
int err = 0;
|
||||
size_t tmp_size;
|
||||
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
(void) memset(&cmd, 0, sizeof(struct nv_flcn_cmd_gsp));
|
||||
cmd.hdr.unit_id = NV_GSP_UNIT_DEVICES_INFO;
|
||||
tmp_size = GSP_CMD_HDR_SIZE + sizeof(struct nvgpu_gsp_device_info);
|
||||
nvgpu_assert(tmp_size <= U64(U8_MAX));
|
||||
cmd.hdr.size = tmp_size;
|
||||
|
||||
/* copy domain info into cmd buffer */
|
||||
gsp_get_device_info(g, &cmd.cmd.device);
|
||||
|
||||
err = nvgpu_gsp_cmd_post(g, &cmd, GSP_NV_CMDQ_LOG_ID,
|
||||
gsp_handle_cmd_ack, &command_ack, U32_MAX);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "command post failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = nvgpu_gsp_wait_message_cond(g, nvgpu_get_poll_timeout(g),
|
||||
&command_ack, U8(true));
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "command ack receive failed");
|
||||
}
|
||||
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
100
drivers/gpu/nvgpu/common/gsp_scheduler/gsp_runlist.h
Normal file
100
drivers/gpu/nvgpu/common/gsp_scheduler/gsp_runlist.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
|
||||
#ifndef NVGPU_GSP_RUNLIST
|
||||
#define NVGPU_GSP_RUNLIST
|
||||
|
||||
#include <nvgpu/device.h>
|
||||
|
||||
#define NVGPU_GSP_MAX_DEVTYPE 1U
|
||||
|
||||
struct nvgpu_gsp_device_info {
|
||||
/*
|
||||
* Device index
|
||||
*/
|
||||
u8 device_id;
|
||||
/*
|
||||
* TRUE when the device is a Host-driven method engine. FALSE otherwise.
|
||||
*/
|
||||
bool is_engine;
|
||||
/*
|
||||
* The device's DEV_RUNLIST_PRI_BASE is the offset into BAR0 for the device's
|
||||
* NV_RUNLIST PRI space.
|
||||
*/
|
||||
u32 runlist_pri_base;
|
||||
/*
|
||||
* Engine description, like graphics, or copy engine.
|
||||
*/
|
||||
u32 engine_type;
|
||||
/*
|
||||
* The unique per-device ID that host uses to identify any given engine.
|
||||
*/
|
||||
u32 engine_id;
|
||||
/*
|
||||
* Specifies instance of a device, allowing SW to distinguish between
|
||||
* multiple copies of a device present on the chip.
|
||||
*/
|
||||
u32 instance_id;
|
||||
/*
|
||||
* Device's runlist-based engine ID.
|
||||
*/
|
||||
u32 rl_engine_id;
|
||||
/*
|
||||
* The device's DEV_PRI_BASE is the offset into BAR0 for accessing the
|
||||
* register space for the target device.
|
||||
*/
|
||||
u32 dev_pri_base;
|
||||
};
|
||||
|
||||
struct nvgpu_gsp_runlist_info {
|
||||
/*
|
||||
* Device id to which this runlist belongs to
|
||||
*/
|
||||
u8 device_id;
|
||||
/*
|
||||
* Domain id to which this runlist need to mapped to
|
||||
*/
|
||||
u8 domain_id;
|
||||
/*
|
||||
* Indicates how many runlist entries are in the newly submitted runlist
|
||||
*/
|
||||
u32 num_entries;
|
||||
/*
|
||||
* Indicates how many runlist aperture
|
||||
*/
|
||||
u32 aperture;
|
||||
/*
|
||||
* ID contains the identifier of the runlist.
|
||||
*/
|
||||
u32 runlist_id;
|
||||
/*
|
||||
*NV_RUNLIST_SUBMIT_BASE_L0 in-memory location of runlist.
|
||||
*/
|
||||
u32 runlist_base_lo;
|
||||
/*
|
||||
*NV_RUNLIST_SUBMIT_BASE_Hi in-memory location of runlist.
|
||||
*/
|
||||
u32 runlist_base_hi;
|
||||
};
|
||||
|
||||
int nvgpu_gsp_send_devices_info(struct gk20a *g);
|
||||
#endif // NVGPU_GSP_RUNLIST
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "gsp_scheduler.h"
|
||||
#include "ipc/gsp_seq.h"
|
||||
#include "ipc/gsp_queue.h"
|
||||
#include "gsp_runlist.h"
|
||||
|
||||
static void gsp_sched_get_file_names(struct gk20a *g, struct gsp_fw *gsp_ucode)
|
||||
{
|
||||
@@ -205,6 +206,11 @@ int nvgpu_gsp_sched_bootstrap_ns(struct gk20a *g)
|
||||
goto de_init;
|
||||
}
|
||||
|
||||
status = nvgpu_gsp_send_devices_info(g);
|
||||
if (status != 0) {
|
||||
nvgpu_err(g, "gsp send device info failed");
|
||||
}
|
||||
|
||||
return status;
|
||||
de_init:
|
||||
nvgpu_gsp_sched_sw_deinit(g);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define NVGPU_GSP_CMD_IF_H
|
||||
|
||||
#include <nvgpu/types.h>
|
||||
#include "../gsp_runlist.h"
|
||||
#include "gsp_seq.h"
|
||||
|
||||
struct gk20a;
|
||||
@@ -35,6 +36,8 @@ struct gk20a;
|
||||
#define NV_GSP_UNIT_REWIND NV_FLCN_UNIT_ID_REWIND
|
||||
#define NV_GSP_UNIT_NULL 0x01U
|
||||
#define NV_GSP_UNIT_INIT 0x02U
|
||||
#define NV_GSP_UNIT_DEVICES_INFO 0x03U
|
||||
#define NV_GSP_UNIT_SUBMIT_RUNLIST 0x04U
|
||||
#define NV_GSP_UNIT_END 0x0AU
|
||||
|
||||
#define GSP_MSG_HDR_SIZE U32(sizeof(struct gsp_hdr))
|
||||
@@ -49,6 +52,10 @@ struct gsp_hdr {
|
||||
|
||||
struct nv_flcn_cmd_gsp {
|
||||
struct gsp_hdr hdr;
|
||||
union {
|
||||
struct nvgpu_gsp_device_info device;
|
||||
struct nvgpu_gsp_runlist_info runlist;
|
||||
} cmd;
|
||||
};
|
||||
|
||||
u8 gsp_unit_id_is_valid(u8 id);
|
||||
|
||||
Reference in New Issue
Block a user