示例#1
0
文件: engine.c 项目: hakzsam/nouveau
static int
nvkm_engine_init(struct nvkm_subdev *subdev)
{
    struct nvkm_engine *engine = nvkm_engine(subdev);
    struct nvkm_fb *fb = subdev->device->fb;
    int ret = 0, i;
    s64 time;

    if (!engine->usecount) {
        nvkm_trace(subdev, "init skipped, engine has no users\n");
        return ret;
    }

    if (engine->func->oneinit && !engine->subdev.oneinit) {
        nvkm_trace(subdev, "one-time init running...\n");
        time = ktime_to_us(ktime_get());
        ret = engine->func->oneinit(engine);
        if (ret) {
            nvkm_trace(subdev, "one-time init failed, %d\n", ret);
            return ret;
        }

        engine->subdev.oneinit = true;
        time = ktime_to_us(ktime_get()) - time;
        nvkm_trace(subdev, "one-time init completed in %lldus\n", time);
    }

    if (engine->func->init)
        ret = engine->func->init(engine);

    for (i = 0; fb && i < fb->tile.regions; i++)
        nvkm_engine_tile(engine, i);
    return ret;
}
示例#2
0
文件: subdev.c 项目: hakzsam/nouveau
int
nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
{
    struct nvkm_device *device = subdev->device;
    const char *action = suspend ? "suspend" : "fini";
    u32 pmc_enable = subdev->pmc_enable;
    s64 time;

    nvkm_trace(subdev, "%s running...\n", action);
    time = ktime_to_us(ktime_get());

    if (subdev->func->fini) {
        int ret = subdev->func->fini(subdev, suspend);
        if (ret) {
            nvkm_error(subdev, "%s failed, %d\n", action, ret);
            if (suspend)
                return ret;
        }
    }

    if (pmc_enable) {
        nvkm_mask(device, 0x000200, pmc_enable, 0x00000000);
        nvkm_mask(device, 0x000200, pmc_enable, pmc_enable);
        nvkm_rd32(device, 0x000200);
    }

    time = ktime_to_us(ktime_get()) - time;
    nvkm_trace(subdev, "%s completed in %lldus\n", action, time);
    return 0;
}
示例#3
0
文件: subdev.c 项目: AK101111/linux
int
nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
{
	struct nvkm_device *device = subdev->device;
	const char *action = suspend ? "suspend" : "fini";
	s64 time;

	nvkm_trace(subdev, "%s running...\n", action);
	time = ktime_to_us(ktime_get());

	if (subdev->func->fini) {
		int ret = subdev->func->fini(subdev, suspend);
		if (ret) {
			nvkm_error(subdev, "%s failed, %d\n", action, ret);
			if (suspend)
				return ret;
		}
	}

	nvkm_mc_reset(device, subdev->index);

	time = ktime_to_us(ktime_get()) - time;
	nvkm_trace(subdev, "%s completed in %lldus\n", action, time);
	return 0;
}
示例#4
0
文件: pcie.c 项目: 020gzh/linux
int
nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
{
	struct nvkm_subdev *subdev = &pci->subdev;
	enum nvkm_pcie_speed cur_speed, max_speed;
	struct pci_bus *pbus;
	int ret;

	if (!pci || !pci_is_pcie(pci->pdev))
		return 0;
	pbus = pci->pdev->bus;

	if (!pci->func->pcie.set_link)
		return -ENOSYS;

	nvkm_trace(subdev, "requested %s\n", nvkm_pcie_speeds[speed]);

	if (pci->func->pcie.version(pci) < 2) {
		nvkm_error(subdev, "setting link failed due to low version\n");
		return -ENODEV;
	}

	cur_speed = pci->func->pcie.cur_speed(pci);
	max_speed = min(nvkm_pcie_speed(pbus->max_bus_speed),
			pci->func->pcie.max_speed(pci));

	nvkm_trace(subdev, "current speed: %s\n", nvkm_pcie_speeds[cur_speed]);

	if (speed > max_speed) {
		nvkm_debug(subdev, "%s not supported by bus or card, dropping"
			   "requested speed to %s", nvkm_pcie_speeds[speed],
			   nvkm_pcie_speeds[max_speed]);
		speed = max_speed;
	}

	pci->pcie.speed = speed;
	pci->pcie.width = width;

	if (speed == cur_speed) {
		nvkm_debug(subdev, "requested matches current speed\n");
		return speed;
	}

	nvkm_debug(subdev, "set link to %s x%i\n",
		   nvkm_pcie_speeds[speed], width);

	ret = pci->func->pcie.set_link(pci, speed, width);
	if (ret < 0)
		nvkm_error(subdev, "setting link failed: %i\n", ret);

	return ret;
}
示例#5
0
文件: subdev.c 项目: hakzsam/nouveau
void
nvkm_subdev_del(struct nvkm_subdev **psubdev)
{
    struct nvkm_subdev *subdev = *psubdev;
    s64 time;

    if (subdev && !WARN_ON(!subdev->func)) {
        nvkm_trace(subdev, "destroy running...\n");
        time = ktime_to_us(ktime_get());
        if (subdev->func->dtor)
            *psubdev = subdev->func->dtor(subdev);
        time = ktime_to_us(ktime_get()) - time;
        nvkm_trace(subdev, "destroy completed in %lldus\n", time);
        kfree(*psubdev);
        *psubdev = NULL;
    }
}
示例#6
0
文件: pcie.c 项目: 020gzh/linux
static int
nvkm_pcie_set_version(struct nvkm_pci *pci, int version)
{
	if (!pci->func->pcie.set_version)
		return -ENOSYS;

	nvkm_trace(&pci->subdev, "set to version %i\n", version);
	pci->func->pcie.set_version(pci, version);
	return nvkm_pcie_get_version(pci);
}
示例#7
0
文件: subdev.c 项目: hakzsam/nouveau
int
nvkm_subdev_preinit(struct nvkm_subdev *subdev)
{
    s64 time;

    nvkm_trace(subdev, "preinit running...\n");
    time = ktime_to_us(ktime_get());

    if (subdev->func->preinit) {
        int ret = subdev->func->preinit(subdev);
        if (ret) {
            nvkm_error(subdev, "preinit failed, %d\n", ret);
            return ret;
        }
    }

    time = ktime_to_us(ktime_get()) - time;
    nvkm_trace(subdev, "preinit completed in %lldus\n", time);
    return 0;
}
示例#8
0
void
gf100_clkgate_init(struct nvkm_therm *therm,
		   const struct nvkm_therm_clkgate_pack *p)
{
	struct nvkm_device *device = therm->subdev.device;
	const struct nvkm_therm_clkgate_pack *pack;
	const struct nvkm_therm_clkgate_init *init;
	u32 next, addr;

	pack_for_each_init(init, pack, p) {
		next = init->addr + init->count * 8;
		addr = init->addr;

		nvkm_trace(&therm->subdev, "{ 0x%06x, %d, 0x%08x }\n",
			   init->addr, init->count, init->data);
		while (addr < next) {
			nvkm_trace(&therm->subdev, "\t0x%06x = 0x%08x\n",
				   addr, init->data);
			nvkm_wr32(device, addr, init->data);
			addr += 8;
		}
	}
示例#9
0
文件: subdev.c 项目: hakzsam/nouveau
int
nvkm_subdev_init(struct nvkm_subdev *subdev)
{
    s64 time;
    int ret;

    nvkm_trace(subdev, "init running...\n");
    time = ktime_to_us(ktime_get());

    if (subdev->func->oneinit && !subdev->oneinit) {
        s64 time;
        nvkm_trace(subdev, "one-time init running...\n");
        time = ktime_to_us(ktime_get());
        ret = subdev->func->oneinit(subdev);
        if (ret) {
            nvkm_error(subdev, "one-time init failed, %d\n", ret);
            return ret;
        }

        subdev->oneinit = true;
        time = ktime_to_us(ktime_get()) - time;
        nvkm_trace(subdev, "one-time init completed in %lldus\n", time);
    }

    if (subdev->func->init) {
        ret = subdev->func->init(subdev);
        if (ret) {
            nvkm_error(subdev, "init failed, %d\n", ret);
            return ret;
        }
    }

    time = ktime_to_us(ktime_get()) - time;
    nvkm_trace(subdev, "init completed in %lldus\n", time);
    return 0;
}
示例#10
0
文件: gk104.c 项目: AK101111/linux
static int
gk104_top_oneinit(struct nvkm_top *top)
{
	struct nvkm_subdev *subdev = &top->subdev;
	struct nvkm_device *device = subdev->device;
	struct nvkm_top_device *info = NULL;
	u32 data, type, inst;
	int i;

	for (i = 0; i < 64; i++) {
		if (!info) {
			if (!(info = nvkm_top_device_new(top)))
				return -ENOMEM;
			type = ~0;
			inst = 0;
		}

		data = nvkm_rd32(device, 0x022700 + (i * 0x04));
		nvkm_trace(subdev, "%02x: %08x\n", i, data);
		switch (data & 0x00000003) {
		case 0x00000000: /* NOT_VALID */
			continue;
		case 0x00000001: /* DATA */
			inst        = (data & 0x3c000000) >> 26;
			info->addr  = (data & 0x00fff000);
			info->fault = (data & 0x000000f8) >> 3;
			break;
		case 0x00000002: /* ENUM */
			if (data & 0x00000020)
				info->engine  = (data & 0x3c000000) >> 26;
			if (data & 0x00000010)
				info->runlist = (data & 0x01e00000) >> 21;
			if (data & 0x00000008)
				info->intr    = (data & 0x000f8000) >> 15;
			if (data & 0x00000004)
				info->reset   = (data & 0x00003e00) >> 9;
			break;
		case 0x00000003: /* ENGINE_TYPE */
			type = (data & 0x7ffffffc) >> 2;
			break;
		}

		if (data & 0x80000000)
			continue;

		/* Translate engine type to NVKM engine identifier. */
#define A_(A) if (inst == 0) info->index = NVKM_ENGINE_##A
#define B_(A) if (inst + NVKM_ENGINE_##A##0 < NVKM_ENGINE_##A##_LAST + 1)      \
		info->index = NVKM_ENGINE_##A##0 + inst
		switch (type) {
		case 0x00000000: A_(GR    ); break;
		case 0x00000001: A_(CE0   ); break;
		case 0x00000002: A_(CE1   ); break;
		case 0x00000003: A_(CE2   ); break;
		case 0x00000008: A_(MSPDEC); break;
		case 0x00000009: A_(MSPPP ); break;
		case 0x0000000a: A_(MSVLD ); break;
		case 0x0000000b: A_(MSENC ); break;
		case 0x0000000c: A_(VIC   ); break;
		case 0x0000000d: A_(SEC   ); break;
		case 0x0000000e: B_(NVENC ); break;
		case 0x0000000f: A_(NVENC1); break;
		case 0x00000010: A_(NVDEC ); break;
		case 0x00000013: B_(CE    ); break;
			break;
		default:
			break;
		}

		nvkm_debug(subdev, "%02x.%d (%8s): addr %06x fault %2d "
				   "engine %2d runlist %2d intr %2d "
				   "reset %2d\n", type, inst,
			   info->index == NVKM_SUBDEV_NR ? NULL :
					  nvkm_subdev_name[info->index],
			   info->addr, info->fault, info->engine, info->runlist,
			   info->intr, info->reset);
		info = NULL;
	}

	return 0;
}