drivers/gpu/drm/nouveau/nvkm/engine/device/user.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
Extension
.c
Size
9762 bytes
Lines
350
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 nvkm_udevice {
	struct nvkm_object object;
	struct nvkm_device *device;
};

static int
nvkm_udevice_info_subdev(struct nvkm_device *device, u64 mthd, u64 *data)
{
	struct nvkm_subdev *subdev;
	enum nvkm_subdev_type type;

	switch (mthd & NV_DEVICE_INFO_UNIT) {
	case NV_DEVICE_HOST(0): type = NVKM_ENGINE_FIFO; break;
	default:
		return -EINVAL;
	}

	subdev = nvkm_device_subdev(device, type, 0);
	if (subdev)
		return nvkm_subdev_info(subdev, mthd, data);
	return -ENODEV;
}

static void
nvkm_udevice_info_v1(struct nvkm_device *device,
		     struct nv_device_info_v1_data *args)
{
	if (args->mthd & NV_DEVICE_INFO_UNIT) {
		if (nvkm_udevice_info_subdev(device, args->mthd, &args->data))
			args->mthd = NV_DEVICE_INFO_INVALID;
		return;
	}
	args->mthd = NV_DEVICE_INFO_INVALID;
}

static int
nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
{
	struct nvkm_object *object = &udev->object;
	struct nvkm_device *device = udev->device;
	struct nvkm_fb *fb = device->fb;
	struct nvkm_instmem *imem = device->imem;
	union {
		struct nv_device_info_v0 v0;
		struct nv_device_info_v1 v1;
	} *args = data;
	int ret = -ENOSYS, i;

	nvif_ioctl(object, "device info size %d\n", size);
	if (!(ret = nvif_unpack(ret, &data, &size, args->v1, 1, 1, true))) {
		nvif_ioctl(object, "device info vers %d count %d\n",
			   args->v1.version, args->v1.count);
		if (args->v1.count * sizeof(args->v1.data[0]) == size) {
			for (i = 0; i < args->v1.count; i++)
				nvkm_udevice_info_v1(device, &args->v1.data[i]);
			return 0;
		}
		return -EINVAL;
	} else
	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
		nvif_ioctl(object, "device info vers %d\n", args->v0.version);
	} else
		return ret;

	switch (device->chipset) {
	case 0x01a:
	case 0x01f:
	case 0x04c:
	case 0x04e:
	case 0x063:
	case 0x067:
	case 0x068:
	case 0x0aa:
	case 0x0ac:
	case 0x0af:
		args->v0.platform = NV_DEVICE_INFO_V0_IGP;
		break;
	default:
		switch (device->type) {
		case NVKM_DEVICE_PCI:
			args->v0.platform = NV_DEVICE_INFO_V0_PCI;
			break;
		case NVKM_DEVICE_AGP:
			args->v0.platform = NV_DEVICE_INFO_V0_AGP;
			break;
		case NVKM_DEVICE_PCIE:
			args->v0.platform = NV_DEVICE_INFO_V0_PCIE;
			break;
		case NVKM_DEVICE_TEGRA:
			args->v0.platform = NV_DEVICE_INFO_V0_SOC;

Annotation

Implementation Notes