These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / gpu / drm / nouveau / nvif / client.c
index 80b9684..1ee9294 100644 (file)
 int
 nvif_client_ioctl(struct nvif_client *client, void *data, u32 size)
 {
-       return client->driver->ioctl(client->base.priv, client->super, data, size, NULL);
+       return client->driver->ioctl(client->object.priv, client->super, data, size, NULL);
 }
 
 int
 nvif_client_suspend(struct nvif_client *client)
 {
-       return client->driver->suspend(client->base.priv);
+       return client->driver->suspend(client->object.priv);
 }
 
 int
 nvif_client_resume(struct nvif_client *client)
 {
-       return client->driver->resume(client->base.priv);
+       return client->driver->resume(client->object.priv);
 }
 
 void
 nvif_client_fini(struct nvif_client *client)
 {
        if (client->driver) {
-               client->driver->fini(client->base.priv);
+               client->driver->fini(client->object.priv);
                client->driver = NULL;
-               client->base.parent = NULL;
-               nvif_object_fini(&client->base);
+               client->object.client = NULL;
+               nvif_object_fini(&client->object);
        }
 }
 
@@ -68,63 +68,39 @@ nvif_drivers[] = {
 };
 
 int
-nvif_client_init(void (*dtor)(struct nvif_client *), const char *driver,
-                const char *name, u64 device, const char *cfg, const char *dbg,
-                struct nvif_client *client)
+nvif_client_init(const char *driver, const char *name, u64 device,
+                const char *cfg, const char *dbg, struct nvif_client *client)
 {
+       struct {
+               struct nvif_ioctl_v0 ioctl;
+               struct nvif_ioctl_nop_v0 nop;
+       } args = {};
        int ret, i;
 
-       ret = nvif_object_init(NULL, (void*)dtor, 0, 0, NULL, 0, &client->base);
+       ret = nvif_object_init(NULL, 0, 0, NULL, 0, &client->object);
        if (ret)
                return ret;
 
-       client->base.parent = &client->base;
-       client->base.handle = ~0;
-       client->object = &client->base;
+       client->object.client = client;
+       client->object.handle = ~0;
+       client->route = NVIF_IOCTL_V0_ROUTE_NVIF;
        client->super = true;
 
        for (i = 0, ret = -EINVAL; (client->driver = nvif_drivers[i]); i++) {
                if (!driver || !strcmp(client->driver->name, driver)) {
                        ret = client->driver->init(name, device, cfg, dbg,
-                                                 &client->base.priv);
+                                                 &client->object.priv);
                        if (!ret || driver)
                                break;
                }
        }
 
+       if (ret == 0) {
+               ret = nvif_client_ioctl(client, &args, sizeof(args));
+               client->version = args.nop.version;
+       }
+
        if (ret)
                nvif_client_fini(client);
        return ret;
 }
-
-static void
-nvif_client_del(struct nvif_client *client)
-{
-       nvif_client_fini(client);
-       kfree(client);
-}
-
-int
-nvif_client_new(const char *driver, const char *name, u64 device,
-               const char *cfg, const char *dbg,
-               struct nvif_client **pclient)
-{
-       struct nvif_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
-       if (client) {
-               int ret = nvif_client_init(nvif_client_del, driver, name,
-                                          device, cfg, dbg, client);
-               if (ret) {
-                       kfree(client);
-                       client = NULL;
-               }
-               *pclient = client;
-               return ret;
-       }
-       return -ENOMEM;
-}
-
-void
-nvif_client_ref(struct nvif_client *client, struct nvif_client **pclient)
-{
-       nvif_object_ref(&client->base, (struct nvif_object **)pclient);
-}