int nouveau_bar_alloc(struct nouveau_bar *bar, struct nouveau_object *parent, struct nouveau_mem *mem, struct nouveau_object **pobject) { struct nouveau_object *engine = nv_object(bar); return nouveau_object_ctor(parent, engine, &nouveau_barobj_oclass, mem, 0, pobject); }
int nouveau_bar_alloc(struct nouveau_bar *bar, struct nouveau_object *parent, struct nouveau_mem *mem, struct nouveau_object **pobject) { struct nouveau_object *engine = nv_object(bar); int ret = -ENOMEM; if (bar->iomem) { ret = nouveau_object_ctor(parent, engine, &nouveau_barobj_oclass, mem, 0, pobject); } return ret; }
static int nv41_vmmgr_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_oclass *oclass, void *data, u32 size, struct nouveau_object **pobject) { struct nouveau_device *device = nv_device(parent); struct nv04_vmmgr_priv *priv; int ret; if (pci_find_capability(device->pdev, PCI_CAP_ID_AGP) || !nouveau_boolopt(device->cfgopt, "NvPCIE", true)) { return nouveau_object_ctor(parent, engine, &nv04_vmmgr_oclass, data, size, pobject); } ret = nouveau_vmmgr_create(parent, engine, oclass, "PCIEGART", "pciegart", &priv); *pobject = nv_object(priv); if (ret) return ret; priv->base.create = nv04_vm_create; priv->base.limit = NV41_GART_SIZE; priv->base.dma_bits = 39; priv->base.pgt_bits = 32 - 12; priv->base.spg_shift = 12; priv->base.lpg_shift = 12; priv->base.map_sg = nv41_vm_map_sg; priv->base.unmap = nv41_vm_unmap; priv->base.flush = nv41_vm_flush; ret = nouveau_vm_create(&priv->base, 0, NV41_GART_SIZE, 0, 4096, &priv->vm); if (ret) return ret; ret = nouveau_gpuobj_new(nv_object(priv), NULL, (NV41_GART_SIZE / NV41_GART_PAGE) * 4, 16, NVOBJ_FLAG_ZERO_ALLOC, &priv->vm->pgt[0].obj[0]); priv->vm->pgt[0].refcount[0] = 1; if (ret) return ret; return 0; }
int nouveau_fb_create_(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_oclass *oclass, int length, void **pobject) { struct nouveau_fb_impl *impl = (void *)oclass; static const char *name[] = { [NV_MEM_TYPE_UNKNOWN] = "unknown", [NV_MEM_TYPE_STOLEN ] = "stolen system memory", [NV_MEM_TYPE_SGRAM ] = "SGRAM", [NV_MEM_TYPE_SDRAM ] = "SDRAM", [NV_MEM_TYPE_DDR1 ] = "DDR1", [NV_MEM_TYPE_DDR2 ] = "DDR2", [NV_MEM_TYPE_DDR3 ] = "DDR3", [NV_MEM_TYPE_GDDR2 ] = "GDDR2", [NV_MEM_TYPE_GDDR3 ] = "GDDR3", [NV_MEM_TYPE_GDDR4 ] = "GDDR4", [NV_MEM_TYPE_GDDR5 ] = "GDDR5", }; struct nouveau_object *ram; struct nouveau_fb *pfb; int ret; ret = nouveau_subdev_create_(parent, engine, oclass, 0, "PFB", "fb", length, pobject); pfb = *pobject; if (ret) return ret; pfb->memtype_valid = impl->memtype; ret = nouveau_object_ctor(nv_object(pfb), nv_object(pfb), impl->ram, NULL, 0, &ram); if (ret) { nv_fatal(pfb, "error detecting memory configuration!!\n"); return ret; } atomic_dec(&ram->parent->refcount); atomic_dec(&ram->engine->refcount); pfb->ram = (void *)ram; if (!nouveau_mm_initialised(&pfb->vram)) { ret = nouveau_mm_init(&pfb->vram, 0, pfb->ram->size >> 12, 1); if (ret) return ret; }
int nouveau_gpuobj_new(struct nouveau_object *parent, struct nouveau_object *pargpu, u32 size, u32 align, u32 flags, struct nouveau_gpuobj **pgpuobj) { struct nouveau_object *engine = parent; struct nouveau_gpuobj_class args = { .pargpu = pargpu, .size = size, .align = align, .flags = flags, }; if (!nv_iclass(engine, NV_SUBDEV_CLASS)) engine = engine->engine; BUG_ON(engine == NULL); return nouveau_object_ctor(parent, engine, &_nouveau_gpuobj_oclass, &args, sizeof(args), (struct nouveau_object **)pgpuobj); }
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; }