Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Red Hat Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | */ |
| 23 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 24 | #include <nvif/client.h> |
| 25 | #include <nvif/driver.h> |
| 26 | #include <nvif/ioctl.h> |
Ben Skeggs | fdb751e | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 27 | #include <nvif/class.h> |
Ben Skeggs | 845f272 | 2015-11-08 12:16:40 +1000 | [diff] [blame] | 28 | #include <nvif/cl0002.h> |
Ben Skeggs | 8ed1730 | 2015-11-08 11:28:26 +1000 | [diff] [blame] | 29 | #include <nvif/cla06f.h> |
Ben Skeggs | 2621a41 | 2015-11-03 11:21:43 +1000 | [diff] [blame] | 30 | #include <nvif/unpack.h> |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 31 | |
Ben Skeggs | 4dc2813 | 2016-05-20 09:22:55 +1000 | [diff] [blame] | 32 | #include "nouveau_drv.h" |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 33 | #include "nouveau_dma.h" |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 34 | #include "nouveau_gem.h" |
| 35 | #include "nouveau_chan.h" |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 36 | #include "nouveau_abi16.h" |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 37 | |
Ben Skeggs | 786a57e | 2015-11-03 10:55:45 +1000 | [diff] [blame] | 38 | static struct nouveau_abi16 * |
| 39 | nouveau_abi16(struct drm_file *file_priv) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 40 | { |
| 41 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 42 | if (!cli->abi16) { |
| 43 | struct nouveau_abi16 *abi16; |
| 44 | cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL); |
| 45 | if (cli->abi16) { |
Ben Skeggs | 586491e | 2014-08-10 04:10:24 +1000 | [diff] [blame] | 46 | struct nv_device_v0 args = { |
| 47 | .device = ~0ULL, |
| 48 | }; |
| 49 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 50 | INIT_LIST_HEAD(&abi16->channels); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 51 | |
| 52 | /* allocate device object targeting client's default |
| 53 | * device (ie. the one that belongs to the fd it |
| 54 | * opened) |
| 55 | */ |
Ben Skeggs | fcf3f91 | 2015-09-04 14:40:32 +1000 | [diff] [blame] | 56 | if (nvif_device_init(&cli->base.object, 0, NV_DEVICE, |
Ben Skeggs | 586491e | 2014-08-10 04:10:24 +1000 | [diff] [blame] | 57 | &args, sizeof(args), |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 58 | &abi16->device) == 0) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 59 | return cli->abi16; |
| 60 | |
| 61 | kfree(cli->abi16); |
| 62 | cli->abi16 = NULL; |
| 63 | } |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 64 | } |
| 65 | return cli->abi16; |
| 66 | } |
| 67 | |
Ben Skeggs | 786a57e | 2015-11-03 10:55:45 +1000 | [diff] [blame] | 68 | struct nouveau_abi16 * |
| 69 | nouveau_abi16_get(struct drm_file *file_priv) |
| 70 | { |
| 71 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
| 72 | mutex_lock(&cli->mutex); |
| 73 | if (nouveau_abi16(file_priv)) |
| 74 | return cli->abi16; |
| 75 | mutex_unlock(&cli->mutex); |
| 76 | return NULL; |
| 77 | } |
| 78 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 79 | int |
| 80 | nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) |
| 81 | { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 82 | struct nouveau_cli *cli = (void *)abi16->device.object.client; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 83 | mutex_unlock(&cli->mutex); |
| 84 | return ret; |
| 85 | } |
| 86 | |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 87 | s32 |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 88 | nouveau_abi16_swclass(struct nouveau_drm *drm) |
| 89 | { |
Ben Skeggs | 1167c6b | 2016-05-18 13:57:42 +1000 | [diff] [blame] | 90 | switch (drm->client.device.info.family) { |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 91 | case NV_DEVICE_INFO_V0_TNT: |
Ben Skeggs | 08f7633 | 2015-11-08 10:18:19 +1000 | [diff] [blame] | 92 | return NVIF_CLASS_SW_NV04; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 93 | case NV_DEVICE_INFO_V0_CELSIUS: |
| 94 | case NV_DEVICE_INFO_V0_KELVIN: |
| 95 | case NV_DEVICE_INFO_V0_RANKINE: |
| 96 | case NV_DEVICE_INFO_V0_CURIE: |
Ben Skeggs | 08f7633 | 2015-11-08 10:18:19 +1000 | [diff] [blame] | 97 | return NVIF_CLASS_SW_NV10; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 98 | case NV_DEVICE_INFO_V0_TESLA: |
Ben Skeggs | 08f7633 | 2015-11-08 10:18:19 +1000 | [diff] [blame] | 99 | return NVIF_CLASS_SW_NV50; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 100 | case NV_DEVICE_INFO_V0_FERMI: |
| 101 | case NV_DEVICE_INFO_V0_KEPLER: |
| 102 | case NV_DEVICE_INFO_V0_MAXWELL: |
Ben Skeggs | 7f53abd | 2016-07-09 10:41:01 +1000 | [diff] [blame] | 103 | case NV_DEVICE_INFO_V0_PASCAL: |
Ben Skeggs | 08f7633 | 2015-11-08 10:18:19 +1000 | [diff] [blame] | 104 | return NVIF_CLASS_SW_GF100; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | return 0x0000; |
| 108 | } |
| 109 | |
| 110 | static void |
| 111 | nouveau_abi16_ntfy_fini(struct nouveau_abi16_chan *chan, |
| 112 | struct nouveau_abi16_ntfy *ntfy) |
| 113 | { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 114 | nvif_object_fini(&ntfy->object); |
Ben Skeggs | be83cd4 | 2015-01-14 15:36:34 +1000 | [diff] [blame] | 115 | nvkm_mm_free(&chan->heap, &ntfy->node); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 116 | list_del(&ntfy->head); |
| 117 | kfree(ntfy); |
| 118 | } |
| 119 | |
| 120 | static void |
| 121 | nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16, |
| 122 | struct nouveau_abi16_chan *chan) |
| 123 | { |
| 124 | struct nouveau_abi16_ntfy *ntfy, *temp; |
| 125 | |
Marcin Slusarz | 2b77c1c | 2013-03-03 18:58:45 +0100 | [diff] [blame] | 126 | /* wait for all activity to stop before releasing notify object, which |
| 127 | * may be still in use */ |
| 128 | if (chan->chan && chan->ntfy) |
| 129 | nouveau_channel_idle(chan->chan); |
| 130 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 131 | /* cleanup notifier state */ |
| 132 | list_for_each_entry_safe(ntfy, temp, &chan->notifiers, head) { |
| 133 | nouveau_abi16_ntfy_fini(chan, ntfy); |
| 134 | } |
| 135 | |
| 136 | if (chan->ntfy) { |
| 137 | nouveau_bo_vma_del(chan->ntfy, &chan->ntfy_vma); |
Maarten Lankhorst | 198c14a | 2013-06-27 13:38:20 +0200 | [diff] [blame] | 138 | nouveau_bo_unpin(chan->ntfy); |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 139 | drm_gem_object_unreference_unlocked(&chan->ntfy->gem); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | if (chan->heap.block_size) |
Ben Skeggs | be83cd4 | 2015-01-14 15:36:34 +1000 | [diff] [blame] | 143 | nvkm_mm_fini(&chan->heap); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 144 | |
| 145 | /* destroy channel object, all children will be killed too */ |
| 146 | if (chan->chan) { |
Ben Skeggs | fbd58eb | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 147 | nouveau_channel_idle(chan->chan); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 148 | nouveau_channel_del(&chan->chan); |
| 149 | } |
| 150 | |
| 151 | list_del(&chan->head); |
| 152 | kfree(chan); |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | nouveau_abi16_fini(struct nouveau_abi16 *abi16) |
| 157 | { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 158 | struct nouveau_cli *cli = (void *)abi16->device.object.client; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 159 | struct nouveau_abi16_chan *chan, *temp; |
| 160 | |
| 161 | /* cleanup channels */ |
| 162 | list_for_each_entry_safe(chan, temp, &abi16->channels, head) { |
| 163 | nouveau_abi16_chan_fini(abi16, chan); |
| 164 | } |
| 165 | |
| 166 | /* destroy the device object */ |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 167 | nvif_device_fini(&abi16->device); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 168 | |
| 169 | kfree(cli->abi16); |
| 170 | cli->abi16 = NULL; |
| 171 | } |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 172 | |
| 173 | int |
| 174 | nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) |
| 175 | { |
Ben Skeggs | fa2bade | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 176 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 177 | struct nouveau_drm *drm = nouveau_drm(dev); |
Ben Skeggs | 1167c6b | 2016-05-18 13:57:42 +1000 | [diff] [blame] | 178 | struct nvif_device *device = &drm->client.device; |
Ben Skeggs | be83cd4 | 2015-01-14 15:36:34 +1000 | [diff] [blame] | 179 | struct nvkm_gr *gr = nvxx_gr(device); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 180 | struct drm_nouveau_getparam *getparam = data; |
| 181 | |
| 182 | switch (getparam->param) { |
| 183 | case NOUVEAU_GETPARAM_CHIPSET_ID: |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 184 | getparam->value = device->info.chipset; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 185 | break; |
| 186 | case NOUVEAU_GETPARAM_PCI_VENDOR: |
Ben Skeggs | 26c9e8e | 2015-08-20 14:54:23 +1000 | [diff] [blame] | 187 | if (nvxx_device(device)->func->pci) |
Alexandre Courbot | 420b946 | 2014-02-17 15:17:26 +0900 | [diff] [blame] | 188 | getparam->value = dev->pdev->vendor; |
| 189 | else |
| 190 | getparam->value = 0; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 191 | break; |
| 192 | case NOUVEAU_GETPARAM_PCI_DEVICE: |
Ben Skeggs | 26c9e8e | 2015-08-20 14:54:23 +1000 | [diff] [blame] | 193 | if (nvxx_device(device)->func->pci) |
Alexandre Courbot | 420b946 | 2014-02-17 15:17:26 +0900 | [diff] [blame] | 194 | getparam->value = dev->pdev->device; |
| 195 | else |
| 196 | getparam->value = 0; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 197 | break; |
| 198 | case NOUVEAU_GETPARAM_BUS_TYPE: |
Ben Skeggs | 26c9e8e | 2015-08-20 14:54:23 +1000 | [diff] [blame] | 199 | if (!nvxx_device(device)->func->pci) |
Alexandre Courbot | 420b946 | 2014-02-17 15:17:26 +0900 | [diff] [blame] | 200 | getparam->value = 3; |
| 201 | else |
Daniel Vetter | 2ce0264 | 2017-01-25 07:26:52 +0100 | [diff] [blame] | 202 | if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP)) |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 203 | getparam->value = 0; |
| 204 | else |
| 205 | if (!pci_is_pcie(dev->pdev)) |
| 206 | getparam->value = 1; |
| 207 | else |
| 208 | getparam->value = 2; |
| 209 | break; |
| 210 | case NOUVEAU_GETPARAM_FB_SIZE: |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 211 | getparam->value = drm->gem.vram_available; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 212 | break; |
| 213 | case NOUVEAU_GETPARAM_AGP_SIZE: |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 214 | getparam->value = drm->gem.gart_available; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 215 | break; |
| 216 | case NOUVEAU_GETPARAM_VM_VRAM_BASE: |
| 217 | getparam->value = 0; /* deprecated */ |
| 218 | break; |
| 219 | case NOUVEAU_GETPARAM_PTIMER_TIME: |
Ben Skeggs | 56f67dc | 2015-08-20 14:54:10 +1000 | [diff] [blame] | 220 | getparam->value = nvif_device_time(device); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 221 | break; |
| 222 | case NOUVEAU_GETPARAM_HAS_BO_USAGE: |
| 223 | getparam->value = 1; |
| 224 | break; |
| 225 | case NOUVEAU_GETPARAM_HAS_PAGEFLIP: |
| 226 | getparam->value = 1; |
| 227 | break; |
| 228 | case NOUVEAU_GETPARAM_GRAPH_UNITS: |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 229 | getparam->value = nvkm_gr_units(gr); |
Christoph Bumiller | 7e22e71 | 2013-03-27 22:16:54 +0100 | [diff] [blame] | 230 | break; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 231 | default: |
Ben Skeggs | 9ad97ed | 2015-08-20 14:54:13 +1000 | [diff] [blame] | 232 | NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 233 | return -EINVAL; |
| 234 | } |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | int |
| 240 | nouveau_abi16_ioctl_setparam(ABI16_IOCTL_ARGS) |
| 241 | { |
| 242 | return -EINVAL; |
| 243 | } |
| 244 | |
| 245 | int |
| 246 | nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) |
| 247 | { |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 248 | struct drm_nouveau_channel_alloc *init = data; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 249 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
| 250 | struct nouveau_drm *drm = nouveau_drm(dev); |
Ben Skeggs | 09433f2 | 2015-11-03 10:17:49 +1000 | [diff] [blame] | 251 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 252 | struct nouveau_abi16_chan *chan; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 253 | struct nvif_device *device; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 254 | int ret; |
| 255 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 256 | if (unlikely(!abi16)) |
| 257 | return -ENOMEM; |
Marcin Slusarz | bf7e438 | 2012-11-11 20:00:09 +0100 | [diff] [blame] | 258 | |
| 259 | if (!drm->channel) |
| 260 | return nouveau_abi16_put(abi16, -ENODEV); |
| 261 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 262 | device = &abi16->device; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 263 | |
Ben Skeggs | 4946980 | 2012-11-22 13:43:55 +1000 | [diff] [blame] | 264 | /* hack to allow channel engine type specification on kepler */ |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 265 | if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) { |
Ben Skeggs | 4946980 | 2012-11-22 13:43:55 +1000 | [diff] [blame] | 266 | if (init->fb_ctxdma_handle != ~0) |
Ben Skeggs | 1f5ff7f | 2016-03-11 13:09:28 +1000 | [diff] [blame] | 267 | init->fb_ctxdma_handle = NVA06F_V0_ENGINE_GR; |
| 268 | else { |
| 269 | init->fb_ctxdma_handle = 0; |
| 270 | #define _(A,B) if (init->tt_ctxdma_handle & (A)) init->fb_ctxdma_handle |= (B) |
| 271 | _(0x01, NVA06F_V0_ENGINE_GR); |
| 272 | _(0x02, NVA06F_V0_ENGINE_MSPDEC); |
| 273 | _(0x04, NVA06F_V0_ENGINE_MSPPP); |
| 274 | _(0x08, NVA06F_V0_ENGINE_MSVLD); |
| 275 | _(0x10, NVA06F_V0_ENGINE_CE0); |
| 276 | _(0x20, NVA06F_V0_ENGINE_CE1); |
| 277 | _(0x40, NVA06F_V0_ENGINE_MSENC); |
| 278 | #undef _ |
| 279 | } |
Ben Skeggs | 4946980 | 2012-11-22 13:43:55 +1000 | [diff] [blame] | 280 | |
| 281 | /* allow flips to be executed if this is a graphics channel */ |
| 282 | init->tt_ctxdma_handle = 0; |
Ben Skeggs | 1f5ff7f | 2016-03-11 13:09:28 +1000 | [diff] [blame] | 283 | if (init->fb_ctxdma_handle == NVA06F_V0_ENGINE_GR) |
Ben Skeggs | 4946980 | 2012-11-22 13:43:55 +1000 | [diff] [blame] | 284 | init->tt_ctxdma_handle = 1; |
| 285 | } |
| 286 | |
| 287 | if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0) |
| 288 | return nouveau_abi16_put(abi16, -EINVAL); |
| 289 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 290 | /* allocate "abi16 channel" data and make up a handle for it */ |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 291 | chan = kzalloc(sizeof(*chan), GFP_KERNEL); |
| 292 | if (!chan) |
| 293 | return nouveau_abi16_put(abi16, -ENOMEM); |
| 294 | |
| 295 | INIT_LIST_HEAD(&chan->notifiers); |
| 296 | list_add(&chan->head, &abi16->channels); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 297 | |
| 298 | /* create channel object and initialise dma and fence management */ |
Ben Skeggs | fcf3f91 | 2015-09-04 14:40:32 +1000 | [diff] [blame] | 299 | ret = nouveau_channel_new(drm, device, init->fb_ctxdma_handle, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 300 | init->tt_ctxdma_handle, &chan->chan); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 301 | if (ret) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 302 | goto done; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 303 | |
Ben Skeggs | fcf3f91 | 2015-09-04 14:40:32 +1000 | [diff] [blame] | 304 | init->channel = chan->chan->chid; |
| 305 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 306 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 307 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM | |
| 308 | NOUVEAU_GEM_DOMAIN_GART; |
| 309 | else |
| 310 | if (chan->chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM) |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 311 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 312 | else |
| 313 | init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 314 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 315 | if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) { |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 316 | init->subchan[0].handle = 0x00000000; |
| 317 | init->subchan[0].grclass = 0x0000; |
Ben Skeggs | f45f55c4 | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 318 | init->subchan[1].handle = chan->chan->nvsw.handle; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 319 | init->subchan[1].grclass = 0x506e; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 320 | init->nr_subchan = 2; |
| 321 | } |
| 322 | |
| 323 | /* Named memory object area */ |
Ben Skeggs | fc1b0a0 | 2016-05-24 17:29:55 +1000 | [diff] [blame] | 324 | ret = nouveau_gem_new(cli, PAGE_SIZE, 0, NOUVEAU_GEM_DOMAIN_GART, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 325 | 0, 0, &chan->ntfy); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 326 | if (ret == 0) |
Ben Skeggs | ad76b3f | 2014-11-10 11:24:27 +1000 | [diff] [blame] | 327 | ret = nouveau_bo_pin(chan->ntfy, TTM_PL_FLAG_TT, false); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 328 | if (ret) |
| 329 | goto done; |
| 330 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 331 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 332 | ret = nouveau_bo_vma_add(chan->ntfy, cli->vm, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 333 | &chan->ntfy_vma); |
| 334 | if (ret) |
| 335 | goto done; |
| 336 | } |
| 337 | |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 338 | ret = drm_gem_handle_create(file_priv, &chan->ntfy->gem, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 339 | &init->notifier_handle); |
| 340 | if (ret) |
| 341 | goto done; |
| 342 | |
Ben Skeggs | be83cd4 | 2015-01-14 15:36:34 +1000 | [diff] [blame] | 343 | ret = nvkm_mm_init(&chan->heap, 0, PAGE_SIZE, 1); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 344 | done: |
| 345 | if (ret) |
| 346 | nouveau_abi16_chan_fini(abi16, chan); |
| 347 | return nouveau_abi16_put(abi16, ret); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 348 | } |
| 349 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 350 | static struct nouveau_abi16_chan * |
| 351 | nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel) |
| 352 | { |
| 353 | struct nouveau_abi16_chan *chan; |
| 354 | |
| 355 | list_for_each_entry(chan, &abi16->channels, head) { |
Ben Skeggs | fcf3f91 | 2015-09-04 14:40:32 +1000 | [diff] [blame] | 356 | if (chan->chan->chid == channel) |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 357 | return chan; |
| 358 | } |
| 359 | |
| 360 | return NULL; |
| 361 | } |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 362 | |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 363 | int |
Ben Skeggs | 2621a41 | 2015-11-03 11:21:43 +1000 | [diff] [blame] | 364 | nouveau_abi16_usif(struct drm_file *file_priv, void *data, u32 size) |
| 365 | { |
| 366 | union { |
| 367 | struct nvif_ioctl_v0 v0; |
| 368 | } *args = data; |
| 369 | struct nouveau_abi16_chan *chan; |
| 370 | struct nouveau_abi16 *abi16; |
Ben Skeggs | f01c4e6 | 2015-11-09 09:21:27 +1000 | [diff] [blame] | 371 | int ret = -ENOSYS; |
Ben Skeggs | 2621a41 | 2015-11-03 11:21:43 +1000 | [diff] [blame] | 372 | |
Ben Skeggs | f01c4e6 | 2015-11-09 09:21:27 +1000 | [diff] [blame] | 373 | if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) { |
Ben Skeggs | 2621a41 | 2015-11-03 11:21:43 +1000 | [diff] [blame] | 374 | switch (args->v0.type) { |
| 375 | case NVIF_IOCTL_V0_NEW: |
| 376 | case NVIF_IOCTL_V0_MTHD: |
| 377 | case NVIF_IOCTL_V0_SCLASS: |
| 378 | break; |
| 379 | default: |
| 380 | return -EACCES; |
| 381 | } |
| 382 | } else |
| 383 | return ret; |
| 384 | |
| 385 | if (!(abi16 = nouveau_abi16(file_priv))) |
| 386 | return -ENOMEM; |
| 387 | |
| 388 | if (args->v0.token != ~0ULL) { |
| 389 | if (!(chan = nouveau_abi16_chan(abi16, args->v0.token))) |
| 390 | return -EINVAL; |
| 391 | args->v0.object = nvif_handle(&chan->chan->user); |
| 392 | args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY; |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | args->v0.object = nvif_handle(&abi16->device.object); |
| 397 | args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY; |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | int |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 402 | nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS) |
| 403 | { |
| 404 | struct drm_nouveau_channel_free *req = data; |
Ben Skeggs | 09433f2 | 2015-11-03 10:17:49 +1000 | [diff] [blame] | 405 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 406 | struct nouveau_abi16_chan *chan; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 407 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 408 | if (unlikely(!abi16)) |
| 409 | return -ENOMEM; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 410 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 411 | chan = nouveau_abi16_chan(abi16, req->channel); |
| 412 | if (!chan) |
| 413 | return nouveau_abi16_put(abi16, -ENOENT); |
| 414 | nouveau_abi16_chan_fini(abi16, chan); |
| 415 | return nouveau_abi16_put(abi16, 0); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | int |
| 419 | nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) |
| 420 | { |
| 421 | struct drm_nouveau_grobj_alloc *init = data; |
Ben Skeggs | 09433f2 | 2015-11-03 10:17:49 +1000 | [diff] [blame] | 422 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 423 | struct nouveau_abi16_chan *chan; |
| 424 | struct nouveau_abi16_ntfy *ntfy; |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 425 | struct nvif_client *client; |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 426 | struct nvif_sclass *sclass; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 427 | s32 oclass = 0; |
| 428 | int ret, i; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 429 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 430 | if (unlikely(!abi16)) |
| 431 | return -ENOMEM; |
| 432 | |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 433 | if (init->handle == ~0) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 434 | return nouveau_abi16_put(abi16, -EINVAL); |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 435 | client = abi16->device.object.client; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 436 | |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 437 | chan = nouveau_abi16_chan(abi16, init->channel); |
| 438 | if (!chan) |
| 439 | return nouveau_abi16_put(abi16, -ENOENT); |
| 440 | |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 441 | ret = nvif_object_sclass_get(&chan->chan->user, &sclass); |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 442 | if (ret < 0) |
| 443 | return nouveau_abi16_put(abi16, ret); |
| 444 | |
| 445 | if ((init->class & 0x00ff) == 0x006e) { |
| 446 | /* nvsw: compatibility with older 0x*6e class identifier */ |
| 447 | for (i = 0; !oclass && i < ret; i++) { |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 448 | switch (sclass[i].oclass) { |
Ben Skeggs | 08f7633 | 2015-11-08 10:18:19 +1000 | [diff] [blame] | 449 | case NVIF_CLASS_SW_NV04: |
| 450 | case NVIF_CLASS_SW_NV10: |
| 451 | case NVIF_CLASS_SW_NV50: |
| 452 | case NVIF_CLASS_SW_GF100: |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 453 | oclass = sclass[i].oclass; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 454 | break; |
| 455 | default: |
| 456 | break; |
| 457 | } |
| 458 | } |
| 459 | } else |
| 460 | if ((init->class & 0x00ff) == 0x00b1) { |
| 461 | /* msvld: compatibility with incorrect version exposure */ |
| 462 | for (i = 0; i < ret; i++) { |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 463 | if ((sclass[i].oclass & 0x00ff) == 0x00b1) { |
| 464 | oclass = sclass[i].oclass; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 465 | break; |
| 466 | } |
| 467 | } |
| 468 | } else |
| 469 | if ((init->class & 0x00ff) == 0x00b2) { /* mspdec */ |
| 470 | /* mspdec: compatibility with incorrect version exposure */ |
| 471 | for (i = 0; i < ret; i++) { |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 472 | if ((sclass[i].oclass & 0x00ff) == 0x00b2) { |
| 473 | oclass = sclass[i].oclass; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 474 | break; |
| 475 | } |
| 476 | } |
| 477 | } else |
| 478 | if ((init->class & 0x00ff) == 0x00b3) { /* msppp */ |
| 479 | /* msppp: compatibility with incorrect version exposure */ |
| 480 | for (i = 0; i < ret; i++) { |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 481 | if ((sclass[i].oclass & 0x00ff) == 0x00b3) { |
| 482 | oclass = sclass[i].oclass; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 483 | break; |
| 484 | } |
| 485 | } |
| 486 | } else { |
| 487 | oclass = init->class; |
| 488 | } |
| 489 | |
Ben Skeggs | 41a6340 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 490 | nvif_object_sclass_put(&sclass); |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 491 | if (!oclass) |
| 492 | return nouveau_abi16_put(abi16, -EINVAL); |
| 493 | |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 494 | ntfy = kzalloc(sizeof(*ntfy), GFP_KERNEL); |
| 495 | if (!ntfy) |
| 496 | return nouveau_abi16_put(abi16, -ENOMEM); |
| 497 | |
| 498 | list_add(&ntfy->head, &chan->notifiers); |
| 499 | |
| 500 | client->route = NVDRM_OBJECT_ABI16; |
Ben Skeggs | f58ddf9 | 2015-08-20 14:54:16 +1000 | [diff] [blame] | 501 | ret = nvif_object_init(&chan->chan->user, init->handle, oclass, |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 502 | NULL, 0, &ntfy->object); |
| 503 | client->route = NVDRM_OBJECT_NVIF; |
| 504 | |
| 505 | if (ret) |
| 506 | nouveau_abi16_ntfy_fini(chan, ntfy); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 507 | return nouveau_abi16_put(abi16, ret); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | int |
| 511 | nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS) |
| 512 | { |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 513 | struct drm_nouveau_notifierobj_alloc *info = data; |
| 514 | struct nouveau_drm *drm = nouveau_drm(dev); |
Ben Skeggs | 09433f2 | 2015-11-03 10:17:49 +1000 | [diff] [blame] | 515 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 516 | struct nouveau_abi16_chan *chan; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 517 | struct nouveau_abi16_ntfy *ntfy; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 518 | struct nvif_device *device = &abi16->device; |
Ben Skeggs | 3bdda04 | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 519 | struct nvif_client *client; |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 520 | struct nv_dma_v0 args = {}; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 521 | int ret; |
| 522 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 523 | if (unlikely(!abi16)) |
| 524 | return -ENOMEM; |
| 525 | |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 526 | /* completely unnecessary for these chipsets... */ |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 527 | if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI)) |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 528 | return nouveau_abi16_put(abi16, -EINVAL); |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 529 | client = abi16->device.object.client; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 530 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 531 | chan = nouveau_abi16_chan(abi16, info->channel); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 532 | if (!chan) |
| 533 | return nouveau_abi16_put(abi16, -ENOENT); |
| 534 | |
| 535 | ntfy = kzalloc(sizeof(*ntfy), GFP_KERNEL); |
| 536 | if (!ntfy) |
| 537 | return nouveau_abi16_put(abi16, -ENOMEM); |
| 538 | |
| 539 | list_add(&ntfy->head, &chan->notifiers); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 540 | |
Ben Skeggs | be83cd4 | 2015-01-14 15:36:34 +1000 | [diff] [blame] | 541 | ret = nvkm_mm_head(&chan->heap, 0, 1, info->size, info->size, 1, |
| 542 | &ntfy->node); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 543 | if (ret) |
| 544 | goto done; |
| 545 | |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 546 | args.start = ntfy->node->offset; |
| 547 | args.limit = ntfy->node->offset + ntfy->node->length - 1; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 548 | if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 549 | args.target = NV_DMA_V0_TARGET_VM; |
| 550 | args.access = NV_DMA_V0_ACCESS_VM; |
| 551 | args.start += chan->ntfy_vma.offset; |
| 552 | args.limit += chan->ntfy_vma.offset; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 553 | } else |
Ben Skeggs | 340b0e7 | 2015-08-20 14:54:23 +1000 | [diff] [blame] | 554 | if (drm->agp.bridge) { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 555 | args.target = NV_DMA_V0_TARGET_AGP; |
| 556 | args.access = NV_DMA_V0_ACCESS_RDWR; |
| 557 | args.start += drm->agp.base + chan->ntfy->bo.offset; |
| 558 | args.limit += drm->agp.base + chan->ntfy->bo.offset; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 559 | } else { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 560 | args.target = NV_DMA_V0_TARGET_VM; |
| 561 | args.access = NV_DMA_V0_ACCESS_RDWR; |
| 562 | args.start += chan->ntfy->bo.offset; |
| 563 | args.limit += chan->ntfy->bo.offset; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 564 | } |
| 565 | |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 566 | client->route = NVDRM_OBJECT_ABI16; |
| 567 | client->super = true; |
| 568 | ret = nvif_object_init(&chan->chan->user, info->handle, |
| 569 | NV_DMA_IN_MEMORY, &args, sizeof(args), |
| 570 | &ntfy->object); |
Ben Skeggs | 3bdda04 | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 571 | client->super = false; |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 572 | client->route = NVDRM_OBJECT_NVIF; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 573 | if (ret) |
| 574 | goto done; |
| 575 | |
Bob Gleitsmann | c1ccaa6 | 2014-01-06 08:59:07 +1000 | [diff] [blame] | 576 | info->offset = ntfy->node->offset; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 577 | done: |
| 578 | if (ret) |
| 579 | nouveau_abi16_ntfy_fini(chan, ntfy); |
| 580 | return nouveau_abi16_put(abi16, ret); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | int |
| 584 | nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS) |
| 585 | { |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 586 | struct drm_nouveau_gpuobj_free *fini = data; |
Ben Skeggs | 09433f2 | 2015-11-03 10:17:49 +1000 | [diff] [blame] | 587 | struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 588 | struct nouveau_abi16_chan *chan; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 589 | struct nouveau_abi16_ntfy *ntfy; |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 590 | int ret = -ENOENT; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 591 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 592 | if (unlikely(!abi16)) |
| 593 | return -ENOMEM; |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 594 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 595 | chan = nouveau_abi16_chan(abi16, fini->channel); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 596 | if (!chan) |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 597 | return nouveau_abi16_put(abi16, -EINVAL); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 598 | |
| 599 | /* synchronize with the user channel and destroy the gpu object */ |
| 600 | nouveau_channel_idle(chan->chan); |
| 601 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 602 | list_for_each_entry(ntfy, &chan->notifiers, head) { |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 603 | if (ntfy->object.handle == fini->handle) { |
| 604 | nouveau_abi16_ntfy_fini(chan, ntfy); |
| 605 | ret = 0; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 606 | break; |
| 607 | } |
| 608 | } |
| 609 | |
Ben Skeggs | a01ca78 | 2015-08-20 14:54:15 +1000 | [diff] [blame] | 610 | return nouveau_abi16_put(abi16, ret); |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 611 | } |