History

drm/nouveau: remove unnecessary usage of object handles

No longer required in a lot of cases, as objects are identified over NVIF via an alternate mechanism since the rework.

Ben Skeggs committed 11 years ago

Commit fcf3f911 parent a0a49ba10 files · +31 −61Browse files

Unified · Split

10 files
  1. drivers/gpu/drm/nouveau/nouveau_abi16.c +5 −12
  2. drivers/gpu/drm/nouveau/nouveau_chan.c +13 −17
  3. drivers/gpu/drm/nouveau/nouveau_chan.h +1 −2
  4. drivers/gpu/drm/nouveau/nouveau_display.c +2 −3
  5. drivers/gpu/drm/nouveau/nouveau_drm.c +4 −6
  6. drivers/gpu/drm/nouveau/nouveau_drm.h +0 −5
  7. drivers/gpu/drm/nouveau/nouveau_gem.c +1 −1
  8. drivers/gpu/drm/nouveau/nouveau_sysfs.c +2 −3
  9. drivers/gpu/drm/nouveau/nv50_display.c +3 −4
  10. include/uapi/drm/nouveau_drm.h +0 −8
drivers/gpu/drm/nouveau/nouveau_abi16.c+5−12
@@ -51,8 +51,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) · 50 unmodified lines
51 * device (ie. the one that belongs to the fd it51 * device (ie. the one that belongs to the fd it
52 * opened)52 * opened)
53 */53 */
54 if (nvif_device_init(&cli->base.object,54 if (nvif_device_init(&cli->base.object, 0, NV_DEVICE,
55 NOUVEAU_ABI16_DEVICE, NV_DEVICE,
56 &args, sizeof(args),55 &args, sizeof(args),
57 &abi16->device) == 0)56 &abi16->device) == 0)
58 return cli->abi16;57 return cli->abi16;
@@ -133,7 +132,6 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16, · 74 unmodified lines
133 132
134 /* destroy channel object, all children will be killed too */133 /* destroy channel object, all children will be killed too */
135 if (chan->chan) {134 if (chan->chan) {
136 abi16->handles &= ~(1ULL << (chan->chan->user.handle & 0xffff));
137 nouveau_channel_idle(chan->chan);135 nouveau_channel_idle(chan->chan);
138 nouveau_channel_del(&chan->chan);136 nouveau_channel_del(&chan->chan);
139 }137 }
@@ -268,26 +266,21 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) · 128 unmodified lines
268 return nouveau_abi16_put(abi16, -EINVAL);266 return nouveau_abi16_put(abi16, -EINVAL);
269 267
270 /* allocate "abi16 channel" data and make up a handle for it */268 /* allocate "abi16 channel" data and make up a handle for it */
271 init->channel = __ffs64(~abi16->handles);
272 if (~abi16->handles == 0)
273 return nouveau_abi16_put(abi16, -ENOSPC);
274
275 chan = kzalloc(sizeof(*chan), GFP_KERNEL);269 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
276 if (!chan)270 if (!chan)
277 return nouveau_abi16_put(abi16, -ENOMEM);271 return nouveau_abi16_put(abi16, -ENOMEM);
278 272
279 INIT_LIST_HEAD(&chan->notifiers);273 INIT_LIST_HEAD(&chan->notifiers);
280 list_add(&chan->head, &abi16->channels);274 list_add(&chan->head, &abi16->channels);
281 abi16->handles |= (1ULL << init->channel);
282 275
283 /* create channel object and initialise dma and fence management */276 /* create channel object and initialise dma and fence management */
284 ret = nouveau_channel_new(drm, device,277 ret = nouveau_channel_new(drm, device, init->fb_ctxdma_handle,
285 NOUVEAU_ABI16_CHAN(init->channel),
286 init->fb_ctxdma_handle,
287 init->tt_ctxdma_handle, &chan->chan);278 init->tt_ctxdma_handle, &chan->chan);
288 if (ret)279 if (ret)
289 goto done;280 goto done;
290 281
282 init->channel = chan->chan->chid;
283
291 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)284 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
292 init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |285 init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
293 NOUVEAU_GEM_DOMAIN_GART;286 NOUVEAU_GEM_DOMAIN_GART;
@@ -338,7 +331,7 @@ nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel) · 44 unmodified lines
338 struct nouveau_abi16_chan *chan;331 struct nouveau_abi16_chan *chan;
339 332
340 list_for_each_entry(chan, &abi16->channels, head) {333 list_for_each_entry(chan, &abi16->channels, head) {
341 if (chan->chan->user.handle == NOUVEAU_ABI16_CHAN(channel))334 if (chan->chan->chid == channel)
342 return chan;335 return chan;
343 }336 }
344 337
drivers/gpu/drm/nouveau/nouveau_chan.c+13−17
@@ -55,10 +55,8 @@ nouveau_channel_idle(struct nouveau_channel *chan) · 54 unmodified lines
55 }55 }
56 56
57 if (ret) {57 if (ret) {
58 NV_PRINTK(err, cli, "failed to idle channel "58 NV_PRINTK(err, cli, "failed to idle channel %d [%s]\n",
59 "0x%08x [%s]\n",59 chan->chid, nvxx_client(&cli->base)->name);
60 chan->user.handle,
61 nvxx_client(&cli->base)->name);
62 return ret;60 return ret;
63 }61 }
64 }62 }
@@ -89,7 +87,7 @@ nouveau_channel_del(struct nouveau_channel **pchan) · 24 unmodified lines
89 87
90static int88static int
91nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,89nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
92 u32 handle, u32 size, struct nouveau_channel **pchan)90 u32 size, struct nouveau_channel **pchan)
93{91{
94 struct nouveau_cli *cli = (void *)device->object.client;92 struct nouveau_cli *cli = (void *)device->object.client;
95 struct nvkm_mmu *mmu = nvxx_mmu(device);93 struct nvkm_mmu *mmu = nvxx_mmu(device);
@@ -174,8 +172,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, · 78 unmodified lines
174 }172 }
175 }173 }
176 174
177 ret = nvif_object_init(&device->object, NVDRM_PUSH |175 ret = nvif_object_init(&device->object, 0, NV_DMA_FROM_MEMORY,
178 (handle & 0xffff), NV_DMA_FROM_MEMORY,
179 &args, sizeof(args), &chan->push.ctxdma);176 &args, sizeof(args), &chan->push.ctxdma);
180 if (ret) {177 if (ret) {
181 nouveau_channel_del(pchan);178 nouveau_channel_del(pchan);
@@ -187,7 +184,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, · 5 unmodified lines
187 184
188static int185static int
189nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,186nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
190 u32 handle, u32 engine, struct nouveau_channel **pchan)187 u32 engine, struct nouveau_channel **pchan)
191{188{
192 static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,189 static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
193 KEPLER_CHANNEL_GPFIFO_A,190 KEPLER_CHANNEL_GPFIFO_A,
@@ -206,7 +203,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device, · 12 unmodified lines
206 int ret;203 int ret;
207 204
208 /* allocate dma push buffer */205 /* allocate dma push buffer */
209 ret = nouveau_channel_prep(drm, device, handle, 0x12000, &chan);206 ret = nouveau_channel_prep(drm, device, 0x12000, &chan);
210 *pchan = chan;207 *pchan = chan;
211 if (ret)208 if (ret)
212 return ret;209 return ret;
@@ -236,7 +233,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device, · 23 unmodified lines
236 size = sizeof(args.nv50);233 size = sizeof(args.nv50);
237 }234 }
238 235
239 ret = nvif_object_init(&device->object, handle, *oclass++,236 ret = nvif_object_init(&device->object, 0, *oclass++,
240 &args, size, &chan->user);237 &args, size, &chan->user);
241 if (ret == 0) {238 if (ret == 0) {
242 if (chan->user.oclass >= KEPLER_CHANNEL_GPFIFO_A)239 if (chan->user.oclass >= KEPLER_CHANNEL_GPFIFO_A)
@@ -256,7 +253,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device, · 13 unmodified lines
256 253
257static int254static int
258nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,255nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
259 u32 handle, struct nouveau_channel **pchan)256 struct nouveau_channel **pchan)
260{257{
261 static const u16 oclasses[] = { NV40_CHANNEL_DMA,258 static const u16 oclasses[] = { NV40_CHANNEL_DMA,
262 NV17_CHANNEL_DMA,259 NV17_CHANNEL_DMA,
@@ -269,7 +266,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device, · 6 unmodified lines
269 int ret;266 int ret;
270 267
271 /* allocate dma push buffer */268 /* allocate dma push buffer */
272 ret = nouveau_channel_prep(drm, device, handle, 0x10000, &chan);269 ret = nouveau_channel_prep(drm, device, 0x10000, &chan);
273 *pchan = chan;270 *pchan = chan;
274 if (ret)271 if (ret)
275 return ret;272 return ret;
@@ -280,7 +277,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device, · 4 unmodified lines
280 args.offset = chan->push.vma.offset;277 args.offset = chan->push.vma.offset;
281 278
282 do {279 do {
283 ret = nvif_object_init(&device->object, handle, *oclass++,280 ret = nvif_object_init(&device->object, 0, *oclass++,
284 &args, sizeof(args), &chan->user);281 &args, sizeof(args), &chan->user);
285 if (ret == 0) {282 if (ret == 0) {
286 chan->chid = args.chid;283 chan->chid = args.chid;
@@ -401,8 +398,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart) · 114 unmodified lines
401 398
402int399int
403nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,400nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
404 u32 handle, u32 arg0, u32 arg1,401 u32 arg0, u32 arg1, struct nouveau_channel **pchan)
405 struct nouveau_channel **pchan)
406{402{
407 struct nouveau_cli *cli = (void *)device->object.client;403 struct nouveau_cli *cli = (void *)device->object.client;
408 bool super;404 bool super;
@@ -412,10 +408,10 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device, · 3 unmodified lines
412 super = cli->base.super;408 super = cli->base.super;
413 cli->base.super = true;409 cli->base.super = true;
414 410
415 ret = nouveau_channel_ind(drm, device, handle, arg0, pchan);411 ret = nouveau_channel_ind(drm, device, arg0, pchan);
416 if (ret) {412 if (ret) {
417 NV_PRINTK(dbg, cli, "ib channel create, %d\n", ret);413 NV_PRINTK(dbg, cli, "ib channel create, %d\n", ret);
418 ret = nouveau_channel_dma(drm, device, handle, pchan);414 ret = nouveau_channel_dma(drm, device, pchan);
419 if (ret) {415 if (ret) {
420 NV_PRINTK(dbg, cli, "dma channel create, %d\n", ret);416 NV_PRINTK(dbg, cli, "dma channel create, %d\n", ret);
421 goto done;417 goto done;
drivers/gpu/drm/nouveau/nouveau_chan.h+1−2
@@ -42,8 +42,7 @@ struct nouveau_channel { · 41 unmodified lines
42 42
43 43
44int nouveau_channel_new(struct nouveau_drm *, struct nvif_device *,44int nouveau_channel_new(struct nouveau_drm *, struct nvif_device *,
45 u32 handle, u32 arg0, u32 arg1,45 u32 arg0, u32 arg1, struct nouveau_channel **);
46 struct nouveau_channel **);
47void nouveau_channel_del(struct nouveau_channel **);46void nouveau_channel_del(struct nouveau_channel **);
48int nouveau_channel_idle(struct nouveau_channel *);47int nouveau_channel_idle(struct nouveau_channel *);
49 48
drivers/gpu/drm/nouveau/nouveau_display.c+2−3
@@ -509,9 +509,8 @@ nouveau_display_create(struct drm_device *dev) · 508 unmodified lines
509 int i;509 int i;
510 510
511 for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {511 for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
512 ret = nvif_object_init(&drm->device.object,512 ret = nvif_object_init(&drm->device.object, 0,
513 NVDRM_DISPLAY, oclass[i],513 oclass[i], NULL, 0, &disp->disp);
514 NULL, 0, &disp->disp);
515 }514 }
516 515
517 if (ret == 0) {516 if (ret == 0) {
drivers/gpu/drm/nouveau/nouveau_drm.c+4−6
@@ -208,7 +208,7 @@ nouveau_accel_init(struct nouveau_drm *drm) · 207 unmodified lines
208 }208 }
209 209
210 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {210 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
211 ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,211 ret = nouveau_channel_new(drm, &drm->device,
212 KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|212 KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|
213 KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,213 KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,
214 0, &drm->cechan);214 0, &drm->cechan);
@@ -221,7 +221,7 @@ nouveau_accel_init(struct nouveau_drm *drm) · 6 unmodified lines
221 if (device->info.chipset >= 0xa3 &&221 if (device->info.chipset >= 0xa3 &&
222 device->info.chipset != 0xaa &&222 device->info.chipset != 0xaa &&
223 device->info.chipset != 0xac) {223 device->info.chipset != 0xac) {
224 ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,224 ret = nouveau_channel_new(drm, &drm->device,
225 NvDmaFB, NvDmaTT, &drm->cechan);225 NvDmaFB, NvDmaTT, &drm->cechan);
226 if (ret)226 if (ret)
227 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);227 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
@@ -233,8 +233,7 @@ nouveau_accel_init(struct nouveau_drm *drm) · 5 unmodified lines
233 arg1 = NvDmaTT;233 arg1 = NvDmaTT;
234 }234 }
235 235
236 ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN, arg0, arg1,236 ret = nouveau_channel_new(drm, &drm->device, arg0, arg1, &drm->channel);
237 &drm->channel);
238 if (ret) {237 if (ret) {
239 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);238 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
240 nouveau_accel_fini(drm);239 nouveau_accel_fini(drm);
@@ -403,8 +402,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) · 162 unmodified lines
403 402
404 nouveau_get_hdmi_dev(drm);403 nouveau_get_hdmi_dev(drm);
405 404
406 ret = nvif_device_init(&drm->client.base.object,405 ret = nvif_device_init(&drm->client.base.object, 0, NV_DEVICE,
407 NVDRM_DEVICE, NV_DEVICE,
408 &(struct nv_device_v0) {406 &(struct nv_device_v0) {
409 .device = ~0,407 .device = ~0,
410 }, sizeof(struct nv_device_v0),408 }, sizeof(struct nv_device_v0),
drivers/gpu/drm/nouveau/nouveau_drm.h+0−5
@@ -74,11 +74,6 @@ enum nouveau_drm_notify_route { · 73 unmodified lines
74};74};
75 75
76enum nouveau_drm_handle {76enum nouveau_drm_handle {
77 NVDRM_CLIENT = 0xffffffff,
78 NVDRM_DEVICE = 0xdddddddd,
79 NVDRM_CONTROL = 0xdddddddc,
80 NVDRM_DISPLAY = 0xd1500000,
81 NVDRM_PUSH = 0xbbbb0000, /* |= client chid */
82 NVDRM_CHAN = 0xcccc0000, /* |= client chid */77 NVDRM_CHAN = 0xcccc0000, /* |= client chid */
83 NVDRM_NVSW = 0x55550000,78 NVDRM_NVSW = 0x55550000,
84};79};
drivers/gpu/drm/nouveau/nouveau_gem.c+1−1
@@ -682,7 +682,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, · 681 unmodified lines
682 return -ENOMEM;682 return -ENOMEM;
683 683
684 list_for_each_entry(temp, &abi16->channels, head) {684 list_for_each_entry(temp, &abi16->channels, head) {
685 if (temp->chan->user.handle == (NVDRM_CHAN | req->channel)) {685 if (temp->chan->chid == req->channel) {
686 chan = temp->chan;686 chan = temp->chan;
687 break;687 break;
688 }688 }
drivers/gpu/drm/nouveau/nouveau_sysfs.c+2−3
@@ -188,9 +188,8 @@ nouveau_sysfs_init(struct drm_device *dev) · 187 unmodified lines
188 if (!sysfs)188 if (!sysfs)
189 return -ENOMEM;189 return -ENOMEM;
190 190
191 ret = nvif_object_init(&device->object, NVDRM_CONTROL,191 ret = nvif_object_init(&device->object, 0, NVIF_IOCTL_NEW_V0_CONTROL,
192 NVIF_IOCTL_NEW_V0_CONTROL, NULL, 0,192 NULL, 0, &sysfs->ctrl);
193 &sysfs->ctrl);
194 if (ret == 0)193 if (ret == 0)
195 device_create_file(nvxx_device(device)->dev, &dev_attr_pstate);194 device_create_file(nvxx_device(device)->dev, &dev_attr_pstate);
196 195
drivers/gpu/drm/nouveau/nv50_display.c+3−4
@@ -68,7 +68,6 @@ nv50_chan_create(struct nvif_device *device, struct nvif_object *disp, · 67 unmodified lines
68 const s32 *oclass, u8 head, void *data, u32 size,68 const s32 *oclass, u8 head, void *data, u32 size,
69 struct nv50_chan *chan)69 struct nv50_chan *chan)
70{70{
71 const u32 handle = (oclass[0] << 16) | head;
72 struct nvif_sclass *sclass;71 struct nvif_sclass *sclass;
73 int ret, i, n;72 int ret, i, n;
74 73
@@ -81,7 +80,7 @@ nv50_chan_create(struct nvif_device *device, struct nvif_object *disp, · 6 unmodified lines
81 while (oclass[0]) {80 while (oclass[0]) {
82 for (i = 0; i < n; i++) {81 for (i = 0; i < n; i++) {
83 if (sclass[i].oclass == oclass[0]) {82 if (sclass[i].oclass == oclass[0]) {
84 ret = nvif_object_init(disp, handle, oclass[0],83 ret = nvif_object_init(disp, 0, oclass[0],
85 data, size, &chan->user);84 data, size, &chan->user);
86 if (ret == 0)85 if (ret == 0)
87 nvif_object_map(&chan->user);86 nvif_object_map(&chan->user);
@@ -231,8 +230,8 @@ nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp, · 143 unmodified lines
231 if (!dmac->ptr)230 if (!dmac->ptr)
232 return -ENOMEM;231 return -ENOMEM;
233 232
234 ret = nvif_object_init(&device->object, 0xd0000000,233 ret = nvif_object_init(&device->object, 0, NV_DMA_FROM_MEMORY,
235 NV_DMA_FROM_MEMORY, &(struct nv_dma_v0) {234 &(struct nv_dma_v0) {
236 .target = NV_DMA_V0_TARGET_PCI_US,235 .target = NV_DMA_V0_TARGET_PCI_US,
237 .access = NV_DMA_V0_ACCESS_RD,236 .access = NV_DMA_V0_ACCESS_RD,
238 .start = dmac->handle + 0x0000,237 .start = dmac->handle + 0x0000,
include/uapi/drm/nouveau_drm.h+0−8
@@ -27,14 +27,6 @@ · 26 unmodified lines
27 27
28#define DRM_NOUVEAU_EVENT_NVIF 0x8000000028#define DRM_NOUVEAU_EVENT_NVIF 0x80000000
29 29
30/* reserved object handles when using deprecated object APIs - these
31 * are here so that libdrm can allow interoperability with the new
32 * object APIs
33 */
34#define NOUVEAU_ABI16_CLIENT 0xffffffff
35#define NOUVEAU_ABI16_DEVICE 0xdddddddd
36#define NOUVEAU_ABI16_CHAN(n) (0xcccc0000 | (n))
37
38#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)30#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
39#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)31#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
40#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)32#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)