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; }
static void nvkm_engine_intr(struct nvkm_subdev *subdev) { struct nvkm_engine *engine = nvkm_engine(subdev); if (engine->func->intr) engine->func->intr(engine); }
int nvkm_parent_lclass(struct nvkm_object *parent, u32 *lclass, int size) { struct nvkm_sclass *sclass; struct nvkm_engine *engine; struct nvkm_oclass *oclass; int nr = -1, i; u64 mask; sclass = nv_parent(parent)->sclass; while (sclass) { if (++nr < size) lclass[nr] = sclass->oclass->handle & 0xffff; sclass = sclass->sclass; } mask = nv_parent(parent)->engine; while (i = __ffs64(mask), mask) { engine = nvkm_engine(parent, i); if (engine && (oclass = engine->sclass)) { while (oclass->ofuncs) { if (++nr < size) lclass[nr] = oclass->handle & 0xffff; oclass++; } } mask &= ~(1ULL << i); } return nr + 1; }
static int nvkm_engine_fini(struct nvkm_subdev *subdev, bool suspend) { struct nvkm_engine *engine = nvkm_engine(subdev); if (engine->func->fini) return engine->func->fini(engine, suspend); return 0; }
static void * nvkm_engine_dtor(struct nvkm_subdev *subdev) { struct nvkm_engine *engine = nvkm_engine(subdev); if (engine->func->dtor) return engine->func->dtor(engine); return engine; }
int nvkm_parent_sclass(struct nvkm_object *parent, u16 handle, struct nvkm_object **pengine, struct nvkm_oclass **poclass) { struct nvkm_sclass *sclass; struct nvkm_engine *engine; struct nvkm_oclass *oclass; u64 mask; sclass = nv_parent(parent)->sclass; while (sclass) { if ((sclass->oclass->handle & 0xffff) == handle) { *pengine = &parent->engine->subdev.object; *poclass = sclass->oclass; return 0; } sclass = sclass->sclass; } mask = nv_parent(parent)->engine; while (mask) { int i = __ffs64(mask); if (nv_iclass(parent, NV_CLIENT_CLASS)) engine = nv_engine(nv_client(parent)->device); else engine = nvkm_engine(parent, i); if (engine) { oclass = engine->sclass; while (oclass->ofuncs) { if ((oclass->handle & 0xffff) == handle) { *pengine = nv_object(engine); *poclass = oclass; return 0; } oclass++; } } mask &= ~(1ULL << i); } return -EINVAL; }