drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c
Extension
.c
Size
4531 bytes
Lines
165
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#include "priv.h"

#include <core/firmware.h>
#include <subdev/mc.h>
#include <subdev/timer.h>

#include <nvfw/sec2.h>

static int
nvkm_sec2_finimsg(void *priv, struct nvfw_falcon_msg *hdr)
{
	struct nvkm_sec2 *sec2 = priv;

	atomic_set(&sec2->running, 0);
	return 0;
}

static int
nvkm_sec2_fini(struct nvkm_engine *engine, enum nvkm_suspend_state suspend)
{
	struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
	struct nvkm_subdev *subdev = &sec2->engine.subdev;
	struct nvkm_falcon *falcon = &sec2->falcon;
	struct nvkm_falcon_cmdq *cmdq = sec2->cmdq;
	struct nvfw_falcon_cmd cmd = {
		.unit_id = sec2->func->unit_unload,
		.size = sizeof(cmd),
	};
	int ret;

	if (!subdev->use.enabled)
		return 0;

	if (atomic_read(&sec2->initmsg) == 1) {
		ret = nvkm_falcon_cmdq_send(cmdq, &cmd, nvkm_sec2_finimsg, sec2,
					    msecs_to_jiffies(1000));
		WARN_ON(ret);

		nvkm_msec(subdev->device, 2000,
			if (nvkm_falcon_rd32(falcon, 0x100) & 0x00000010)
				break;
		);
	}

	nvkm_inth_block(&subdev->inth);

	nvkm_falcon_cmdq_fini(cmdq);
	falcon->func->disable(falcon);
	nvkm_falcon_put(falcon, subdev);
	return 0;
}

static int
nvkm_sec2_init(struct nvkm_engine *engine)
{
	struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
	struct nvkm_subdev *subdev = &sec2->engine.subdev;
	struct nvkm_falcon *falcon = &sec2->falcon;
	int ret;

	ret = nvkm_falcon_get(falcon, subdev);
	if (ret)
		return ret;

	nvkm_falcon_wr32(falcon, 0x014, 0xffffffff);
	atomic_set(&sec2->initmsg, 0);
	atomic_set(&sec2->running, 1);
	nvkm_inth_allow(&subdev->inth);

	nvkm_falcon_start(falcon);
	return 0;
}

static int
nvkm_sec2_oneinit(struct nvkm_engine *engine)
{
	struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
	struct nvkm_subdev *subdev = &sec2->engine.subdev;
	struct nvkm_intr *intr = &sec2->engine.subdev.device->mc->intr;
	enum nvkm_intr_type type = NVKM_INTR_SUBDEV;

	if (sec2->func->intr_vector) {
		intr = sec2->func->intr_vector(sec2, &type);
		if (IS_ERR(intr))
			return PTR_ERR(intr);
	}

	return nvkm_inth_add(intr, type, NVKM_INTR_PRIO_NORMAL, subdev, sec2->func->intr,
			     &subdev->inth);
}

Annotation

Implementation Notes