diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_abi16.c')
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_abi16.c | 246 |
1 files changed, 138 insertions, 108 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c index b13f441c6431..615714c1727d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c | |||
| @@ -21,16 +21,10 @@ | |||
| 21 | * | 21 | * |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include <core/object.h> | 24 | #include <nvif/client.h> |
| 25 | #include <core/client.h> | 25 | #include <nvif/driver.h> |
| 26 | #include <core/device.h> | 26 | #include <nvif/ioctl.h> |
| 27 | #include <core/class.h> | 27 | #include <nvif/class.h> |
| 28 | #include <core/mm.h> | ||
| 29 | |||
| 30 | #include <subdev/fb.h> | ||
| 31 | #include <subdev/timer.h> | ||
| 32 | #include <subdev/instmem.h> | ||
| 33 | #include <engine/graph.h> | ||
| 34 | 28 | ||
| 35 | #include "nouveau_drm.h" | 29 | #include "nouveau_drm.h" |
| 36 | #include "nouveau_dma.h" | 30 | #include "nouveau_dma.h" |
| @@ -47,20 +41,20 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) | |||
| 47 | struct nouveau_abi16 *abi16; | 41 | struct nouveau_abi16 *abi16; |
| 48 | cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL); | 42 | cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL); |
| 49 | if (cli->abi16) { | 43 | if (cli->abi16) { |
| 44 | struct nv_device_v0 args = { | ||
| 45 | .device = ~0ULL, | ||
| 46 | }; | ||
| 47 | |||
| 50 | INIT_LIST_HEAD(&abi16->channels); | 48 | INIT_LIST_HEAD(&abi16->channels); |
| 51 | abi16->client = nv_object(cli); | ||
| 52 | 49 | ||
| 53 | /* allocate device object targeting client's default | 50 | /* allocate device object targeting client's default |
| 54 | * device (ie. the one that belongs to the fd it | 51 | * device (ie. the one that belongs to the fd it |
| 55 | * opened) | 52 | * opened) |
| 56 | */ | 53 | */ |
| 57 | if (nouveau_object_new(abi16->client, NVDRM_CLIENT, | 54 | if (nvif_device_init(&cli->base.base, NULL, |
| 58 | NVDRM_DEVICE, 0x0080, | 55 | NOUVEAU_ABI16_DEVICE, NV_DEVICE, |
| 59 | &(struct nv_device_class) { | 56 | &args, sizeof(args), |
| 60 | .device = ~0ULL, | 57 | &abi16->device) == 0) |
| 61 | }, | ||
| 62 | sizeof(struct nv_device_class), | ||
| 63 | &abi16->device) == 0) | ||
| 64 | return cli->abi16; | 58 | return cli->abi16; |
| 65 | 59 | ||
| 66 | kfree(cli->abi16); | 60 | kfree(cli->abi16); |
| @@ -75,7 +69,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) | |||
| 75 | int | 69 | int |
| 76 | nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) | 70 | nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) |
| 77 | { | 71 | { |
| 78 | struct nouveau_cli *cli = (void *)abi16->client; | 72 | struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base); |
| 79 | mutex_unlock(&cli->mutex); | 73 | mutex_unlock(&cli->mutex); |
| 80 | return ret; | 74 | return ret; |
| 81 | } | 75 | } |
| @@ -83,21 +77,19 @@ nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) | |||
| 83 | u16 | 77 | u16 |
| 84 | nouveau_abi16_swclass(struct nouveau_drm *drm) | 78 | nouveau_abi16_swclass(struct nouveau_drm *drm) |
| 85 | { | 79 | { |
| 86 | switch (nv_device(drm->device)->card_type) { | 80 | switch (drm->device.info.family) { |
| 87 | case NV_04: | 81 | case NV_DEVICE_INFO_V0_TNT: |
| 88 | return 0x006e; | 82 | return 0x006e; |
| 89 | case NV_10: | 83 | case NV_DEVICE_INFO_V0_CELSIUS: |
| 90 | case NV_11: | 84 | case NV_DEVICE_INFO_V0_KELVIN: |
| 91 | case NV_20: | 85 | case NV_DEVICE_INFO_V0_RANKINE: |
| 92 | case NV_30: | 86 | case NV_DEVICE_INFO_V0_CURIE: |
| 93 | case NV_40: | ||
| 94 | return 0x016e; | 87 | return 0x016e; |
| 95 | case NV_50: | 88 | case NV_DEVICE_INFO_V0_TESLA: |
| 96 | return 0x506e; | 89 | return 0x506e; |
| 97 | case NV_C0: | 90 | case NV_DEVICE_INFO_V0_FERMI: |
| 98 | case NV_D0: | 91 | case NV_DEVICE_INFO_V0_KEPLER: |
| 99 | case NV_E0: | 92 | case NV_DEVICE_INFO_V0_MAXWELL: |
| 100 | case GM100: | ||
| 101 | return 0x906e; | 93 | return 0x906e; |
| 102 | } | 94 | } |
| 103 | 95 | ||
| @@ -140,7 +132,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16, | |||
| 140 | 132 | ||
| 141 | /* destroy channel object, all children will be killed too */ | 133 | /* destroy channel object, all children will be killed too */ |
| 142 | if (chan->chan) { | 134 | if (chan->chan) { |
| 143 | abi16->handles &= ~(1ULL << (chan->chan->handle & 0xffff)); | 135 | abi16->handles &= ~(1ULL << (chan->chan->object->handle & 0xffff)); |
| 144 | nouveau_channel_del(&chan->chan); | 136 | nouveau_channel_del(&chan->chan); |
| 145 | } | 137 | } |
| 146 | 138 | ||
| @@ -151,7 +143,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16, | |||
| 151 | void | 143 | void |
| 152 | nouveau_abi16_fini(struct nouveau_abi16 *abi16) | 144 | nouveau_abi16_fini(struct nouveau_abi16 *abi16) |
| 153 | { | 145 | { |
| 154 | struct nouveau_cli *cli = (void *)abi16->client; | 146 | struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base); |
| 155 | struct nouveau_abi16_chan *chan, *temp; | 147 | struct nouveau_abi16_chan *chan, *temp; |
| 156 | 148 | ||
| 157 | /* cleanup channels */ | 149 | /* cleanup channels */ |
| @@ -160,7 +152,7 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16) | |||
| 160 | } | 152 | } |
| 161 | 153 | ||
| 162 | /* destroy the device object */ | 154 | /* destroy the device object */ |
| 163 | nouveau_object_del(abi16->client, NVDRM_CLIENT, NVDRM_DEVICE); | 155 | nvif_device_fini(&abi16->device); |
| 164 | 156 | ||
| 165 | kfree(cli->abi16); | 157 | kfree(cli->abi16); |
| 166 | cli->abi16 = NULL; | 158 | cli->abi16 = NULL; |
| @@ -169,30 +161,31 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16) | |||
| 169 | int | 161 | int |
| 170 | nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) | 162 | nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) |
| 171 | { | 163 | { |
| 164 | struct nouveau_cli *cli = nouveau_cli(file_priv); | ||
| 172 | struct nouveau_drm *drm = nouveau_drm(dev); | 165 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 173 | struct nouveau_device *device = nv_device(drm->device); | 166 | struct nvif_device *device = &drm->device; |
| 174 | struct nouveau_timer *ptimer = nouveau_timer(device); | 167 | struct nouveau_timer *ptimer = nvkm_timer(device); |
| 175 | struct nouveau_graph *graph = (void *)nouveau_engine(device, NVDEV_ENGINE_GR); | 168 | struct nouveau_graph *graph = nvkm_gr(device); |
| 176 | struct drm_nouveau_getparam *getparam = data; | 169 | struct drm_nouveau_getparam *getparam = data; |
| 177 | 170 | ||
| 178 | switch (getparam->param) { | 171 | switch (getparam->param) { |
| 179 | case NOUVEAU_GETPARAM_CHIPSET_ID: | 172 | case NOUVEAU_GETPARAM_CHIPSET_ID: |
| 180 | getparam->value = device->chipset; | 173 | getparam->value = device->info.chipset; |
| 181 | break; | 174 | break; |
| 182 | case NOUVEAU_GETPARAM_PCI_VENDOR: | 175 | case NOUVEAU_GETPARAM_PCI_VENDOR: |
| 183 | if (nv_device_is_pci(device)) | 176 | if (nv_device_is_pci(nvkm_device(device))) |
| 184 | getparam->value = dev->pdev->vendor; | 177 | getparam->value = dev->pdev->vendor; |
| 185 | else | 178 | else |
| 186 | getparam->value = 0; | 179 | getparam->value = 0; |
| 187 | break; | 180 | break; |
| 188 | case NOUVEAU_GETPARAM_PCI_DEVICE: | 181 | case NOUVEAU_GETPARAM_PCI_DEVICE: |
| 189 | if (nv_device_is_pci(device)) | 182 | if (nv_device_is_pci(nvkm_device(device))) |
| 190 | getparam->value = dev->pdev->device; | 183 | getparam->value = dev->pdev->device; |
| 191 | else | 184 | else |
| 192 | getparam->value = 0; | 185 | getparam->value = 0; |
| 193 | break; | 186 | break; |
| 194 | case NOUVEAU_GETPARAM_BUS_TYPE: | 187 | case NOUVEAU_GETPARAM_BUS_TYPE: |
| 195 | if (!nv_device_is_pci(device)) | 188 | if (!nv_device_is_pci(nvkm_device(device))) |
| 196 | getparam->value = 3; | 189 | getparam->value = 3; |
| 197 | else | 190 | else |
| 198 | if (drm_pci_device_is_agp(dev)) | 191 | if (drm_pci_device_is_agp(dev)) |
| @@ -225,7 +218,7 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) | |||
| 225 | getparam->value = graph->units ? graph->units(graph) : 0; | 218 | getparam->value = graph->units ? graph->units(graph) : 0; |
| 226 | break; | 219 | break; |
| 227 | default: | 220 | default: |
| 228 | nv_debug(device, "unknown parameter %lld\n", getparam->param); | 221 | NV_PRINTK(debug, cli, "unknown parameter %lld\n", getparam->param); |
| 229 | return -EINVAL; | 222 | return -EINVAL; |
| 230 | } | 223 | } |
| 231 | 224 | ||
| @@ -246,10 +239,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 246 | struct nouveau_drm *drm = nouveau_drm(dev); | 239 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 247 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); | 240 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); |
| 248 | struct nouveau_abi16_chan *chan; | 241 | struct nouveau_abi16_chan *chan; |
| 249 | struct nouveau_client *client; | 242 | struct nvif_device *device; |
| 250 | struct nouveau_device *device; | ||
| 251 | struct nouveau_instmem *imem; | ||
| 252 | struct nouveau_fb *pfb; | ||
| 253 | int ret; | 243 | int ret; |
| 254 | 244 | ||
| 255 | if (unlikely(!abi16)) | 245 | if (unlikely(!abi16)) |
| @@ -258,21 +248,18 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 258 | if (!drm->channel) | 248 | if (!drm->channel) |
| 259 | return nouveau_abi16_put(abi16, -ENODEV); | 249 | return nouveau_abi16_put(abi16, -ENODEV); |
| 260 | 250 | ||
| 261 | client = nv_client(abi16->client); | 251 | device = &abi16->device; |
| 262 | device = nv_device(abi16->device); | ||
| 263 | imem = nouveau_instmem(device); | ||
| 264 | pfb = nouveau_fb(device); | ||
| 265 | 252 | ||
| 266 | /* hack to allow channel engine type specification on kepler */ | 253 | /* hack to allow channel engine type specification on kepler */ |
| 267 | if (device->card_type >= NV_E0) { | 254 | if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) { |
| 268 | if (init->fb_ctxdma_handle != ~0) | 255 | if (init->fb_ctxdma_handle != ~0) |
| 269 | init->fb_ctxdma_handle = NVE0_CHANNEL_IND_ENGINE_GR; | 256 | init->fb_ctxdma_handle = KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR; |
| 270 | else | 257 | else |
| 271 | init->fb_ctxdma_handle = init->tt_ctxdma_handle; | 258 | init->fb_ctxdma_handle = init->tt_ctxdma_handle; |
| 272 | 259 | ||
| 273 | /* allow flips to be executed if this is a graphics channel */ | 260 | /* allow flips to be executed if this is a graphics channel */ |
| 274 | init->tt_ctxdma_handle = 0; | 261 | init->tt_ctxdma_handle = 0; |
| 275 | if (init->fb_ctxdma_handle == NVE0_CHANNEL_IND_ENGINE_GR) | 262 | if (init->fb_ctxdma_handle == KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR) |
| 276 | init->tt_ctxdma_handle = 1; | 263 | init->tt_ctxdma_handle = 1; |
| 277 | } | 264 | } |
| 278 | 265 | ||
| @@ -293,13 +280,14 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 293 | abi16->handles |= (1ULL << init->channel); | 280 | abi16->handles |= (1ULL << init->channel); |
| 294 | 281 | ||
| 295 | /* create channel object and initialise dma and fence management */ | 282 | /* create channel object and initialise dma and fence management */ |
| 296 | ret = nouveau_channel_new(drm, cli, NVDRM_DEVICE, NVDRM_CHAN | | 283 | ret = nouveau_channel_new(drm, device, |
| 297 | init->channel, init->fb_ctxdma_handle, | 284 | NOUVEAU_ABI16_CHAN(init->channel), |
| 285 | init->fb_ctxdma_handle, | ||
| 298 | init->tt_ctxdma_handle, &chan->chan); | 286 | init->tt_ctxdma_handle, &chan->chan); |
| 299 | if (ret) | 287 | if (ret) |
| 300 | goto done; | 288 | goto done; |
| 301 | 289 | ||
| 302 | if (device->card_type >= NV_50) | 290 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) |
| 303 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM | | 291 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM | |
| 304 | NOUVEAU_GEM_DOMAIN_GART; | 292 | NOUVEAU_GEM_DOMAIN_GART; |
| 305 | else | 293 | else |
| @@ -308,10 +296,10 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 308 | else | 296 | else |
| 309 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART; | 297 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART; |
| 310 | 298 | ||
| 311 | if (device->card_type < NV_10) { | 299 | if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) { |
| 312 | init->subchan[0].handle = 0x00000000; | 300 | init->subchan[0].handle = 0x00000000; |
| 313 | init->subchan[0].grclass = 0x0000; | 301 | init->subchan[0].grclass = 0x0000; |
| 314 | init->subchan[1].handle = NvSw; | 302 | init->subchan[1].handle = chan->chan->nvsw.handle; |
| 315 | init->subchan[1].grclass = 0x506e; | 303 | init->subchan[1].grclass = 0x506e; |
| 316 | init->nr_subchan = 2; | 304 | init->nr_subchan = 2; |
| 317 | } | 305 | } |
| @@ -324,8 +312,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 324 | if (ret) | 312 | if (ret) |
| 325 | goto done; | 313 | goto done; |
| 326 | 314 | ||
| 327 | if (device->card_type >= NV_50) { | 315 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { |
| 328 | ret = nouveau_bo_vma_add(chan->ntfy, client->vm, | 316 | ret = nouveau_bo_vma_add(chan->ntfy, cli->vm, |
| 329 | &chan->ntfy_vma); | 317 | &chan->ntfy_vma); |
| 330 | if (ret) | 318 | if (ret) |
| 331 | goto done; | 319 | goto done; |
| @@ -343,6 +331,18 @@ done: | |||
| 343 | return nouveau_abi16_put(abi16, ret); | 331 | return nouveau_abi16_put(abi16, ret); |
| 344 | } | 332 | } |
| 345 | 333 | ||
| 334 | static struct nouveau_abi16_chan * | ||
| 335 | nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel) | ||
| 336 | { | ||
| 337 | struct nouveau_abi16_chan *chan; | ||
| 338 | |||
| 339 | list_for_each_entry(chan, &abi16->channels, head) { | ||
| 340 | if (chan->chan->object->handle == NOUVEAU_ABI16_CHAN(channel)) | ||
| 341 | return chan; | ||
| 342 | } | ||
| 343 | |||
| 344 | return NULL; | ||
| 345 | } | ||
| 346 | 346 | ||
| 347 | int | 347 | int |
| 348 | nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS) | 348 | nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS) |
| @@ -350,28 +350,38 @@ nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS) | |||
| 350 | struct drm_nouveau_channel_free *req = data; | 350 | struct drm_nouveau_channel_free *req = data; |
| 351 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); | 351 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); |
| 352 | struct nouveau_abi16_chan *chan; | 352 | struct nouveau_abi16_chan *chan; |
| 353 | int ret = -ENOENT; | ||
| 354 | 353 | ||
| 355 | if (unlikely(!abi16)) | 354 | if (unlikely(!abi16)) |
| 356 | return -ENOMEM; | 355 | return -ENOMEM; |
| 357 | 356 | ||
| 358 | list_for_each_entry(chan, &abi16->channels, head) { | 357 | chan = nouveau_abi16_chan(abi16, req->channel); |
| 359 | if (chan->chan->handle == (NVDRM_CHAN | req->channel)) { | 358 | if (!chan) |
| 360 | nouveau_abi16_chan_fini(abi16, chan); | 359 | return nouveau_abi16_put(abi16, -ENOENT); |
| 361 | return nouveau_abi16_put(abi16, 0); | 360 | nouveau_abi16_chan_fini(abi16, chan); |
| 362 | } | 361 | return nouveau_abi16_put(abi16, 0); |
| 363 | } | ||
| 364 | |||
| 365 | return nouveau_abi16_put(abi16, ret); | ||
| 366 | } | 362 | } |
| 367 | 363 | ||
| 368 | int | 364 | int |
| 369 | nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) | 365 | nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) |
| 370 | { | 366 | { |
| 371 | struct drm_nouveau_grobj_alloc *init = data; | 367 | struct drm_nouveau_grobj_alloc *init = data; |
| 368 | struct { | ||
| 369 | struct nvif_ioctl_v0 ioctl; | ||
| 370 | struct nvif_ioctl_new_v0 new; | ||
| 371 | } args = { | ||
| 372 | .ioctl.owner = NVIF_IOCTL_V0_OWNER_ANY, | ||
| 373 | .ioctl.type = NVIF_IOCTL_V0_NEW, | ||
| 374 | .ioctl.path_nr = 3, | ||
| 375 | .ioctl.path[2] = NOUVEAU_ABI16_CLIENT, | ||
| 376 | .ioctl.path[1] = NOUVEAU_ABI16_DEVICE, | ||
| 377 | .ioctl.path[0] = NOUVEAU_ABI16_CHAN(init->channel), | ||
| 378 | .new.route = NVDRM_OBJECT_ABI16, | ||
| 379 | .new.handle = init->handle, | ||
| 380 | .new.oclass = init->class, | ||
| 381 | }; | ||
| 372 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); | 382 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); |
| 373 | struct nouveau_drm *drm = nouveau_drm(dev); | 383 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 374 | struct nouveau_object *object; | 384 | struct nvif_client *client; |
| 375 | int ret; | 385 | int ret; |
| 376 | 386 | ||
| 377 | if (unlikely(!abi16)) | 387 | if (unlikely(!abi16)) |
| @@ -379,6 +389,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) | |||
| 379 | 389 | ||
| 380 | if (init->handle == ~0) | 390 | if (init->handle == ~0) |
| 381 | return nouveau_abi16_put(abi16, -EINVAL); | 391 | return nouveau_abi16_put(abi16, -EINVAL); |
| 392 | client = nvif_client(nvif_object(&abi16->device)); | ||
| 382 | 393 | ||
| 383 | /* compatibility with userspace that assumes 506e for all chipsets */ | 394 | /* compatibility with userspace that assumes 506e for all chipsets */ |
| 384 | if (init->class == 0x506e) { | 395 | if (init->class == 0x506e) { |
| @@ -387,8 +398,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) | |||
| 387 | return nouveau_abi16_put(abi16, 0); | 398 | return nouveau_abi16_put(abi16, 0); |
| 388 | } | 399 | } |
| 389 | 400 | ||
| 390 | ret = nouveau_object_new(abi16->client, NVDRM_CHAN | init->channel, | 401 | ret = nvif_client_ioctl(client, &args, sizeof(args)); |
| 391 | init->handle, init->class, NULL, 0, &object); | ||
| 392 | return nouveau_abi16_put(abi16, ret); | 402 | return nouveau_abi16_put(abi16, ret); |
| 393 | } | 403 | } |
| 394 | 404 | ||
| @@ -396,29 +406,38 @@ int | |||
| 396 | nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS) | 406 | nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS) |
| 397 | { | 407 | { |
| 398 | struct drm_nouveau_notifierobj_alloc *info = data; | 408 | struct drm_nouveau_notifierobj_alloc *info = data; |
| 409 | struct { | ||
| 410 | struct nvif_ioctl_v0 ioctl; | ||
| 411 | struct nvif_ioctl_new_v0 new; | ||
| 412 | struct nv_dma_v0 ctxdma; | ||
| 413 | } args = { | ||
| 414 | .ioctl.owner = NVIF_IOCTL_V0_OWNER_ANY, | ||
| 415 | .ioctl.type = NVIF_IOCTL_V0_NEW, | ||
| 416 | .ioctl.path_nr = 3, | ||
| 417 | .ioctl.path[2] = NOUVEAU_ABI16_CLIENT, | ||
| 418 | .ioctl.path[1] = NOUVEAU_ABI16_DEVICE, | ||
| 419 | .ioctl.path[0] = NOUVEAU_ABI16_CHAN(info->channel), | ||
| 420 | .new.route = NVDRM_OBJECT_ABI16, | ||
| 421 | .new.handle = info->handle, | ||
| 422 | .new.oclass = NV_DMA_IN_MEMORY, | ||
| 423 | }; | ||
| 399 | struct nouveau_drm *drm = nouveau_drm(dev); | 424 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 400 | struct nouveau_device *device = nv_device(drm->device); | ||
| 401 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); | 425 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); |
| 402 | struct nouveau_abi16_chan *chan = NULL, *temp; | 426 | struct nouveau_abi16_chan *chan; |
| 403 | struct nouveau_abi16_ntfy *ntfy; | 427 | struct nouveau_abi16_ntfy *ntfy; |
| 404 | struct nouveau_object *object; | 428 | struct nvif_device *device = &abi16->device; |
| 405 | struct nv_dma_class args = {}; | 429 | struct nvif_client *client; |
| 406 | int ret; | 430 | int ret; |
| 407 | 431 | ||
| 408 | if (unlikely(!abi16)) | 432 | if (unlikely(!abi16)) |
| 409 | return -ENOMEM; | 433 | return -ENOMEM; |
| 410 | 434 | ||
| 411 | /* completely unnecessary for these chipsets... */ | 435 | /* completely unnecessary for these chipsets... */ |
| 412 | if (unlikely(nv_device(abi16->device)->card_type >= NV_C0)) | 436 | if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI)) |
| 413 | return nouveau_abi16_put(abi16, -EINVAL); | 437 | return nouveau_abi16_put(abi16, -EINVAL); |
| 438 | client = nvif_client(nvif_object(&abi16->device)); | ||
| 414 | 439 | ||
| 415 | list_for_each_entry(temp, &abi16->channels, head) { | 440 | chan = nouveau_abi16_chan(abi16, info->channel); |
| 416 | if (temp->chan->handle == (NVDRM_CHAN | info->channel)) { | ||
| 417 | chan = temp; | ||
| 418 | break; | ||
| 419 | } | ||
| 420 | } | ||
| 421 | |||
| 422 | if (!chan) | 441 | if (!chan) |
| 423 | return nouveau_abi16_put(abi16, -ENOENT); | 442 | return nouveau_abi16_put(abi16, -ENOENT); |
| 424 | 443 | ||
| @@ -434,26 +453,29 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS) | |||
| 434 | if (ret) | 453 | if (ret) |
| 435 | goto done; | 454 | goto done; |
| 436 | 455 | ||
| 437 | args.start = ntfy->node->offset; | 456 | args.ctxdma.start = ntfy->node->offset; |
| 438 | args.limit = ntfy->node->offset + ntfy->node->length - 1; | 457 | args.ctxdma.limit = ntfy->node->offset + ntfy->node->length - 1; |
| 439 | if (device->card_type >= NV_50) { | 458 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { |
| 440 | args.flags = NV_DMA_TARGET_VM | NV_DMA_ACCESS_VM; | 459 | args.ctxdma.target = NV_DMA_V0_TARGET_VM; |
| 441 | args.start += chan->ntfy_vma.offset; | 460 | args.ctxdma.access = NV_DMA_V0_ACCESS_VM; |
| 442 | args.limit += chan->ntfy_vma.offset; | 461 | args.ctxdma.start += chan->ntfy_vma.offset; |
| 462 | args.ctxdma.limit += chan->ntfy_vma.offset; | ||
| 443 | } else | 463 | } else |
| 444 | if (drm->agp.stat == ENABLED) { | 464 | if (drm->agp.stat == ENABLED) { |
| 445 | args.flags = NV_DMA_TARGET_AGP | NV_DMA_ACCESS_RDWR; | 465 | args.ctxdma.target = NV_DMA_V0_TARGET_AGP; |
| 446 | args.start += drm->agp.base + chan->ntfy->bo.offset; | 466 | args.ctxdma.access = NV_DMA_V0_ACCESS_RDWR; |
| 447 | args.limit += drm->agp.base + chan->ntfy->bo.offset; | 467 | args.ctxdma.start += drm->agp.base + chan->ntfy->bo.offset; |
| 468 | args.ctxdma.limit += drm->agp.base + chan->ntfy->bo.offset; | ||
| 469 | client->super = true; | ||
| 448 | } else { | 470 | } else { |
| 449 | args.flags = NV_DMA_TARGET_VM | NV_DMA_ACCESS_RDWR; | 471 | args.ctxdma.target = NV_DMA_V0_TARGET_VM; |
| 450 | args.start += chan->ntfy->bo.offset; | 472 | args.ctxdma.access = NV_DMA_V0_ACCESS_RDWR; |
| 451 | args.limit += chan->ntfy->bo.offset; | 473 | args.ctxdma.start += chan->ntfy->bo.offset; |
| 474 | args.ctxdma.limit += chan->ntfy->bo.offset; | ||
| 452 | } | 475 | } |
| 453 | 476 | ||
| 454 | ret = nouveau_object_new(abi16->client, chan->chan->handle, | 477 | ret = nvif_client_ioctl(client, &args, sizeof(args)); |
| 455 | ntfy->handle, 0x003d, &args, | 478 | client->super = false; |
| 456 | sizeof(args), &object); | ||
| 457 | if (ret) | 479 | if (ret) |
| 458 | goto done; | 480 | goto done; |
| 459 | 481 | ||
| @@ -469,28 +491,36 @@ int | |||
| 469 | nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS) | 491 | nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS) |
| 470 | { | 492 | { |
| 471 | struct drm_nouveau_gpuobj_free *fini = data; | 493 | struct drm_nouveau_gpuobj_free *fini = data; |
| 494 | struct { | ||
| 495 | struct nvif_ioctl_v0 ioctl; | ||
| 496 | struct nvif_ioctl_del del; | ||
| 497 | } args = { | ||
| 498 | .ioctl.owner = NVDRM_OBJECT_ABI16, | ||
| 499 | .ioctl.type = NVIF_IOCTL_V0_DEL, | ||
| 500 | .ioctl.path_nr = 4, | ||
| 501 | .ioctl.path[3] = NOUVEAU_ABI16_CLIENT, | ||
| 502 | .ioctl.path[2] = NOUVEAU_ABI16_DEVICE, | ||
| 503 | .ioctl.path[1] = NOUVEAU_ABI16_CHAN(fini->channel), | ||
| 504 | .ioctl.path[0] = fini->handle, | ||
| 505 | }; | ||
| 472 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); | 506 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); |
| 473 | struct nouveau_abi16_chan *chan = NULL, *temp; | 507 | struct nouveau_abi16_chan *chan; |
| 474 | struct nouveau_abi16_ntfy *ntfy; | 508 | struct nouveau_abi16_ntfy *ntfy; |
| 509 | struct nvif_client *client; | ||
| 475 | int ret; | 510 | int ret; |
| 476 | 511 | ||
| 477 | if (unlikely(!abi16)) | 512 | if (unlikely(!abi16)) |
| 478 | return -ENOMEM; | 513 | return -ENOMEM; |
| 479 | 514 | ||
| 480 | list_for_each_entry(temp, &abi16->channels, head) { | 515 | chan = nouveau_abi16_chan(abi16, fini->channel); |
| 481 | if (temp->chan->handle == (NVDRM_CHAN | fini->channel)) { | ||
| 482 | chan = temp; | ||
| 483 | break; | ||
| 484 | } | ||
| 485 | } | ||
| 486 | |||
| 487 | if (!chan) | 516 | if (!chan) |
| 488 | return nouveau_abi16_put(abi16, -ENOENT); | 517 | return nouveau_abi16_put(abi16, -ENOENT); |
| 518 | client = nvif_client(nvif_object(&abi16->device)); | ||
| 489 | 519 | ||
| 490 | /* synchronize with the user channel and destroy the gpu object */ | 520 | /* synchronize with the user channel and destroy the gpu object */ |
| 491 | nouveau_channel_idle(chan->chan); | 521 | nouveau_channel_idle(chan->chan); |
| 492 | 522 | ||
| 493 | ret = nouveau_object_del(abi16->client, chan->chan->handle, fini->handle); | 523 | ret = nvif_client_ioctl(client, &args, sizeof(args)); |
| 494 | if (ret) | 524 | if (ret) |
| 495 | return nouveau_abi16_put(abi16, ret); | 525 | return nouveau_abi16_put(abi16, ret); |
| 496 | 526 | ||
