mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: prepare sec2 msg, allocator units
SEC2 message handling unit can't be part of command handling unit as it creates circular dependencies with the SEC2 tasks (ACR bootstrap) SEC2 allocator unit shall encompass DMEM allocator and other allocators used by SEC2. JIRA NVGPU-2075 Change-Id: Ic2b8204d8225f2056785f035cbecdb776a9ecfe9 Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2085749 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
eef3ef7773
commit
e848e9dfb8
@@ -29,7 +29,6 @@
|
||||
#include <nvgpu/sec2.h>
|
||||
#include <nvgpu/engine_queue.h>
|
||||
#include <nvgpu/sec2/queue.h>
|
||||
#include <nvgpu/sec2if/sec2_if_sec2.h>
|
||||
#include <nvgpu/sec2if/sec2_if_cmn.h>
|
||||
|
||||
/* command post operation functions */
|
||||
@@ -145,189 +144,6 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Message/Event request handlers */
|
||||
static int sec2_response_handle(struct nvgpu_sec2 *sec2,
|
||||
struct nv_flcn_msg_sec2 *msg)
|
||||
{
|
||||
struct gk20a *g = sec2->g;
|
||||
|
||||
return nvgpu_sec2_seq_response_handle(g, &sec2->sequences,
|
||||
msg, msg->hdr.seq_id);
|
||||
}
|
||||
|
||||
static int sec2_handle_event(struct nvgpu_sec2 *sec2,
|
||||
struct nv_flcn_msg_sec2 *msg)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
switch (msg->hdr.unit_id) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool sec2_read_message(struct nvgpu_sec2 *sec2,
|
||||
u32 queue_id, struct nv_flcn_msg_sec2 *msg, int *status)
|
||||
{
|
||||
struct gk20a *g = sec2->g;
|
||||
u32 read_size;
|
||||
int err;
|
||||
|
||||
*status = 0;
|
||||
|
||||
if (nvgpu_sec2_queue_is_empty(sec2->queues, queue_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!nvgpu_sec2_queue_read(g, sec2->queues, queue_id,
|
||||
&sec2->flcn, &msg->hdr,
|
||||
PMU_MSG_HDR_SIZE, status)) {
|
||||
nvgpu_err(g, "fail to read msg from queue %d", queue_id);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
if (msg->hdr.unit_id == NV_SEC2_UNIT_REWIND) {
|
||||
err = nvgpu_sec2_queue_rewind(&sec2->flcn,
|
||||
sec2->queues, queue_id);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "fail to rewind queue %d", queue_id);
|
||||
*status = err;
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
/* read again after rewind */
|
||||
if (!nvgpu_sec2_queue_read(g, sec2->queues, queue_id,
|
||||
&sec2->flcn, &msg->hdr,
|
||||
PMU_MSG_HDR_SIZE, status)) {
|
||||
nvgpu_err(g, "fail to read msg from queue %d",
|
||||
queue_id);
|
||||
goto clean_up;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NV_SEC2_UNITID_IS_VALID(msg->hdr.unit_id)) {
|
||||
nvgpu_err(g, "read invalid unit_id %d from queue %d",
|
||||
msg->hdr.unit_id, queue_id);
|
||||
*status = -EINVAL;
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
if (msg->hdr.size > PMU_MSG_HDR_SIZE) {
|
||||
read_size = msg->hdr.size - PMU_MSG_HDR_SIZE;
|
||||
if (!nvgpu_sec2_queue_read(g, sec2->queues, queue_id,
|
||||
&sec2->flcn, &msg->msg,
|
||||
read_size, status)) {
|
||||
nvgpu_err(g, "fail to read msg from queue %d",
|
||||
queue_id);
|
||||
goto clean_up;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
clean_up:
|
||||
return false;
|
||||
}
|
||||
|
||||
static int sec2_process_init_msg(struct nvgpu_sec2 *sec2,
|
||||
struct nv_flcn_msg_sec2 *msg)
|
||||
{
|
||||
struct gk20a *g = sec2->g;
|
||||
struct sec2_init_msg_sec2_init *sec2_init;
|
||||
u32 tail = 0;
|
||||
int err = 0;
|
||||
|
||||
g->ops.sec2.msgq_tail(g, sec2, &tail, QUEUE_GET);
|
||||
|
||||
err = nvgpu_falcon_copy_from_emem(&sec2->flcn, tail,
|
||||
(u8 *)&msg->hdr, PMU_MSG_HDR_SIZE, 0U);
|
||||
if (err != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (msg->hdr.unit_id != NV_SEC2_UNIT_INIT) {
|
||||
nvgpu_err(g, "expecting init msg");
|
||||
err = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = nvgpu_falcon_copy_from_emem(&sec2->flcn, tail + PMU_MSG_HDR_SIZE,
|
||||
(u8 *)&msg->msg, msg->hdr.size - PMU_MSG_HDR_SIZE, 0U);
|
||||
if (err != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (msg->msg.init.msg_type != PMU_INIT_MSG_TYPE_PMU_INIT) {
|
||||
nvgpu_err(g, "expecting init msg");
|
||||
err = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
tail += ALIGN(msg->hdr.size, PMU_DMEM_ALIGNMENT);
|
||||
g->ops.sec2.msgq_tail(g, sec2, &tail, QUEUE_SET);
|
||||
|
||||
sec2_init = &msg->msg.init.sec2_init;
|
||||
|
||||
err = nvgpu_sec2_queues_init(g, sec2->queues, sec2_init);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!nvgpu_alloc_initialized(&sec2->dmem)) {
|
||||
/* Align start and end addresses */
|
||||
u32 start = ALIGN(sec2_init->nv_managed_area_offset,
|
||||
PMU_DMEM_ALLOC_ALIGNMENT);
|
||||
|
||||
u32 end = (sec2_init->nv_managed_area_offset +
|
||||
sec2_init->nv_managed_area_size) &
|
||||
~(PMU_DMEM_ALLOC_ALIGNMENT - 1U);
|
||||
u32 size = end - start;
|
||||
|
||||
nvgpu_bitmap_allocator_init(g, &sec2->dmem, "sec2_dmem",
|
||||
start, size, PMU_DMEM_ALLOC_ALIGNMENT, 0U);
|
||||
}
|
||||
|
||||
sec2->sec2_ready = true;
|
||||
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
int nvgpu_sec2_process_message(struct nvgpu_sec2 *sec2)
|
||||
{
|
||||
struct gk20a *g = sec2->g;
|
||||
struct nv_flcn_msg_sec2 msg;
|
||||
int status = 0;
|
||||
|
||||
if (unlikely(!sec2->sec2_ready)) {
|
||||
status = sec2_process_init_msg(sec2, &msg);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
while (sec2_read_message(sec2,
|
||||
SEC2_NV_MSGQ_LOG_ID, &msg, &status)) {
|
||||
|
||||
nvgpu_sec2_dbg(g, "read msg hdr: ");
|
||||
nvgpu_sec2_dbg(g, "unit_id = 0x%08x, size = 0x%08x",
|
||||
msg.hdr.unit_id, msg.hdr.size);
|
||||
nvgpu_sec2_dbg(g, "ctrl_flags = 0x%08x, seq_id = 0x%08x",
|
||||
msg.hdr.ctrl_flags, msg.hdr.seq_id);
|
||||
|
||||
msg.hdr.ctrl_flags &= ~PMU_CMD_FLAGS_PMU_MASK;
|
||||
|
||||
if (msg.hdr.ctrl_flags == PMU_CMD_FLAGS_EVENT) {
|
||||
sec2_handle_event(sec2, &msg);
|
||||
} else {
|
||||
sec2_response_handle(sec2, &msg);
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return status;
|
||||
}
|
||||
|
||||
int nvgpu_sec2_wait_message_cond(struct nvgpu_sec2 *sec2, u32 timeout_ms,
|
||||
void *var, u8 val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user