drivers/gpu/drm/nouveau/nvkm/engine/gr/ga102.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nvkm/engine/gr/ga102.c
Extension
.c
Size
10679 bytes
Lines
359
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

struct netlist_region {
	u32 region_id;
	u32 data_size;
	u32 data_offset;
};

struct netlist_image_header {
	u32 version;
	u32 regions;
};

struct netlist_image {
	struct netlist_image_header header;
	struct netlist_region regions[];
};

struct netlist_av64 {
	u32 addr;
	u32 data_hi;
	u32 data_lo;
};

static int
ga102_gr_av64_to_init(struct nvkm_blob *blob, struct gf100_gr_pack **ppack)
{
	struct gf100_gr_init *init;
	struct gf100_gr_pack *pack;
	int nent;
	int i;

	nent = (blob->size / sizeof(struct netlist_av64));
	pack = vzalloc((sizeof(*pack) * 2) + (sizeof(*init) * (nent + 1)));
	if (!pack)
		return -ENOMEM;

	init = (void *)(pack + 2);
	pack[0].init = init;
	pack[0].type = 64;

	for (i = 0; i < nent; i++) {
		struct gf100_gr_init *ent = &init[i];
		struct netlist_av64 *av = &((struct netlist_av64 *)blob->data)[i];

		ent->addr = av->addr;
		ent->data = ((u64)av->data_hi << 32) | av->data_lo;
		ent->count = 1;
		ent->pitch = 1;
	}

	*ppack = pack;
	return 0;
}

static int
ga102_gr_load(struct gf100_gr *gr, int ver, const struct gf100_gr_fwif *fwif)
{
	struct nvkm_subdev *subdev = &gr->base.engine.subdev;
	const struct firmware *fw;
	const struct netlist_image *net;
	const struct netlist_region *fecs_inst = NULL;
	const struct netlist_region *fecs_data = NULL;
	const struct netlist_region *gpccs_inst = NULL;
	const struct netlist_region *gpccs_data = NULL;
	int ret, i;

	ret = nvkm_firmware_get(subdev, "gr/NET_img", 0, &fw);
	if (ret)
		return ret;

	net = (const void *)fw->data;
	nvkm_debug(subdev, "netlist version %d, %d regions\n",
		   net->header.version, net->header.regions);

	for (i = 0; i < net->header.regions; i++) {
		const struct netlist_region *reg = &net->regions[i];
		struct nvkm_blob blob = {
			.data = (void *)fw->data + reg->data_offset,
			.size = reg->data_size,
		};

		nvkm_debug(subdev, "\t%2d: %08x %08x\n",
			   reg->region_id, reg->data_offset, reg->data_size);

		switch (reg->region_id) {
		case  0: fecs_data = reg; break;
		case  1: fecs_inst = reg; break;
		case  2: gpccs_data = reg; break;
		case  3: gpccs_inst = reg; break;
		case  4: gk20a_gr_av_to_init(&blob, &gr->bundle); break;
		case  5: gk20a_gr_aiv_to_init(&blob, &gr->sw_ctx); break;

Annotation

Implementation Notes