drm/nouveau: remove unnecessary usage of object handles
authorBen Skeggs <bskeggs@redhat.com>
Fri, 4 Sep 2015 04:40:32 +0000 (14:40 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 3 Nov 2015 05:02:18 +0000 (15:02 +1000)
No longer required in a lot of cases, as objects are identified over NVIF
via an alternate mechanism since the rework.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_abi16.c
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nouveau_chan.h
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_drm.h
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_sysfs.c
drivers/gpu/drm/nouveau/nv50_display.c
include/uapi/drm/nouveau_drm.h

index d336c2247d6afa0759a9b3cfa686508eaead319a..0b3c8abd684315be82281d3b9eb4d41f00345a83 100644 (file)
@@ -51,8 +51,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
                         * device (ie. the one that belongs to the fd it
                         * opened)
                         */
-                       if (nvif_device_init(&cli->base.object,
-                                            NOUVEAU_ABI16_DEVICE, NV_DEVICE,
+                       if (nvif_device_init(&cli->base.object, 0, NV_DEVICE,
                                             &args, sizeof(args),
                                             &abi16->device) == 0)
                                return cli->abi16;
@@ -133,7 +132,6 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 
        /* destroy channel object, all children will be killed too */
        if (chan->chan) {
-               abi16->handles &= ~(1ULL << (chan->chan->user.handle & 0xffff));
                nouveau_channel_idle(chan->chan);
                nouveau_channel_del(&chan->chan);
        }
@@ -268,26 +266,21 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
                return nouveau_abi16_put(abi16, -EINVAL);
 
        /* allocate "abi16 channel" data and make up a handle for it */
-       init->channel = __ffs64(~abi16->handles);
-       if (~abi16->handles == 0)
-               return nouveau_abi16_put(abi16, -ENOSPC);
-
        chan = kzalloc(sizeof(*chan), GFP_KERNEL);
        if (!chan)
                return nouveau_abi16_put(abi16, -ENOMEM);
 
        INIT_LIST_HEAD(&chan->notifiers);
        list_add(&chan->head, &abi16->channels);
-       abi16->handles |= (1ULL << init->channel);
 
        /* create channel object and initialise dma and fence management */
-       ret = nouveau_channel_new(drm, device,
-                                 NOUVEAU_ABI16_CHAN(init->channel),
-                                 init->fb_ctxdma_handle,
+       ret = nouveau_channel_new(drm, device, init->fb_ctxdma_handle,
                                  init->tt_ctxdma_handle, &chan->chan);
        if (ret)
                goto done;
 
+       init->channel = chan->chan->chid;
+
        if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
                init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
                                        NOUVEAU_GEM_DOMAIN_GART;
@@ -338,7 +331,7 @@ nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
        struct nouveau_abi16_chan *chan;
 
        list_for_each_entry(chan, &abi16->channels, head) {
-               if (chan->chan->user.handle == NOUVEAU_ABI16_CHAN(channel))
+               if (chan->chan->chid == channel)
                        return chan;
        }
 
index ff5e59db49db02d213bf21e676243da562144d07..1860f389f21f157fa7b1795e1a5b7a5ccab64098 100644 (file)
@@ -55,10 +55,8 @@ nouveau_channel_idle(struct nouveau_channel *chan)
                }
 
                if (ret) {
-                       NV_PRINTK(err, cli, "failed to idle channel "
-                                           "0x%08x [%s]\n",
-                                 chan->user.handle,
-                                 nvxx_client(&cli->base)->name);
+                       NV_PRINTK(err, cli, "failed to idle channel %d [%s]\n",
+                                 chan->chid, nvxx_client(&cli->base)->name);
                        return ret;
                }
        }
@@ -89,7 +87,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 
 static int
 nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
-                    u32 handle, u32 size, struct nouveau_channel **pchan)
+                    u32 size, struct nouveau_channel **pchan)
 {
        struct nouveau_cli *cli = (void *)device->object.client;
        struct nvkm_mmu *mmu = nvxx_mmu(device);
@@ -174,8 +172,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
                }
        }
 
-       ret = nvif_object_init(&device->object, NVDRM_PUSH |
-                              (handle & 0xffff), NV_DMA_FROM_MEMORY,
+       ret = nvif_object_init(&device->object, 0, NV_DMA_FROM_MEMORY,
                               &args, sizeof(args), &chan->push.ctxdma);
        if (ret) {
                nouveau_channel_del(pchan);
@@ -187,7 +184,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
 
 static int
 nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
-                   u32 handle, u32 engine, struct nouveau_channel **pchan)
+                   u32 engine, struct nouveau_channel **pchan)
 {
        static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
                                        KEPLER_CHANNEL_GPFIFO_A,
@@ -206,7 +203,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
        int ret;
 
        /* allocate dma push buffer */
-       ret = nouveau_channel_prep(drm, device, handle, 0x12000, &chan);
+       ret = nouveau_channel_prep(drm, device, 0x12000, &chan);
        *pchan = chan;
        if (ret)
                return ret;
@@ -236,7 +233,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
                        size = sizeof(args.nv50);
                }
 
