Expose nvif ioctl interface. nvif is a variable length (nested..) ioctl, so it doesn't match the usual drm_ioctl interface. linux uses a shim to override the ioctl function for nouveau to allow this, do the same. fixes 3D acceleration with nouveau. from riastradh.diff -r1.15 -r1.16 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c
(maya)
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c 2018/08/27 15:22:54 1.15
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c 2018/12/21 07:51:17 1.16
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: nouveau_drm.c,v 1.15 2018/08/27 15:22:54 riastradh Exp $ */ | 1 | /* $NetBSD: nouveau_drm.c,v 1.16 2018/12/21 07:51:17 maya Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2012 Red Hat Inc. | 4 | * Copyright 2012 Red Hat Inc. | |
5 | * | 5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | 6 | * Permission is hereby granted, free of charge, to any person obtaining a | |
7 | * copy of this software and associated documentation files (the "Software"), | 7 | * copy of this software and associated documentation files (the "Software"), | |
8 | * to deal in the Software without restriction, including without limitation | 8 | * to deal in the Software without restriction, including without limitation | |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
10 | * and/or sell copies of the Software, and to permit persons to whom the | 10 | * and/or sell copies of the Software, and to permit persons to whom the | |
11 | * Software is furnished to do so, subject to the following conditions: | 11 | * Software is furnished to do so, subject to the following conditions: | |
12 | * | 12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | 13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | 14 | * all copies or substantial portions of the Software. | |
15 | * | 15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
22 | * OTHER DEALINGS IN THE SOFTWARE. | 22 | * OTHER DEALINGS IN THE SOFTWARE. | |
23 | * | 23 | * | |
24 | * Authors: Ben Skeggs | 24 | * Authors: Ben Skeggs | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_drm.c,v 1.15 2018/08/27 15:22:54 riastradh Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_drm.c,v 1.16 2018/12/21 07:51:17 maya Exp $"); | |
29 | 29 | |||
30 | #include <linux/console.h> | 30 | #include <linux/console.h> | |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> | |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> | |
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> | |
34 | #include <linux/pm_runtime.h> | 34 | #include <linux/pm_runtime.h> | |
35 | #include <linux/vga_switcheroo.h> | 35 | #include <linux/vga_switcheroo.h> | |
36 | 36 | |||
37 | #include "drmP.h" | 37 | #include "drmP.h" | |
38 | #include "drm_crtc_helper.h" | 38 | #include "drm_crtc_helper.h" | |
39 | 39 | |||
40 | #include <core/gpuobj.h> | 40 | #include <core/gpuobj.h> | |
41 | #include <core/option.h> | 41 | #include <core/option.h> | |
@@ -944,52 +944,82 @@ nouveau_ioctls[] = { | @@ -944,52 +944,82 @@ nouveau_ioctls[] = { | |||
944 | DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 944 | DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | |
945 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | 945 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | |
946 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_AUTH|DRM_RENDER_ALLOW), | 946 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_AUTH|DRM_RENDER_ALLOW), | |
947 | DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | 947 | DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | |
948 | DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | 948 | DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW), | |
949 | DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_AUTH|DRM_RENDER_ALLOW), | 949 | DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_AUTH|DRM_RENDER_ALLOW), | |
950 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_AUTH|DRM_RENDER_ALLOW), | 950 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_AUTH|DRM_RENDER_ALLOW), | |
951 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_AUTH|DRM_RENDER_ALLOW), | 951 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_AUTH|DRM_RENDER_ALLOW), | |
952 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW), | 952 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW), | |
953 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW), | 953 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW), | |
954 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_AUTH|DRM_RENDER_ALLOW), | 954 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_AUTH|DRM_RENDER_ALLOW), | |
955 | }; | 955 | }; | |
956 | 956 | |||
957 | #ifndef __NetBSD__ /* XXX nouveau pm */ | 957 | #ifdef __NetBSD__ | |
958 | #include <sys/file.h> | |||
959 | #include <sys/ioccom.h> | |||
960 | static int /* XXX expose to ioc32 */ | |||
961 | nouveau_ioctl_override(struct file *fp, unsigned long cmd, void *data) | |||
962 | { | |||
963 | struct drm_file *file = fp->f_data; | |||
964 | struct drm_device *dev = file->minor->dev; | |||
965 | int ret; | |||
966 | ||||
967 | ret = pm_runtime_get_sync(dev->dev); | |||
968 | if (ret < 0 && ret != -EACCES) | |||
969 | return ret; | |||
970 | ||||
971 | switch (DRM_IOCTL_NR(cmd) - DRM_COMMAND_BASE) { | |||
972 | case DRM_NOUVEAU_NVIF: | |||
973 | /* XXX errno NetBSD->Linux */ | |||
974 | ret = -usif_ioctl(file, data, IOCPARM_LEN(cmd)); | |||
975 | break; | |||
976 | default: | |||
977 | ret = drm_ioctl(fp, cmd, data); | |||
978 | break; | |||
979 | } | |||
980 | ||||
981 | pm_runtime_mark_last_busy(dev->dev); | |||
982 | pm_runtime_put_autosuspend(dev->dev); | |||
983 | return ret; | |||
984 | } | |||
985 | #else | |||
958 | long | 986 | long | |
959 | nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 987 | nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |
960 | { | 988 | { | |
961 | struct drm_file *filp = file->private_data; | 989 | struct drm_file *filp = file->private_data; | |
962 | struct drm_device *dev = filp->minor->dev; | 990 | struct drm_device *dev = filp->minor->dev; | |
963 | long ret; | 991 | long ret; | |
964 | 992 | |||
965 | ret = pm_runtime_get_sync(dev->dev); | 993 | ret = pm_runtime_get_sync(dev->dev); | |
966 | if (ret < 0 && ret != -EACCES) | 994 | if (ret < 0 && ret != -EACCES) | |
967 | return ret; | 995 | return ret; | |
968 | 996 | |||
969 | switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) { | 997 | switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) { | |
970 | case DRM_NOUVEAU_NVIF: | 998 | case DRM_NOUVEAU_NVIF: | |
971 | ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd)); | 999 | ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd)); | |
972 | break; | 1000 | break; | |
973 | default: | 1001 | default: | |
974 | ret = drm_ioctl(file, cmd, arg); | 1002 | ret = drm_ioctl(file, cmd, arg); | |
975 | break; | 1003 | break; | |
976 | } | 1004 | } | |
977 | 1005 | |||
978 | pm_runtime_mark_last_busy(dev->dev); | 1006 | pm_runtime_mark_last_busy(dev->dev); | |
979 | pm_runtime_put_autosuspend(dev->dev); | 1007 | pm_runtime_put_autosuspend(dev->dev); | |
980 | return ret; | 1008 | return ret; | |
981 | } | 1009 | } | |
1010 | #endif | |||
982 | 1011 | |||
1012 | #ifndef __NetBSD__ | |||
983 | static const struct file_operations | 1013 | static const struct file_operations | |
984 | nouveau_driver_fops = { | 1014 | nouveau_driver_fops = { | |
985 | .owner = THIS_MODULE, | 1015 | .owner = THIS_MODULE, | |
986 | .open = drm_open, | 1016 | .open = drm_open, | |
987 | .release = drm_release, | 1017 | .release = drm_release, | |
988 | .unlocked_ioctl = nouveau_drm_ioctl, | 1018 | .unlocked_ioctl = nouveau_drm_ioctl, | |
989 | .mmap = nouveau_ttm_mmap, | 1019 | .mmap = nouveau_ttm_mmap, | |
990 | .poll = drm_poll, | 1020 | .poll = drm_poll, | |
991 | .read = drm_read, | 1021 | .read = drm_read, | |
992 | #if defined(CONFIG_COMPAT) | 1022 | #if defined(CONFIG_COMPAT) | |
993 | .compat_ioctl = nouveau_compat_ioctl, | 1023 | .compat_ioctl = nouveau_compat_ioctl, | |
994 | #endif | 1024 | #endif | |
995 | .llseek = noop_llseek, | 1025 | .llseek = noop_llseek, | |
@@ -1016,26 +1046,27 @@ driver_stub = { | @@ -1016,26 +1046,27 @@ driver_stub = { | |||
1016 | 1046 | |||
1017 | .get_vblank_counter = drm_vblank_no_hw_counter, | 1047 | .get_vblank_counter = drm_vblank_no_hw_counter, | |
1018 | .enable_vblank = nouveau_display_vblank_enable, | 1048 | .enable_vblank = nouveau_display_vblank_enable, | |
1019 | .disable_vblank = nouveau_display_vblank_disable, | 1049 | .disable_vblank = nouveau_display_vblank_disable, | |
1020 | .get_scanout_position = nouveau_display_scanoutpos, | 1050 | .get_scanout_position = nouveau_display_scanoutpos, | |
1021 | .get_vblank_timestamp = nouveau_display_vblstamp, | 1051 | .get_vblank_timestamp = nouveau_display_vblstamp, | |
1022 | 1052 | |||
1023 | .ioctls = nouveau_ioctls, | 1053 | .ioctls = nouveau_ioctls, | |
1024 | .num_ioctls = ARRAY_SIZE(nouveau_ioctls), | 1054 | .num_ioctls = ARRAY_SIZE(nouveau_ioctls), | |
1025 | #ifdef __NetBSD__ | 1055 | #ifdef __NetBSD__ | |
1026 | .fops = NULL, | 1056 | .fops = NULL, | |
1027 | .mmap_object = &nouveau_ttm_mmap_object, | 1057 | .mmap_object = &nouveau_ttm_mmap_object, | |
1028 | .gem_uvm_ops = &nouveau_gem_uvm_ops, | 1058 | .gem_uvm_ops = &nouveau_gem_uvm_ops, | |
1059 | .ioctl_override = nouveau_ioctl_override, | |||
1029 | #else | 1060 | #else | |
1030 | .fops = &nouveau_driver_fops, | 1061 | .fops = &nouveau_driver_fops, | |
1031 | #endif | 1062 | #endif | |
1032 | 1063 | |||
1033 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, | 1064 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, | |
1034 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, | 1065 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, | |
1035 | .gem_prime_export = drm_gem_prime_export, | 1066 | .gem_prime_export = drm_gem_prime_export, | |
1036 | .gem_prime_import = drm_gem_prime_import, | 1067 | .gem_prime_import = drm_gem_prime_import, | |
1037 | .gem_prime_pin = nouveau_gem_prime_pin, | 1068 | .gem_prime_pin = nouveau_gem_prime_pin, | |
1038 | .gem_prime_res_obj = nouveau_gem_prime_res_obj, | 1069 | .gem_prime_res_obj = nouveau_gem_prime_res_obj, | |
1039 | .gem_prime_unpin = nouveau_gem_prime_unpin, | 1070 | .gem_prime_unpin = nouveau_gem_prime_unpin, | |
1040 | .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table, | 1071 | .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table, | |
1041 | .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table, | 1072 | .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table, |
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c 2018/08/27 07:43:16 1.5
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c 2018/12/21 07:51:17 1.6
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: nouveau_usif.c,v 1.5 2018/08/27 07:43:16 riastradh Exp $ */ | 1 | /* $NetBSD: nouveau_usif.c,v 1.6 2018/12/21 07:51:17 maya Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2014 Red Hat Inc. | 4 | * Copyright 2014 Red Hat Inc. | |
5 | * | 5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | 6 | * Permission is hereby granted, free of charge, to any person obtaining a | |
7 | * copy of this software and associated documentation files (the "Software"), | 7 | * copy of this software and associated documentation files (the "Software"), | |
8 | * to deal in the Software without restriction, including without limitation | 8 | * to deal in the Software without restriction, including without limitation | |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
10 | * and/or sell copies of the Software, and to permit persons to whom the | 10 | * and/or sell copies of the Software, and to permit persons to whom the | |
11 | * Software is furnished to do so, subject to the following conditions: | 11 | * Software is furnished to do so, subject to the following conditions: | |
12 | * | 12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | 13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | 14 | * all copies or substantial portions of the Software. | |
15 | * | 15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
22 | * OTHER DEALINGS IN THE SOFTWARE. | 22 | * OTHER DEALINGS IN THE SOFTWARE. | |
23 | * | 23 | * | |
24 | * Authors: Ben Skeggs <bskeggs@redhat.com> | 24 | * Authors: Ben Skeggs <bskeggs@redhat.com> | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_usif.c,v 1.5 2018/08/27 07:43:16 riastradh Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_usif.c,v 1.6 2018/12/21 07:51:17 maya Exp $"); | |
29 | 29 | |||
30 | #include "nouveau_drm.h" | 30 | #include "nouveau_drm.h" | |
31 | #include "nouveau_usif.h" | 31 | #include "nouveau_usif.h" | |
32 | #include "nouveau_abi16.h" | 32 | #include "nouveau_abi16.h" | |
33 | 33 | |||
34 | #include <nvif/notify.h> | 34 | #include <nvif/notify.h> | |
35 | #include <nvif/unpack.h> | 35 | #include <nvif/unpack.h> | |
36 | #include <nvif/client.h> | 36 | #include <nvif/client.h> | |
37 | #include <nvif/event.h> | 37 | #include <nvif/event.h> | |
38 | #include <nvif/ioctl.h> | 38 | #include <nvif/ioctl.h> | |
39 | 39 | |||
40 | struct usif_notify_p { | 40 | struct usif_notify_p { | |
41 | struct drm_pending_event base; | 41 | struct drm_pending_event base; | |
@@ -295,43 +295,51 @@ usif_object_new(struct drm_file *f, void | @@ -295,43 +295,51 @@ usif_object_new(struct drm_file *f, void | |||
295 | args->v0.route = NVDRM_OBJECT_USIF; | 295 | args->v0.route = NVDRM_OBJECT_USIF; | |
296 | args->v0.token = (unsigned long)(void *)object; | 296 | args->v0.token = (unsigned long)(void *)object; | |
297 | ret = nvif_client_ioctl(client, argv, argc); | 297 | ret = nvif_client_ioctl(client, argv, argc); | |
298 | args->v0.token = object->token; | 298 | args->v0.token = object->token; | |
299 | args->v0.route = object->route; | 299 | args->v0.route = object->route; | |
300 | } | 300 | } | |
301 | 301 | |||
302 | if (ret) | 302 | if (ret) | |
303 | usif_object_dtor(object); | 303 | usif_object_dtor(object); | |
304 | return ret; | 304 | return ret; | |
305 | } | 305 | } | |
306 | 306 | |||
307 | int | 307 | int | |
308 | #ifdef __NetBSD__ | |||
309 | usif_ioctl(struct drm_file *filp, void *data, u32 argc) | |||
310 | #else | |||
308 | usif_ioctl(struct drm_file *filp, void __user *user, u32 argc) | 311 | usif_ioctl(struct drm_file *filp, void __user *user, u32 argc) | |
312 | #endif | |||
309 | { | 313 | { | |
310 | struct nouveau_cli *cli = nouveau_cli(filp); | 314 | struct nouveau_cli *cli = nouveau_cli(filp); | |
311 | struct nvif_client *client = &cli->base; | 315 | struct nvif_client *client = &cli->base; | |
316 | #ifndef __NetBSD__ | |||
312 | void *data = kmalloc(argc, GFP_KERNEL); | 317 | void *data = kmalloc(argc, GFP_KERNEL); | |
318 | #endif | |||
313 | u32 size = argc; | 319 | u32 size = argc; | |
314 | union { | 320 | union { | |
315 | struct nvif_ioctl_v0 v0; | 321 | struct nvif_ioctl_v0 v0; | |
316 | } *argv = data; | 322 | } *argv = data; | |
317 | struct usif_object *object; | 323 | struct usif_object *object; | |
318 | u8 owner; | 324 | u8 owner; | |
319 | int ret; | 325 | int ret; | |
320 | 326 | |||
327 | #ifndef __NetBSD__ | |||
321 | if (ret = -ENOMEM, !argv) | 328 | if (ret = -ENOMEM, !argv) | |
322 | goto done; | 329 | goto done; | |
323 | if (ret = -EFAULT, copy_from_user(argv, user, size)) | 330 | if (ret = -EFAULT, copy_from_user(argv, user, size)) | |
324 | goto done; | 331 | goto done; | |
332 | #endif | |||
325 | 333 | |||
326 | if (nvif_unpack(argv->v0, 0, 0, true)) { | 334 | if (nvif_unpack(argv->v0, 0, 0, true)) { | |
327 | /* block access to objects not created via this interface */ | 335 | /* block access to objects not created via this interface */ | |
328 | owner = argv->v0.owner; | 336 | owner = argv->v0.owner; | |
329 | if (argv->v0.object == 0ULL && | 337 | if (argv->v0.object == 0ULL && | |
330 | argv->v0.type != NVIF_IOCTL_V0_DEL) | 338 | argv->v0.type != NVIF_IOCTL_V0_DEL) | |
331 | argv->v0.owner = NVDRM_OBJECT_ANY; /* except client */ | 339 | argv->v0.owner = NVDRM_OBJECT_ANY; /* except client */ | |
332 | else | 340 | else | |
333 | argv->v0.owner = NVDRM_OBJECT_USIF; | 341 | argv->v0.owner = NVDRM_OBJECT_USIF; | |
334 | } else | 342 | } else | |
335 | goto done; | 343 | goto done; | |
336 | 344 | |||
337 | /* USIF slightly abuses some return-only ioctl members in order | 345 | /* USIF slightly abuses some return-only ioctl members in order | |
@@ -375,30 +383,34 @@ usif_ioctl(struct drm_file *filp, void _ | @@ -375,30 +383,34 @@ usif_ioctl(struct drm_file *filp, void _ | |||
375 | argv->v0.route = object->route; | 383 | argv->v0.route = object->route; | |
376 | argv->v0.token = object->token; | 384 | argv->v0.token = object->token; | |
377 | if (ret == 0 && argv->v0.type == NVIF_IOCTL_V0_DEL) { | 385 | if (ret == 0 && argv->v0.type == NVIF_IOCTL_V0_DEL) { | |
378 | list_del(&object->head); | 386 | list_del(&object->head); | |
379 | kfree(object); | 387 | kfree(object); | |
380 | } | 388 | } | |
381 | } else { | 389 | } else { | |
382 | argv->v0.route = NVIF_IOCTL_V0_ROUTE_HIDDEN; | 390 | argv->v0.route = NVIF_IOCTL_V0_ROUTE_HIDDEN; | |
383 | argv->v0.token = 0; | 391 | argv->v0.token = 0; | |
384 | } | 392 | } | |
385 | argv->v0.owner = owner; | 393 | argv->v0.owner = owner; | |
386 | mutex_unlock(&cli->mutex); | 394 | mutex_unlock(&cli->mutex); | |
387 | 395 | |||
396 | #ifndef __NetBSD__ | |||
388 | if (copy_to_user(user, argv, argc)) | 397 | if (copy_to_user(user, argv, argc)) | |
389 | ret = -EFAULT; | 398 | ret = -EFAULT; | |
399 | #endif | |||
390 | done: | 400 | done: | |
401 | #ifndef __NetBSD__ | |||
391 | kfree(argv); | 402 | kfree(argv); | |
403 | #endif | |||
392 | return ret; | 404 | return ret; | |
393 | } | 405 | } | |
394 | 406 | |||
395 | void | 407 | void | |
396 | usif_client_fini(struct nouveau_cli *cli) | 408 | usif_client_fini(struct nouveau_cli *cli) | |
397 | { | 409 | { | |
398 | struct usif_object *object, *otemp; | 410 | struct usif_object *object, *otemp; | |
399 | struct usif_notify *notify, *ntemp; | 411 | struct usif_notify *notify, *ntemp; | |
400 | 412 | |||
401 | list_for_each_entry_safe(notify, ntemp, &cli->notifys, head) { | 413 | list_for_each_entry_safe(notify, ntemp, &cli->notifys, head) { | |
402 | usif_notify_dtor(notify); | 414 | usif_notify_dtor(notify); | |
403 | } | 415 | } | |
404 | 416 |
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.h 2018/08/27 04:58:24 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.h 2018/12/21 07:51:17 1.3
@@ -1,11 +1,15 @@ | @@ -1,11 +1,15 @@ | |||
1 | /* $NetBSD: nouveau_usif.h,v 1.2 2018/08/27 04:58:24 riastradh Exp $ */ | 1 | /* $NetBSD: nouveau_usif.h,v 1.3 2018/12/21 07:51:17 maya Exp $ */ | |
2 | 2 | |||
3 | #ifndef __NOUVEAU_USIF_H__ | 3 | #ifndef __NOUVEAU_USIF_H__ | |
4 | #define __NOUVEAU_USIF_H__ | 4 | #define __NOUVEAU_USIF_H__ | |
5 | 5 | |||
6 | void usif_client_init(struct nouveau_cli *); | 6 | void usif_client_init(struct nouveau_cli *); | |
7 | void usif_client_fini(struct nouveau_cli *); | 7 | void usif_client_fini(struct nouveau_cli *); | |
8 | #ifdef __NetBSD__ | |||
9 | int usif_ioctl(struct drm_file *, void *, u32); | |||
10 | #else | |||
8 | int usif_ioctl(struct drm_file *, void __user *, u32); | 11 | int usif_ioctl(struct drm_file *, void __user *, u32); | |
12 | #endif | |||
9 | int usif_notify(const void *, u32, const void *, u32); | 13 | int usif_notify(const void *, u32, const void *, u32); | |
10 | 14 | |||
11 | #endif | 15 | #endif |
--- src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2018/08/28 03:41:39 1.34
+++ src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2018/12/21 07:51:18 1.35
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drmP.h,v 1.34 2018/08/28 03:41:39 riastradh Exp $ */ | 1 | /* $NetBSD: drmP.h,v 1.35 2018/12/21 07:51:18 maya Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Internal Header for the Direct Rendering Manager | 4 | * Internal Header for the Direct Rendering Manager | |
5 | * | 5 | * | |
6 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | 6 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | |
7 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | 7 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | |
8 | * Copyright (c) 2009-2010, Code Aurora Forum. | 8 | * Copyright (c) 2009-2010, Code Aurora Forum. | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
10 | * | 10 | * | |
11 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> | 11 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> | |
12 | * Author: Gareth Hughes <gareth@valinux.com> | 12 | * Author: Gareth Hughes <gareth@valinux.com> | |
13 | * | 13 | * | |
14 | * Permission is hereby granted, free of charge, to any person obtaining a | 14 | * Permission is hereby granted, free of charge, to any person obtaining a | |
@@ -700,26 +700,30 @@ struct drm_driver { | @@ -700,26 +700,30 @@ struct drm_driver { | |||
700 | int major; | 700 | int major; | |
701 | int minor; | 701 | int minor; | |
702 | int patchlevel; | 702 | int patchlevel; | |
703 | const char *name; | 703 | const char *name; | |
704 | const char *desc; | 704 | const char *desc; | |
705 | const char *date; | 705 | const char *date; | |
706 | 706 | |||
707 | u32 driver_features; | 707 | u32 driver_features; | |
708 | int dev_priv_size; | 708 | int dev_priv_size; | |
709 | const struct drm_ioctl_desc *ioctls; | 709 | const struct drm_ioctl_desc *ioctls; | |
710 | int num_ioctls; | 710 | int num_ioctls; | |
711 | const struct file_operations *fops; | 711 | const struct file_operations *fops; | |
712 | 712 | |||
713 | #ifdef __NetBSD__ | |||
714 | int (*ioctl_override)(struct file *, unsigned long, void *); | |||
715 | #endif | |||
716 | ||||
713 | /* List of devices hanging off this driver with stealth attach. */ | 717 | /* List of devices hanging off this driver with stealth attach. */ | |
714 | struct list_head legacy_dev_list; | 718 | struct list_head legacy_dev_list; | |
715 | }; | 719 | }; | |
716 | 720 | |||
717 | enum drm_minor_type { | 721 | enum drm_minor_type { | |
718 | DRM_MINOR_LEGACY, | 722 | DRM_MINOR_LEGACY, | |
719 | DRM_MINOR_CONTROL, | 723 | DRM_MINOR_CONTROL, | |
720 | DRM_MINOR_RENDER, | 724 | DRM_MINOR_RENDER, | |
721 | DRM_MINOR_CNT, | 725 | DRM_MINOR_CNT, | |
722 | }; | 726 | }; | |
723 | 727 | |||
724 | #ifdef __NetBSD__ /* XXX debugfs */ | 728 | #ifdef __NetBSD__ /* XXX debugfs */ | |
725 | struct seq_file; | 729 | struct seq_file; |
--- src/sys/external/bsd/drm2/drm/drm_cdevsw.c 2018/08/28 03:41:39 1.12
+++ src/sys/external/bsd/drm2/drm/drm_cdevsw.c 2018/12/21 07:51:18 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_cdevsw.c,v 1.12 2018/08/28 03:41:39 riastradh Exp $ */ | 1 | /* $NetBSD: drm_cdevsw.c,v 1.13 2018/12/21 07:51:18 maya Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.12 2018/08/28 03:41:39 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.13 2018/12/21 07:51:18 maya Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> | |
37 | #include <sys/conf.h> | 37 | #include <sys/conf.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | #include <sys/file.h> | 39 | #include <sys/file.h> | |
40 | #include <sys/filedesc.h> | 40 | #include <sys/filedesc.h> | |
41 | #include <sys/ioccom.h> | 41 | #include <sys/ioccom.h> | |
42 | #include <sys/kauth.h> | 42 | #include <sys/kauth.h> | |
43 | #ifndef _MODULE | 43 | #ifndef _MODULE | |
44 | /* XXX Mega-kludge because modules are broken. */ | 44 | /* XXX Mega-kludge because modules are broken. */ | |
45 | #include <sys/once.h> | 45 | #include <sys/once.h> | |
46 | #endif | 46 | #endif | |
@@ -60,26 +60,27 @@ __KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c | @@ -60,26 +60,27 @@ __KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c | |||
60 | #include <drm/drmP.h> | 60 | #include <drm/drmP.h> | |
61 | #include <drm/drm_internal.h> | 61 | #include <drm/drm_internal.h> | |
62 | #include "../dist/drm/drm_legacy.h" | 62 | #include "../dist/drm/drm_legacy.h" | |
63 | 63 | |||
64 | static dev_type_open(drm_open); | 64 | static dev_type_open(drm_open); | |
65 | 65 | |||
66 | static int drm_firstopen(struct drm_device *); | 66 | static int drm_firstopen(struct drm_device *); | |
67 | 67 | |||
68 | static int drm_close(struct file *); | 68 | static int drm_close(struct file *); | |
69 | static int drm_read(struct file *, off_t *, struct uio *, kauth_cred_t, | 69 | static int drm_read(struct file *, off_t *, struct uio *, kauth_cred_t, | |
70 | int); | 70 | int); | |
71 | static int drm_dequeue_event(struct drm_file *, size_t, | 71 | static int drm_dequeue_event(struct drm_file *, size_t, | |
72 | struct drm_pending_event **, int); | 72 | struct drm_pending_event **, int); | |
73 | static int drm_ioctl_shim(struct file *, unsigned long, void *); | |||
73 | static int drm_poll(struct file *, int); | 74 | static int drm_poll(struct file *, int); | |
74 | static int drm_kqfilter(struct file *, struct knote *); | 75 | static int drm_kqfilter(struct file *, struct knote *); | |
75 | static int drm_stat(struct file *, struct stat *); | 76 | static int drm_stat(struct file *, struct stat *); | |
76 | static int drm_fop_mmap(struct file *, off_t *, size_t, int, int *, int *, | 77 | static int drm_fop_mmap(struct file *, off_t *, size_t, int, int *, int *, | |
77 | struct uvm_object **, int *); | 78 | struct uvm_object **, int *); | |
78 | static paddr_t drm_legacy_mmap(dev_t, off_t, int); | 79 | static paddr_t drm_legacy_mmap(dev_t, off_t, int); | |
79 | 80 | |||
80 | const struct cdevsw drm_cdevsw = { | 81 | const struct cdevsw drm_cdevsw = { | |
81 | .d_open = drm_open, | 82 | .d_open = drm_open, | |
82 | .d_close = noclose, | 83 | .d_close = noclose, | |
83 | .d_read = noread, | 84 | .d_read = noread, | |
84 | .d_write = nowrite, | 85 | .d_write = nowrite, | |
85 | .d_ioctl = noioctl, | 86 | .d_ioctl = noioctl, | |
@@ -88,27 +89,27 @@ const struct cdevsw drm_cdevsw = { | @@ -88,27 +89,27 @@ const struct cdevsw drm_cdevsw = { | |||
88 | .d_poll = nopoll, | 89 | .d_poll = nopoll, | |
89 | .d_mmap = drm_legacy_mmap, | 90 | .d_mmap = drm_legacy_mmap, | |
90 | .d_kqfilter = nokqfilter, | 91 | .d_kqfilter = nokqfilter, | |
91 | .d_discard = nodiscard, | 92 | .d_discard = nodiscard, | |
92 | /* XXX was D_TTY | D_NEGOFFSAFE */ | 93 | /* XXX was D_TTY | D_NEGOFFSAFE */ | |
93 | /* XXX Add D_MPSAFE some day... */ | 94 | /* XXX Add D_MPSAFE some day... */ | |
94 | .d_flag = D_NEGOFFSAFE, | 95 | .d_flag = D_NEGOFFSAFE, | |
95 | }; | 96 | }; | |
96 | 97 | |||
97 | static const struct fileops drm_fileops = { | 98 | static const struct fileops drm_fileops = { | |
98 | .fo_name = "drm", | 99 | .fo_name = "drm", | |
99 | .fo_read = drm_read, | 100 | .fo_read = drm_read, | |
100 | .fo_write = fbadop_write, | 101 | .fo_write = fbadop_write, | |
101 | .fo_ioctl = drm_ioctl, | 102 | .fo_ioctl = drm_ioctl_shim, | |
102 | .fo_fcntl = fnullop_fcntl, | 103 | .fo_fcntl = fnullop_fcntl, | |
103 | .fo_poll = drm_poll, | 104 | .fo_poll = drm_poll, | |
104 | .fo_stat = drm_stat, | 105 | .fo_stat = drm_stat, | |
105 | .fo_close = drm_close, | 106 | .fo_close = drm_close, | |
106 | .fo_kqfilter = drm_kqfilter, | 107 | .fo_kqfilter = drm_kqfilter, | |
107 | .fo_restart = fnullop_restart, | 108 | .fo_restart = fnullop_restart, | |
108 | .fo_mmap = drm_fop_mmap, | 109 | .fo_mmap = drm_fop_mmap, | |
109 | }; | 110 | }; | |
110 | 111 | |||
111 | static int | 112 | static int | |
112 | drm_open(dev_t d, int flags, int fmt, struct lwp *l) | 113 | drm_open(dev_t d, int flags, int fmt, struct lwp *l) | |
113 | { | 114 | { | |
114 | struct drm_minor *dminor; | 115 | struct drm_minor *dminor; | |
@@ -330,26 +331,38 @@ drm_dequeue_event(struct drm_file *file, | @@ -330,26 +331,38 @@ drm_dequeue_event(struct drm_file *file, | |||
330 | ret = 0; | 331 | ret = 0; | |
331 | goto out; | 332 | goto out; | |
332 | } | 333 | } | |
333 | 334 | |||
334 | file->event_space += event->event->length; | 335 | file->event_space += event->event->length; | |
335 | list_del(&event->link); | 336 | list_del(&event->link); | |
336 | 337 | |||
337 | out: spin_unlock_irqrestore(&dev->event_lock, irqflags); | 338 | out: spin_unlock_irqrestore(&dev->event_lock, irqflags); | |
338 | *eventp = event; | 339 | *eventp = event; | |
339 | return ret; | 340 | return ret; | |
340 | } | 341 | } | |
341 | 342 | |||
342 | static int | 343 | static int | |
344 | drm_ioctl_shim(struct file *fp, unsigned long cmd, void *data) | |||
345 | { | |||
346 | struct drm_file *file = fp->f_data; | |||
347 | struct drm_driver *driver = file->minor->dev->driver; | |||
348 | ||||
349 | if (driver->ioctl_override) | |||
350 | return driver->ioctl_override(fp, cmd, data); | |||
351 | else | |||
352 | return drm_ioctl(fp, cmd, data); | |||
353 | } | |||
354 | ||||
355 | static int | |||
343 | drm_poll(struct file *fp __unused, int events __unused) | 356 | drm_poll(struct file *fp __unused, int events __unused) | |
344 | { | 357 | { | |
345 | struct drm_file *const file = fp->f_data; | 358 | struct drm_file *const file = fp->f_data; | |
346 | struct drm_device *const dev = file->minor->dev; | 359 | struct drm_device *const dev = file->minor->dev; | |
347 | int revents = 0; | 360 | int revents = 0; | |
348 | unsigned long irqflags; | 361 | unsigned long irqflags; | |
349 | 362 | |||
350 | if (!ISSET(events, (POLLIN | POLLRDNORM))) | 363 | if (!ISSET(events, (POLLIN | POLLRDNORM))) | |
351 | return 0; | 364 | return 0; | |
352 | 365 | |||
353 | spin_lock_irqsave(&dev->event_lock, irqflags); | 366 | spin_lock_irqsave(&dev->event_lock, irqflags); | |
354 | if (list_empty(&file->event_list)) | 367 | if (list_empty(&file->event_list)) | |
355 | selrecord(curlwp, &file->event_selq); | 368 | selrecord(curlwp, &file->event_selq); |