int nouveau_client_init(struct nouveau_client *client) { int ret; nv_debug(client, "init running\n"); ret = nouveau_handle_init(client->root); nv_debug(client, "init completed with %d\n", ret); return ret; }
static int nvkm_ioctl_new(struct nouveau_handle *parent, void *data, u32 size) { union { struct nvif_ioctl_new_v0 v0; } *args = data; struct nouveau_client *client = nouveau_client(parent->object); struct nouveau_object *engctx = NULL; struct nouveau_object *object = NULL; struct nouveau_object *engine; struct nouveau_oclass *oclass; struct nouveau_handle *handle; u32 _handle, _oclass; int ret; nv_ioctl(client, "new size %d\n", size); if (nvif_unpack(args->v0, 0, 0, true)) { _handle = args->v0.handle; _oclass = args->v0.oclass; } else return ret; nv_ioctl(client, "new vers %d handle %08x class %08x " "route %02x token %llx\n", args->v0.version, _handle, _oclass, args->v0.route, args->v0.token); if (!nv_iclass(parent->object, NV_PARENT_CLASS)) { nv_debug(parent->object, "cannot have children (ctor)\n"); ret = -ENODEV; goto fail_class; } /* check that parent supports the requested subclass */ ret = nouveau_parent_sclass(parent->object, _oclass, &engine, &oclass); if (ret) { nv_debug(parent->object, "illegal class 0x%04x\n", _oclass); goto fail_class; } /* make sure engine init has been completed *before* any objects * it controls are created - the constructors may depend on * state calculated at init (ie. default context construction) */ if (engine) { ret = nouveau_object_inc(engine); if (ret) goto fail_class; } /* if engine requires it, create a context object to insert * between the parent and its children (eg. PGRAPH context) */ if (engine && nv_engine(engine)->cclass) { ret = nouveau_object_ctor(parent->object, engine, nv_engine(engine)->cclass, data, size, &engctx); if (ret) goto fail_engctx; } else { nouveau_object_ref(parent->object, &engctx); } /* finally, create new object and bind it to its handle */ ret = nouveau_object_ctor(engctx, engine, oclass, data, size, &object); client->data = object; if (ret) goto fail_ctor; ret = nouveau_object_inc(object); if (ret) goto fail_init; ret = nouveau_handle_create(parent->object, parent->name, _handle, object, &handle); if (ret) goto fail_handle; ret = nouveau_handle_init(handle); handle->route = args->v0.route; handle->token = args->v0.token; if (ret) nouveau_handle_destroy(handle); fail_handle: nouveau_object_dec(object, false); fail_init: nouveau_object_ref(NULL, &object); fail_ctor: nouveau_object_ref(NULL, &engctx); fail_engctx: if (engine) nouveau_object_dec(engine, false); fail_class: return ret; }