-               ret = nvif_object_init(&device->object, handle, *oclass++,
+               ret = nvif_object_init(&device->object, 0, *oclass++,
                                       &args, size, &chan->user);
                if (ret == 0) {
                        if (chan->user.oclass >= KEPLER_CHANNEL_GPFIFO_A)
@@ -256,7 +253,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
 
 static int
 nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
-                   u32 handle, struct nouveau_channel **pchan)
+                   struct nouveau_channel **pchan)
 {
        static const u16 oclasses[] = { NV40_CHANNEL_DMA,
                                        NV17_CHANNEL_DMA,
@@ -269,7 +266,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
        int ret;
 
        /* allocate dma push buffer */
-       ret = nouveau_channel_prep(drm, device, handle, 0x10000, &chan);
+       ret = nouveau_channel_prep(drm, device, 0x10000, &chan);
        *pchan = chan;
        if (ret)
                return ret;
@@ -280,7 +277,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
        args.offset = chan->push.vma.offset;
 
        do {
-               ret = nvif_object_init(&device->object, handle, *oclass++,
+               ret = nvif_object_init(&device->object, 0, *oclass++,
                                       &args, sizeof(args), &chan->user);
                if (ret == 0) {
                        chan->chid = args.chid;
@@ -401,8 +398,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 
 int
 nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
-                   u32 handle, u32 arg0, u32 arg1,
-                   struct nouveau_channel **pchan)
+                   u32 arg0, u32 arg1, struct nouveau_channel **pchan)
 {
        struct nouveau_cli *cli = (void *)device->object.client;
        bool super;
@@ -412,10 +408,10 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
        super = cli->base.super;
        cli->base.super = true;
 
-       ret = nouveau_channel_ind(drm, device, handle, arg0, pchan);
+       ret = nouveau_channel_ind(drm, device, arg0, pchan);
        if (ret) {
                NV_PRINTK(dbg, cli, "ib channel create, %d\n", ret);
-               ret = nouveau_channel_dma(drm, device, handle, pchan);
+               ret = nouveau_channel_dma(drm, device, pchan);
                if (ret) {
                        NV_PRINTK(dbg, cli, "dma channel create, %d\n", ret);
                        goto done;
index 2ed32414cb69740a62071bd58d609ccf5dfc4b32..48062c94f36d7291a6c9f16213e08ca770db2b64 100644 (file)
@@ -42,8 +42,7 @@ struct nouveau_channel {
 
 
 int  nouveau_channel_new(struct nouveau_drm *, struct nvif_device *,
-                        u32 handle, u32 arg0, u32 arg1,
-                        struct nouveau_channel **);
+                        u32 arg0, u32 arg1, struct nouveau_channel **);
 void nouveau_channel_del(struct nouveau_channel **);
 int  nouveau_channel_idle(struct nouveau_channel *);
 
index 614b32e6381cb93c11e19068cded923185bad847..db6bc676054519b08f3dbe6e45a23782362c9376 100644 (file)
@@ -509,9 +509,8 @@ nouveau_display_create(struct drm_device *dev)
                int i;
 
                for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
-                       ret = nvif_object_init(&drm->device.object,
-                                              NVDRM_DISPLAY, oclass[i],
-                                              NULL, 0, &disp->disp);
+                       ret = nvif_object_init(&drm->device.object, 0,
+                                              oclass[i], NULL, 0, &disp->disp);
                }
 
                if (ret == 0) {
index 45ba67819199077ec30118fd04873115ceb8f451..f93266582f2787f46d34492836c82e1110fda271 100644 (file)
@@ -208,7 +208,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
        }
 
        if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
-               ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,
+               ret = nouveau_channel_new(drm, &drm->device,
                                          KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|
                                          KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,
                                          0, &drm->cechan);
@@ -221,7 +221,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
        if (device->info.chipset >= 0xa3 &&
            device->info.chipset != 0xaa &&
            device->info.chipset != 0xac) {
-               ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,
+               ret = nouveau_channel_new(drm, &drm->device,
                                          NvDmaFB, NvDmaTT, &drm->cechan);
                if (ret)
                        NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
@@ -233,8 +233,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
                arg1 = NvDmaTT;
        }
 
-       ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN, arg0, arg1,
-                                &drm->channel);
+       ret = nouveau_channel_new(drm, &drm->device, arg0, arg1, &drm->channel);
        if (ret) {
                NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
                nouveau_accel_fini(drm);
@@ -403,8 +402,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 
        nouveau_get_hdmi_dev(drm);
 
-       ret = nvif_device_init(&drm->client.base.object,
-                              NVDRM_DEVICE, NV_DEVICE,
+       ret = nvif_device_init(&drm->client.base.object, 0, NV_DEVICE,
                               &(struct nv_device_v0) {
                                        .device = ~0,
                               }, sizeof(struct nv_device_v0),
index 3c902c24a8dde3667378750bfbff0872948853ca..acfa03bd50de925441bf3c78d825143e84a70446 100644 (file)
@@ -74,11 +74,6 @@ enum nouveau_drm_notify_route {
 };
 
 enum nouveau_drm_handle {
-       NVDRM_CLIENT  = 0xffffffff,
-       NVDRM_DEVICE  = 0xdddddddd,
-       NVDRM_CONTROL = 0xdddddddc,
-       NVDRM_DISPLAY = 0xd1500000,
-       NVDRM_PUSH    = 0xbbbb0000, /* |= client chid */
        NVDRM_CHAN    = 0xcccc0000, /* |= client chid */
        NVDRM_NVSW    = 0x55550000,
 };
index 41be584147b936a921d0c6bdd4e5fe0b4251c70c..6bf1a7895708e8b4292900fad601599a1e5887da 100644 (file)
@@ -682,7 +682,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
                return -ENOMEM;
 
        list_for_each_entry(temp, &abi16->channels, head) {
-               if (temp->chan->user.handle == (NVDRM_CHAN | req->channel)) {
+               if (temp->chan->chid == req->channel) {
                        chan = temp->chan;
                        break;
                }
index d12a5faee047869049d41e1a7a21b3d974a75ad7..5dac3546c1b89679842300fd1b2aff9f5c5e3da6 100644 (file)
@@ -188,9 +188,8 @@ nouveau_sysfs_init(struct drm_device *dev)
        if (!sysfs)
                return -ENOMEM;
 
-       ret = nvif_object_init(&device->object, NVDRM_CONTROL,
-                              NVIF_IOCTL_NEW_V0_CONTROL, NULL, 0,
-                              &sysfs->ctrl);
+       ret = nvif_object_init(&device->object, 0, NVIF_IOCTL_NEW_V0_CONTROL,
+                              NULL, 0, &sysfs->ctrl);
        if (ret == 0)
                device_create_file(nvxx_device(device)->dev, &dev_attr_pstate);
 
index 4ae87aed45054899a8de0ad39fb31d817a3cf1a3..c053c50b346a2d46f3c2b6405a5598038de98a08 100644 (file)
@@ -68,7 +68,6 @@ nv50_chan_create(struct nvif_device *device, struct nvif_object *disp,
                 const s32 *oclass, u8 head, void *data, u32 size,
                 struct nv50_chan *chan)
 {
-       const u32 handle = (oclass[0] << 16) | head;
        struct nvif_sclass *sclass;
        int ret, i, n;
 
@@ -81,7 +80,7 @@ nv50_chan_create(struct nvif_device *device, struct nvif_object *disp,
        while (oclass[0]) {
                for (i = 0; i < n; i++) {
                        if (sclass[i].oclass == oclass[0]) {
-                               ret = nvif_object_init(disp, handle, oclass[0],
+                               ret = nvif_object_init(disp, 0, oclass[0],
                                                       data, size, &chan->user);
                                if (ret == 0)
                                        nvif_object_map(&chan->user);
@@ -231,8 +230,8 @@ nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
        if (!dmac->ptr)
                return -ENOMEM;
 
-       ret = nvif_object_init(&device->object, 0xd0000000,
-                              NV_DMA_FROM_MEMORY, &(struct nv_dma_v0) {
+       ret = nvif_object_init(&device->object, 0, NV_DMA_FROM_MEMORY,
+                              &(struct nv_dma_v0) {
                                        .target = NV_DMA_V0_TARGET_PCI_US,
                                        .access = NV_DMA_V0_ACCESS_RD,
                                        .start = dmac->handle + 0x0000,
index 5507eead58634f0aba8b2ad6766245346ff58117..fd594cc73cc05180f66273f1e90a94187574a737 100644 (file)
 
 #define DRM_NOUVEAU_EVENT_NVIF                                       0x80000000
 
-/* reserved object handles when using deprecated object APIs - these
- * are here so that libdrm can allow interoperability with the new
- * object APIs
- */
-#define NOUVEAU_ABI16_CLIENT   0xffffffff
-#define NOUVEAU_ABI16_DEVICE   0xdddddddd
-#define NOUVEAU_ABI16_CHAN(n) (0xcccc0000 | (n))
-
 #define NOUVEAU_GEM_DOMAIN_CPU       (1 << 0)
 #define NOUVEAU_GEM_DOMAIN_VRAM      (1 << 1)
 #define NOUVEAU_GEM_DOMAIN_GART      (1 << 2)