drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
Extension
.c
Size
5221 bytes
Lines
197
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 "gf100.h"

#include <core/memory.h>
#include <core/option.h>
#include <subdev/fb.h>
#include <subdev/mmu.h>

struct nvkm_vmm *
gf100_bar_bar1_vmm(struct nvkm_bar *base)
{
	return gf100_bar(base)->bar[1].vmm;
}

void
gf100_bar_bar1_wait(struct nvkm_bar *base)
{
	/* NFI why it's twice. */
	nvkm_bar_flush(base);
	nvkm_bar_flush(base);
}

void
gf100_bar_bar1_fini(struct nvkm_bar *bar)
{
	nvkm_mask(bar->subdev.device, 0x001704, 0x80000000, 0x00000000);
}

void
gf100_bar_bar1_init(struct nvkm_bar *base)
{
	struct nvkm_device *device = base->subdev.device;
	struct gf100_bar *bar = gf100_bar(base);
	const u32 addr = nvkm_memory_addr(bar->bar[1].inst) >> 12;
	nvkm_wr32(device, 0x001704, 0x80000000 | addr);
}

struct nvkm_vmm *
gf100_bar_bar2_vmm(struct nvkm_bar *base)
{
	return gf100_bar(base)->bar[0].vmm;
}

void
gf100_bar_bar2_fini(struct nvkm_bar *bar)
{
	nvkm_mask(bar->subdev.device, 0x001714, 0x80000000, 0x00000000);
}

void
gf100_bar_bar2_init(struct nvkm_bar *base)
{
	struct nvkm_device *device = base->subdev.device;
	struct gf100_bar *bar = gf100_bar(base);
	u32 addr = nvkm_memory_addr(bar->bar[0].inst) >> 12;
	if (bar->bar2_halve)
		addr |= 0x40000000;
	nvkm_wr32(device, 0x001714, 0x80000000 | addr);
}

static int
gf100_bar_oneinit_bar(struct gf100_bar *bar, struct gf100_barN *bar_vm,
		      struct lock_class_key *key, enum nvkm_bar_id bar_id)
{
	struct nvkm_device *device = bar->base.subdev.device;
	resource_size_t bar_len;
	int ret;

	ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, 0x1000, 0, false,
			      &bar_vm->inst);
	if (ret)
		return ret;

	bar_len = device->func->resource_size(device, bar_id);
	if (!bar_len)
		return -ENOMEM;
	if (bar_id == NVKM_BAR2_INST && bar->bar2_halve)
		bar_len >>= 1;

	ret = nvkm_vmm_new(device, 0, bar_len, NULL, 0, key,
			   (bar_id == NVKM_BAR2_INST) ? "bar2" : "bar1", &bar_vm->vmm);
	if (ret)
		return ret;

	atomic_inc(&bar_vm->vmm->engref[NVKM_SUBDEV_BAR]);
	bar_vm->vmm->debug = bar->base.subdev.debug;

	/*
	 * Bootstrap page table lookup.
	 */
	if (bar_id == NVKM_BAR2_INST) {

Annotation

Implementation Notes