Mon Aug 27 07:35:57 2018 UTC ()
Kludge to pass bus_space_tag through nvif mappings.

- New `ioctl' NVIF_IOCTL_V0_MAP_NETBSD returns bus_space_tag_t too.
  . Blocked from userland.  (Would only disclose a kernel virtual
    address, so not terribly serious.)
- struct nvif_driver::map function takes bus_sapce_tag, returns
  bus_space_handle in addition to kva pointer.
- struct nvif_driver::unmap function takes bus_space_tag and
  bus_space_handle rather than kva pointer.
- Teach various nvkm object types to return bus space tags too.
- Map them all with BUS_SPACE_MAP_LINEAR so the vaddr works.

XXX The fifo channel might need to be mapped with a subregion.
XXX What to do?


(riastradh)
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nvif.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c
diff -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h
diff -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/ioctl.h
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvif/nouveau_nvif_object.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_ioctl.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_oproxy.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_user.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_channv50.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/fifo/nouveau_nvkm_engine_fifo_chan.c

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nvif.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nvif.c 2018/08/27 04:58:24 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nvif.c 2018/08/27 07:35:56 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nouveau_nvif.c,v 1.2 2018/08/27 04:58:24 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvif.c,v 1.3 2018/08/27 07:35:56 riastradh 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.
@@ -19,52 +19,77 @@ @@ -19,52 +19,77 @@
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/******************************************************************************* 27/*******************************************************************************
28 * NVIF client driver - NVKM directly linked 28 * NVIF client driver - NVKM directly linked
29 ******************************************************************************/ 29 ******************************************************************************/
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: nouveau_nvif.c,v 1.2 2018/08/27 04:58:24 riastradh Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: nouveau_nvif.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
33 33
34#include <core/client.h> 34#include <core/client.h>
35#include <core/notify.h> 35#include <core/notify.h>
36#include <core/ioctl.h> 36#include <core/ioctl.h>
37 37
38#include <nvif/client.h> 38#include <nvif/client.h>
39#include <nvif/driver.h> 39#include <nvif/driver.h>
40#include <nvif/notify.h> 40#include <nvif/notify.h>
41#include <nvif/event.h> 41#include <nvif/event.h>
42#include <nvif/ioctl.h> 42#include <nvif/ioctl.h>
43 43
44#include "nouveau_drm.h" 44#include "nouveau_drm.h"
45#include "nouveau_usif.h" 45#include "nouveau_usif.h"
46 46
 47#ifdef __NetBSD__
 48#define __iomem __nvif_iomem
 49static int
 50nvkm_client_map(void *priv, bus_space_tag_t tag, u64 busaddr, u32 size,
 51 bus_space_handle_t *handlep, void __iomem **ptrp)
 52{
 53 int ret;
 54
 55 ret = -bus_space_map(tag, busaddr, size, BUS_SPACE_MAP_LINEAR,
 56 handlep);
 57 if (ret)
 58 return ret;
 59 *ptrp = bus_space_vaddr(tag, *handlep);
 60 return 0;
 61}
 62
 63static void
 64nvkm_client_unmap(void *priv, bus_space_tag_t tag, bus_space_handle_t handle,
 65 u32 size)
 66{
 67
 68 bus_space_unmap(tag, handle, size);
 69}
 70#else
47static void 71static void
48nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size) 72nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
49{ 73{
50 iounmap(ptr); 74 iounmap(ptr);
51} 75}
52 76
53static void __iomem * 77static void __iomem *
54nvkm_client_map(void *priv, u64 handle, u32 size) 78nvkm_client_map(void *priv, u64 handle, u32 size)
55{ 79{
56 return ioremap(handle, size); 80 return ioremap(handle, size);
57} 81}
 82#endif
58 83
59static int 84static int
60nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack) 85nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
61{ 86{
62 return nvkm_ioctl(priv, super, data, size, hack); 87 return nvkm_ioctl(priv, super, data, size, hack);
63} 88}
64 89
65static int 90static int
66nvkm_client_resume(void *priv) 91nvkm_client_resume(void *priv)
67{ 92{
68 return nvkm_client_init(priv); 93 return nvkm_client_init(priv);
69} 94}
70 95

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c 2018/08/27 04:58:24 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_usif.c 2018/08/27 07:35:56 1.3
@@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
1/* $NetBSD: nouveau_usif.c,v 1.2 2018/08/27 04:58:24 riastradh Exp $ */ 1/* $NetBSD: nouveau_usif.c,v 1.3 2018/08/27 07:35:56 riastradh 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.2 2018/08/27 04:58:24 riastradh Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: nouveau_usif.c,v 1.3 2018/08/27 07:35:56 riastradh 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
40struct usif_notify_p { 40struct usif_notify_p {
41 struct drm_pending_event base; 41 struct drm_pending_event base;
@@ -345,26 +345,29 @@ usif_ioctl(struct drm_file *filp, void _ @@ -345,26 +345,29 @@ usif_ioctl(struct drm_file *filp, void _
345 break; 345 break;
346 case NVIF_IOCTL_V0_NTFY_NEW: 346 case NVIF_IOCTL_V0_NTFY_NEW:
347 ret = usif_notify_new(filp, data, size, argv, argc); 347 ret = usif_notify_new(filp, data, size, argv, argc);
348 break; 348 break;
349 case NVIF_IOCTL_V0_NTFY_DEL: 349 case NVIF_IOCTL_V0_NTFY_DEL:
350 ret = usif_notify_del(filp, data, size, argv, argc); 350 ret = usif_notify_del(filp, data, size, argv, argc);
351 break; 351 break;
352 case NVIF_IOCTL_V0_NTFY_GET: 352 case NVIF_IOCTL_V0_NTFY_GET:
353 ret = usif_notify_get(filp, data, size, argv, argc); 353 ret = usif_notify_get(filp, data, size, argv, argc);
354 break; 354 break;
355 case NVIF_IOCTL_V0_NTFY_PUT: 355 case NVIF_IOCTL_V0_NTFY_PUT:
356 ret = usif_notify_put(filp, data, size, argv, argc); 356 ret = usif_notify_put(filp, data, size, argv, argc);
357 break; 357 break;
 358 case NVIF_IOCTL_V0_MAP_NETBSD:
 359 /* Kernel-only kludge. */
 360 ret = -EINVAL;
358 default: 361 default:
359 ret = nvif_client_ioctl(client, argv, argc); 362 ret = nvif_client_ioctl(client, argv, argc);
360 break; 363 break;
361 } 364 }
362 if (argv->v0.route == NVDRM_OBJECT_USIF) { 365 if (argv->v0.route == NVDRM_OBJECT_USIF) {
363 object = (void *)(unsigned long)argv->v0.token; 366 object = (void *)(unsigned long)argv->v0.token;
364 argv->v0.route = object->route; 367 argv->v0.route = object->route;
365 argv->v0.token = object->token; 368 argv->v0.token = object->token;
366 if (ret == 0 && argv->v0.type == NVIF_IOCTL_V0_DEL) { 369 if (ret == 0 && argv->v0.type == NVIF_IOCTL_V0_DEL) {
367 list_del(&object->head); 370 list_del(&object->head);
368 kfree(object); 371 kfree(object);
369 } 372 }
370 } else { 373 } else {

cvs diff -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h 2018/08/27 07:32:59 1.3
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/driver.h 2018/08/27 07:35:56 1.4
@@ -1,33 +1,40 @@ @@ -1,33 +1,40 @@
1/* $NetBSD: driver.h,v 1.3 2018/08/27 07:32:59 riastradh Exp $ */ 1/* $NetBSD: driver.h,v 1.4 2018/08/27 07:35:56 riastradh Exp $ */
2 2
3#ifndef __NVIF_DRIVER_H__ 3#ifndef __NVIF_DRIVER_H__
4#define __NVIF_DRIVER_H__ 4#define __NVIF_DRIVER_H__
5 5
6#ifdef __NetBSD__ 6#ifdef __NetBSD__
7# define __nvif_iomem volatile 7# define __nvif_iomem volatile
8# define __iomem __nvif_iomem 8# define __iomem __nvif_iomem
9#endif 9#endif
10 10
11struct nvif_driver { 11struct nvif_driver {
12 const char *name; 12 const char *name;
13 int (*init)(const char *name, u64 device, const char *cfg, 13 int (*init)(const char *name, u64 device, const char *cfg,
14 const char *dbg, void **priv); 14 const char *dbg, void **priv);
15 void (*fini)(void *priv); 15 void (*fini)(void *priv);
16 int (*suspend)(void *priv); 16 int (*suspend)(void *priv);
17 int (*resume)(void *priv); 17 int (*resume)(void *priv);
18 int (*ioctl)(void *priv, bool super, void *data, u32 size, void **hack); 18 int (*ioctl)(void *priv, bool super, void *data, u32 size, void **hack);
 19#ifdef __NetBSD__
 20 int (*map)(void *priv, bus_space_tag_t tag, u64 handle, u32 size,
 21 bus_space_handle_t *handlep, void __iomem **ptrp);
 22 void (*unmap)(void *priv, bus_space_tag_t tag,
 23 bus_space_handle_t handle, u32 size);
 24#else
19 void __iomem *(*map)(void *priv, u64 handle, u32 size); 25 void __iomem *(*map)(void *priv, u64 handle, u32 size);
20 void (*unmap)(void *priv, void __iomem *ptr, u32 size); 26 void (*unmap)(void *priv, void __iomem *ptr, u32 size);
 27#endif
21 bool keep; 28 bool keep;
22}; 29};
23 30
24#ifdef __NetBSD__ 31#ifdef __NetBSD__
25# undef __iomem 32# undef __iomem
26#endif 33#endif
27 34
28extern const struct nvif_driver nvif_driver_nvkm; 35extern const struct nvif_driver nvif_driver_nvkm;
29extern const struct nvif_driver nvif_driver_drm; 36extern const struct nvif_driver nvif_driver_drm;
30extern const struct nvif_driver nvif_driver_lib; 37extern const struct nvif_driver nvif_driver_lib;
31extern const struct nvif_driver nvif_driver_null; 38extern const struct nvif_driver nvif_driver_null;
32 39
33#endif 40#endif

cvs diff -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h 2018/08/27 07:32:59 1.3
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h 2018/08/27 07:35:56 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: object.h,v 1.3 2018/08/27 07:32:59 riastradh Exp $ */ 1/* $NetBSD: object.h,v 1.4 2018/08/27 07:35:56 riastradh Exp $ */
2 2
3#ifndef __NVIF_OBJECT_H__ 3#ifndef __NVIF_OBJECT_H__
4#define __NVIF_OBJECT_H__ 4#define __NVIF_OBJECT_H__
5 5
6#include <nvif/os.h> 6#include <nvif/os.h>
7 7
8struct nvif_sclass { 8struct nvif_sclass {
9 s32 oclass; 9 s32 oclass;
10 int minver; 10 int minver;
11 int maxver; 11 int maxver;
12}; 12};
13 13
14#ifdef __NetBSD__ 14#ifdef __NetBSD__
@@ -57,26 +57,30 @@ static inline void @@ -57,26 +57,30 @@ static inline void
57iowrite32(uint32_t v, void __iomem *p) 57iowrite32(uint32_t v, void __iomem *p)
58{ 58{
59 membar_producer(); 59 membar_producer();
60 *(uint32_t __iomem *)p = v; 60 *(uint32_t __iomem *)p = v;
61} 61}
62#endif 62#endif
63 63
64struct nvif_object { 64struct nvif_object {
65 struct nvif_client *client; 65 struct nvif_client *client;
66 u32 handle; 66 u32 handle;
67 s32 oclass; 67 s32 oclass;
68 void *priv; /*XXX: hack */ 68 void *priv; /*XXX: hack */
69 struct { 69 struct {
 70#ifdef __NetBSD__
 71 bus_space_tag_t tag;
 72 bus_space_handle_t handle;
 73#endif
70 void __iomem *ptr; 74 void __iomem *ptr;
71 u32 size; 75 u32 size;
72 } map; 76 } map;
73}; 77};
74 78
75int nvif_object_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32, 79int nvif_object_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32,
76 struct nvif_object *); 80 struct nvif_object *);
77void nvif_object_fini(struct nvif_object *); 81void nvif_object_fini(struct nvif_object *);
78int nvif_object_ioctl(struct nvif_object *, void *, u32, void **); 82int nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
79int nvif_object_sclass_get(struct nvif_object *, struct nvif_sclass **); 83int nvif_object_sclass_get(struct nvif_object *, struct nvif_sclass **);
80void nvif_object_sclass_put(struct nvif_sclass **); 84void nvif_object_sclass_put(struct nvif_sclass **);
81u32 nvif_object_rd(struct nvif_object *, int, u64); 85u32 nvif_object_rd(struct nvif_object *, int, u64);
82void nvif_object_wr(struct nvif_object *, int, u64, u32); 86void nvif_object_wr(struct nvif_object *, int, u64, u32);

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/ioctl.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/ioctl.h 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/ioctl.h 2018/08/27 07:35:56 1.3
@@ -1,35 +1,36 @@ @@ -1,35 +1,36 @@
1/* $NetBSD: ioctl.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: ioctl.h,v 1.3 2018/08/27 07:35:56 riastradh Exp $ */
2 2
3#ifndef __NVIF_IOCTL_H__ 3#ifndef __NVIF_IOCTL_H__
4#define __NVIF_IOCTL_H__ 4#define __NVIF_IOCTL_H__
5 5
6#define NVIF_VERSION_LATEST 0x0000000000000000ULL 6#define NVIF_VERSION_LATEST 0x0000000000000000ULL
7 7
8struct nvif_ioctl_v0 { 8struct nvif_ioctl_v0 {
9 __u8 version; 9 __u8 version;
10#define NVIF_IOCTL_V0_NOP 0x00 10#define NVIF_IOCTL_V0_NOP 0x00
11#define NVIF_IOCTL_V0_SCLASS 0x01 11#define NVIF_IOCTL_V0_SCLASS 0x01
12#define NVIF_IOCTL_V0_NEW 0x02 12#define NVIF_IOCTL_V0_NEW 0x02
13#define NVIF_IOCTL_V0_DEL 0x03 13#define NVIF_IOCTL_V0_DEL 0x03
14#define NVIF_IOCTL_V0_MTHD 0x04 14#define NVIF_IOCTL_V0_MTHD 0x04
15#define NVIF_IOCTL_V0_RD 0x05 15#define NVIF_IOCTL_V0_RD 0x05
16#define NVIF_IOCTL_V0_WR 0x06 16#define NVIF_IOCTL_V0_WR 0x06
17#define NVIF_IOCTL_V0_MAP 0x07 17#define NVIF_IOCTL_V0_MAP 0x07
18#define NVIF_IOCTL_V0_UNMAP 0x08 18#define NVIF_IOCTL_V0_UNMAP 0x08
19#define NVIF_IOCTL_V0_NTFY_NEW 0x09 19#define NVIF_IOCTL_V0_NTFY_NEW 0x09
20#define NVIF_IOCTL_V0_NTFY_DEL 0x0a 20#define NVIF_IOCTL_V0_NTFY_DEL 0x0a
21#define NVIF_IOCTL_V0_NTFY_GET 0x0b 21#define NVIF_IOCTL_V0_NTFY_GET 0x0b
22#define NVIF_IOCTL_V0_NTFY_PUT 0x0c 22#define NVIF_IOCTL_V0_NTFY_PUT 0x0c
 23#define NVIF_IOCTL_V0_MAP_NETBSD 0x0d
23 __u8 type; 24 __u8 type;
24 __u8 pad02[4]; 25 __u8 pad02[4];
25#define NVIF_IOCTL_V0_OWNER_NVIF 0x00 26#define NVIF_IOCTL_V0_OWNER_NVIF 0x00
26#define NVIF_IOCTL_V0_OWNER_ANY 0xff 27#define NVIF_IOCTL_V0_OWNER_ANY 0xff
27 __u8 owner; 28 __u8 owner;
28#define NVIF_IOCTL_V0_ROUTE_NVIF 0x00 29#define NVIF_IOCTL_V0_ROUTE_NVIF 0x00
29#define NVIF_IOCTL_V0_ROUTE_HIDDEN 0xff 30#define NVIF_IOCTL_V0_ROUTE_HIDDEN 0xff
30 __u8 route; 31 __u8 route;
31 __u64 token; 32 __u64 token;
32 __u64 object; 33 __u64 object;
33 __u8 data[]; /* ioctl data (below) */ 34 __u8 data[]; /* ioctl data (below) */
34}; 35};
35 36
@@ -88,26 +89,39 @@ struct nvif_ioctl_wr_v0 { @@ -88,26 +89,39 @@ struct nvif_ioctl_wr_v0 {
88 __u8 pad02[2]; 89 __u8 pad02[2];
89 __u32 data; 90 __u32 data;
90 __u64 addr; 91 __u64 addr;
91}; 92};
92 93
93struct nvif_ioctl_map_v0 { 94struct nvif_ioctl_map_v0 {
94 /* nvif_ioctl ... */ 95 /* nvif_ioctl ... */
95 __u8 version; 96 __u8 version;
96 __u8 pad01[3]; 97 __u8 pad01[3];
97 __u32 length; 98 __u32 length;
98 __u64 handle; 99 __u64 handle;
99}; 100};
100 101
 102#ifdef __NetBSD__
 103/* XXX Kludge for NetBSD kernel-only use. */
 104#include <sys/bus.h>
 105struct nvif_ioctl_map_netbsd_v0 {
 106 /* nvif_ioctl ... */
 107 __u8 version;
 108 __u8 pad01[3];
 109 bus_space_tag_t tag;
 110 __u32 length;
 111 __u64 handle;
 112};
 113#endif
 114
101struct nvif_ioctl_unmap { 115struct nvif_ioctl_unmap {
102}; 116};
103 117
104struct nvif_ioctl_ntfy_new_v0 { 118struct nvif_ioctl_ntfy_new_v0 {
105 /* nvif_ioctl ... */ 119 /* nvif_ioctl ... */
106 __u8 version; 120 __u8 version;
107 __u8 event; 121 __u8 event;
108 __u8 index; 122 __u8 index;
109 __u8 pad03[5]; 123 __u8 pad03[5];
110 __u8 data[]; /* event request data (event.h) */ 124 __u8 data[]; /* event request data (event.h) */
111}; 125};
112 126
113struct nvif_ioctl_ntfy_del_v0 { 127struct nvif_ioctl_ntfy_del_v0 {

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h 2018/08/27 07:35:56 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: object.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: object.h,v 1.3 2018/08/27 07:35:56 riastradh Exp $ */
2 2
3#ifndef __NVKM_OBJECT_H__ 3#ifndef __NVKM_OBJECT_H__
4#define __NVKM_OBJECT_H__ 4#define __NVKM_OBJECT_H__
5#include <core/os.h> 5#include <core/os.h>
6#include <core/debug.h> 6#include <core/debug.h>
7struct nvkm_event; 7struct nvkm_event;
8struct nvkm_gpuobj; 8struct nvkm_gpuobj;
9struct nvkm_oclass; 9struct nvkm_oclass;
10 10
11struct nvkm_object { 11struct nvkm_object {
12 const struct nvkm_object_func *func; 12 const struct nvkm_object_func *func;
13 struct nvkm_client *client; 13 struct nvkm_client *client;
14 struct nvkm_engine *engine; 14 struct nvkm_engine *engine;
@@ -19,52 +19,58 @@ struct nvkm_object { @@ -19,52 +19,58 @@ struct nvkm_object {
19 struct list_head tree; 19 struct list_head tree;
20 u8 route; 20 u8 route;
21 u64 token; 21 u64 token;
22 u64 object; 22 u64 object;
23 struct rb_node node; 23 struct rb_node node;
24}; 24};
25 25
26struct nvkm_object_func { 26struct nvkm_object_func {
27 void *(*dtor)(struct nvkm_object *); 27 void *(*dtor)(struct nvkm_object *);
28 int (*init)(struct nvkm_object *); 28 int (*init)(struct nvkm_object *);
29 int (*fini)(struct nvkm_object *, bool suspend); 29 int (*fini)(struct nvkm_object *, bool suspend);
30 int (*mthd)(struct nvkm_object *, u32 mthd, void *data, u32 size); 30 int (*mthd)(struct nvkm_object *, u32 mthd, void *data, u32 size);
31 int (*ntfy)(struct nvkm_object *, u32 mthd, struct nvkm_event **); 31 int (*ntfy)(struct nvkm_object *, u32 mthd, struct nvkm_event **);
 32#ifdef __NetBSD__
 33 int (*map)(struct nvkm_object *, bus_space_tag_t *tagp, u64 *addr,
 34 u32 *size);
 35#else
32 int (*map)(struct nvkm_object *, u64 *addr, u32 *size); 36 int (*map)(struct nvkm_object *, u64 *addr, u32 *size);
 37#endif
33 int (*rd08)(struct nvkm_object *, u64 addr, u8 *data); 38 int (*rd08)(struct nvkm_object *, u64 addr, u8 *data);
34 int (*rd16)(struct nvkm_object *, u64 addr, u16 *data); 39 int (*rd16)(struct nvkm_object *, u64 addr, u16 *data);
35 int (*rd32)(struct nvkm_object *, u64 addr, u32 *data); 40 int (*rd32)(struct nvkm_object *, u64 addr, u32 *data);
36 int (*wr08)(struct nvkm_object *, u64 addr, u8 data); 41 int (*wr08)(struct nvkm_object *, u64 addr, u8 data);
37 int (*wr16)(struct nvkm_object *, u64 addr, u16 data); 42 int (*wr16)(struct nvkm_object *, u64 addr, u16 data);
38 int (*wr32)(struct nvkm_object *, u64 addr, u32 data); 43 int (*wr32)(struct nvkm_object *, u64 addr, u32 data);
39 int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align, 44 int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
40 struct nvkm_gpuobj **); 45 struct nvkm_gpuobj **);
41 int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *); 46 int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *);
42}; 47};
43 48
44void nvkm_object_ctor(const struct nvkm_object_func *, 49void nvkm_object_ctor(const struct nvkm_object_func *,
45 const struct nvkm_oclass *, struct nvkm_object *); 50 const struct nvkm_oclass *, struct nvkm_object *);
46int nvkm_object_new_(const struct nvkm_object_func *, 51int nvkm_object_new_(const struct nvkm_object_func *,
47 const struct nvkm_oclass *, void *data, u32 size, 52 const struct nvkm_oclass *, void *data, u32 size,
48 struct nvkm_object **); 53 struct nvkm_object **);
49int nvkm_object_new(const struct nvkm_oclass *, void *data, u32 size, 54int nvkm_object_new(const struct nvkm_oclass *, void *data, u32 size,
50 struct nvkm_object **); 55 struct nvkm_object **);
51void nvkm_object_del(struct nvkm_object **); 56void nvkm_object_del(struct nvkm_object **);
52void *nvkm_object_dtor(struct nvkm_object *); 57void *nvkm_object_dtor(struct nvkm_object *);
53int nvkm_object_init(struct nvkm_object *); 58int nvkm_object_init(struct nvkm_object *);
54int nvkm_object_fini(struct nvkm_object *, bool suspend); 59int nvkm_object_fini(struct nvkm_object *, bool suspend);
55int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size); 60int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size);
56int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **); 61int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **);
57int nvkm_object_map(struct nvkm_object *, u64 *addr, u32 *size); 62int nvkm_object_map(struct nvkm_object *, bus_space_tag_t *, u64 *addr,
 63 u32 *size);
58int nvkm_object_rd08(struct nvkm_object *, u64 addr, u8 *data); 64int nvkm_object_rd08(struct nvkm_object *, u64 addr, u8 *data);
59int nvkm_object_rd16(struct nvkm_object *, u64 addr, u16 *data); 65int nvkm_object_rd16(struct nvkm_object *, u64 addr, u16 *data);
60int nvkm_object_rd32(struct nvkm_object *, u64 addr, u32 *data); 66int nvkm_object_rd32(struct nvkm_object *, u64 addr, u32 *data);
61int nvkm_object_wr08(struct nvkm_object *, u64 addr, u8 data); 67int nvkm_object_wr08(struct nvkm_object *, u64 addr, u8 data);
62int nvkm_object_wr16(struct nvkm_object *, u64 addr, u16 data); 68int nvkm_object_wr16(struct nvkm_object *, u64 addr, u16 data);
63int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32 data); 69int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32 data);
64int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align, 70int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
65 struct nvkm_gpuobj **); 71 struct nvkm_gpuobj **);
66 72
67struct nvkm_sclass { 73struct nvkm_sclass {
68 int minver; 74 int minver;
69 int maxver; 75 int maxver;
70 s32 oclass; 76 s32 oclass;

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvif/nouveau_nvif_object.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvif/nouveau_nvif_object.c 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvif/nouveau_nvif_object.c 2018/08/27 07:35:56 1.3
@@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
1/* $NetBSD: nouveau_nvif_object.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvif_object.c,v 1.3 2018/08/27 07:35:56 riastradh 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_nvif_object.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: nouveau_nvif_object.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
29 29
30#include <nvif/object.h> 30#include <nvif/object.h>
31#include <nvif/client.h> 31#include <nvif/client.h>
32#include <nvif/driver.h> 32#include <nvif/driver.h>
33#include <nvif/ioctl.h> 33#include <nvif/ioctl.h>
34 34
35int 35int
36nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack) 36nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
37{ 37{
38 struct nvif_client *client = object->client; 38 struct nvif_client *client = object->client;
39 union { 39 union {
40 struct nvif_ioctl_v0 v0; 40 struct nvif_ioctl_v0 v0;
41 } *args = data; 41 } *args = data;
@@ -173,54 +173,73 @@ nvif_object_mthd(struct nvif_object *obj @@ -173,54 +173,73 @@ nvif_object_mthd(struct nvif_object *obj
173void 173void
174nvif_object_unmap(struct nvif_object *object) 174nvif_object_unmap(struct nvif_object *object)
175{ 175{
176 if (object->map.size) { 176 if (object->map.size) {
177 struct nvif_client *client = object->client; 177 struct nvif_client *client = object->client;
178 struct { 178 struct {
179 struct nvif_ioctl_v0 ioctl; 179 struct nvif_ioctl_v0 ioctl;
180 struct nvif_ioctl_unmap unmap; 180 struct nvif_ioctl_unmap unmap;
181 } args = { 181 } args = {
182 .ioctl.type = NVIF_IOCTL_V0_UNMAP, 182 .ioctl.type = NVIF_IOCTL_V0_UNMAP,
183 }; 183 };
184 184
185 if (object->map.ptr) { 185 if (object->map.ptr) {
186 client->driver->unmap(client, object->map.ptr, 186 client->driver->unmap(client, object->map.tag,
 187 object->map.handle,
187 object->map.size); 188 object->map.size);
188 object->map.ptr = NULL; 189 object->map.ptr = NULL;
189 } 190 }
190 191
191 nvif_object_ioctl(object, &args, sizeof(args), NULL); 192 nvif_object_ioctl(object, &args, sizeof(args), NULL);
192 object->map.size = 0; 193 object->map.size = 0;
193 } 194 }
194} 195}
195 196
196int 197int
197nvif_object_map(struct nvif_object *object) 198nvif_object_map(struct nvif_object *object)
198{ 199{
199 struct nvif_client *client = object->client; 200 struct nvif_client *client = object->client;
200 struct { 201 struct {
201 struct nvif_ioctl_v0 ioctl; 202 struct nvif_ioctl_v0 ioctl;
 203#ifdef __NetBSD__
 204 struct nvif_ioctl_map_netbsd_v0 map;
 205#else
202 struct nvif_ioctl_map_v0 map; 206 struct nvif_ioctl_map_v0 map;
 207#endif
203 } args = { 208 } args = {
 209#ifdef __NetBSD__
 210 .ioctl.type = NVIF_IOCTL_V0_MAP_NETBSD,
 211#else
204 .ioctl.type = NVIF_IOCTL_V0_MAP, 212 .ioctl.type = NVIF_IOCTL_V0_MAP,
 213#endif
205 }; 214 };
206 int ret = nvif_object_ioctl(object, &args, sizeof(args), NULL); 215 int ret = nvif_object_ioctl(object, &args, sizeof(args), NULL);
207 if (ret == 0) { 216 if (ret == 0) {
208 object->map.size = args.map.length; 217 object->map.size = args.map.length;
 218#ifdef __NetBSD__
 219 ret = client->driver->map(client, args.map.tag,
 220 args.map.handle, object->map.size, &object->map.handle,
 221 &object->map.ptr);
 222 if (ret) {
 223 nvif_object_unmap(object);
 224 return -ENOMEM;
 225 }
 226#else
209 object->map.ptr = client->driver->map(client, args.map.handle, 227 object->map.ptr = client->driver->map(client, args.map.handle,
210 object->map.size); 228 object->map.size);
211 if (ret = -ENOMEM, object->map.ptr) 229 if (ret = -ENOMEM, object->map.ptr)
212 return 0; 230 return 0;
213 nvif_object_unmap(object); 231 nvif_object_unmap(object);
 232#endif
214 } 233 }
215 return ret; 234 return ret;
216} 235}
217 236
218void 237void
219nvif_object_fini(struct nvif_object *object) 238nvif_object_fini(struct nvif_object *object)
220{ 239{
221 struct { 240 struct {
222 struct nvif_ioctl_v0 ioctl; 241 struct nvif_ioctl_v0 ioctl;
223 struct nvif_ioctl_del del; 242 struct nvif_ioctl_del del;
224 } args = { 243 } args = {
225 .ioctl.type = NVIF_IOCTL_V0_DEL, 244 .ioctl.type = NVIF_IOCTL_V0_DEL,
226 }; 245 };

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_ioctl.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_ioctl.c 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_ioctl.c 2018/08/27 07:35:56 1.3
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: nouveau_nvkm_core_ioctl.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_core_ioctl.c,v 1.3 2018/08/27 07:35:56 riastradh 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_ioctl.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_ioctl.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#include <core/ioctl.h> 29#include <core/ioctl.h>
30#include <core/client.h> 30#include <core/client.h>
31#include <core/engine.h> 31#include <core/engine.h>
32 32
33#include <nvif/unpack.h> 33#include <nvif/unpack.h>
34#include <nvif/ioctl.h> 34#include <nvif/ioctl.h>
35 35
36static int 36static int
37nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size) 37nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size)
38{ 38{
39 union { 39 union {
40 struct nvif_ioctl_nop_v0 v0; 40 struct nvif_ioctl_nop_v0 v0;
@@ -250,28 +250,49 @@ nvkm_ioctl_wr(struct nvkm_object *object @@ -250,28 +250,49 @@ nvkm_ioctl_wr(struct nvkm_object *object
250 return -EINVAL; 250 return -EINVAL;
251} 251}
252 252
253static int 253static int
254nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size) 254nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size)
255{ 255{
256 union { 256 union {
257 struct nvif_ioctl_map_v0 v0; 257 struct nvif_ioctl_map_v0 v0;
258 } *args = data; 258 } *args = data;
259 int ret; 259 int ret;
260 260
261 nvif_ioctl(object, "map size %d\n", size); 261 nvif_ioctl(object, "map size %d\n", size);
262 if (nvif_unpack(args->v0, 0, 0, false)) { 262 if (nvif_unpack(args->v0, 0, 0, false)) {
 263 bus_space_tag_t dummy __unused;
263 nvif_ioctl(object, "map vers %d\n", args->v0.version); 264 nvif_ioctl(object, "map vers %d\n", args->v0.version);
264 ret = nvkm_object_map(object, &args->v0.handle, 265 ret = nvkm_object_map(object, &dummy,
 266 &args->v0.handle,
 267 &args->v0.length);
 268 }
 269
 270 return ret;
 271}
 272
 273static int
 274nvkm_ioctl_map_netbsd(struct nvkm_object *object, void *data, u32 size)
 275{
 276 union {
 277 struct nvif_ioctl_map_netbsd_v0 v0;
 278 } *args = data;
 279 int ret;
 280
 281 nvif_ioctl(object, "map size %d\n", size);
 282 if (nvif_unpack(args->v0, 0, 0, false)) {
 283 nvif_ioctl(object, "map vers %d\n", args->v0.version);
 284 ret = nvkm_object_map(object, &args->v0.tag,
 285 &args->v0.handle,
265 &args->v0.length); 286 &args->v0.length);
266 } 287 }
267 288
268 return ret; 289 return ret;
269} 290}
270 291
271static int 292static int
272nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size) 293nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size)
273{ 294{
274 union { 295 union {
275 struct nvif_ioctl_unmap none; 296 struct nvif_ioctl_unmap none;
276 } *args = data; 297 } *args = data;
277 int ret; 298 int ret;
@@ -375,26 +396,27 @@ nvkm_ioctl_v0[] = { @@ -375,26 +396,27 @@ nvkm_ioctl_v0[] = {
375 { 0x00, nvkm_ioctl_nop }, 396 { 0x00, nvkm_ioctl_nop },
376 { 0x00, nvkm_ioctl_sclass }, 397 { 0x00, nvkm_ioctl_sclass },
377 { 0x00, nvkm_ioctl_new }, 398 { 0x00, nvkm_ioctl_new },
378 { 0x00, nvkm_ioctl_del }, 399 { 0x00, nvkm_ioctl_del },
379 { 0x00, nvkm_ioctl_mthd }, 400 { 0x00, nvkm_ioctl_mthd },
380 { 0x00, nvkm_ioctl_rd }, 401 { 0x00, nvkm_ioctl_rd },
381 { 0x00, nvkm_ioctl_wr }, 402 { 0x00, nvkm_ioctl_wr },
382 { 0x00, nvkm_ioctl_map }, 403 { 0x00, nvkm_ioctl_map },
383 { 0x00, nvkm_ioctl_unmap }, 404 { 0x00, nvkm_ioctl_unmap },
384 { 0x00, nvkm_ioctl_ntfy_new }, 405 { 0x00, nvkm_ioctl_ntfy_new },
385 { 0x00, nvkm_ioctl_ntfy_del }, 406 { 0x00, nvkm_ioctl_ntfy_del },
386 { 0x00, nvkm_ioctl_ntfy_get }, 407 { 0x00, nvkm_ioctl_ntfy_get },
387 { 0x00, nvkm_ioctl_ntfy_put }, 408 { 0x00, nvkm_ioctl_ntfy_put },
 409 { 0x00, nvkm_ioctl_map_netbsd },
388}; 410};
389 411
390static int 412static int
391nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type, 413nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
392 void *data, u32 size, u8 owner, u8 *route, u64 *token) 414 void *data, u32 size, u8 owner, u8 *route, u64 *token)
393{ 415{
394 struct nvkm_object *object; 416 struct nvkm_object *object;
395 int ret; 417 int ret;
396 418
397 if (handle) 419 if (handle)
398 object = nvkm_client_search(client, handle); 420 object = nvkm_client_search(client, handle);
399 else 421 else
400 object = &client->object; 422 object = &client->object;

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c 2018/08/27 07:35:56 1.3
@@ -1,67 +1,68 @@ @@ -1,67 +1,68 @@
1/* $NetBSD: nouveau_nvkm_core_object.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_core_object.c,v 1.3 2018/08/27 07:35:56 riastradh 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_object.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_object.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#include <core/object.h> 29#include <core/object.h>
30#include <core/client.h> 30#include <core/client.h>
31#include <core/engine.h> 31#include <core/engine.h>
32 32
33int 33int
34nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 34nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
35{ 35{
36 if (likely(object->func->mthd)) 36 if (likely(object->func->mthd))
37 return object->func->mthd(object, mthd, data, size); 37 return object->func->mthd(object, mthd, data, size);
38 return -ENODEV; 38 return -ENODEV;
39} 39}
40 40
41int 41int
42nvkm_object_ntfy(struct nvkm_object *object, u32 mthd, 42nvkm_object_ntfy(struct nvkm_object *object, u32 mthd,
43 struct nvkm_event **pevent) 43 struct nvkm_event **pevent)
44{ 44{
45 if (likely(object->func->ntfy)) 45 if (likely(object->func->ntfy))
46 return object->func->ntfy(object, mthd, pevent); 46 return object->func->ntfy(object, mthd, pevent);
47 return -ENODEV; 47 return -ENODEV;
48} 48}
49 49
50int 50int
51nvkm_object_map(struct nvkm_object *object, u64 *addr, u32 *size) 51nvkm_object_map(struct nvkm_object *object, bus_space_tag_t *tagp, u64 *addr,
 52 u32 *size)
52{ 53{
53 if (likely(object->func->map)) 54 if (likely(object->func->map))
54 return object->func->map(object, addr, size); 55 return object->func->map(object, tagp, addr, size);
55 return -ENODEV; 56 return -ENODEV;
56} 57}
57 58
58int 59int
59nvkm_object_rd08(struct nvkm_object *object, u64 addr, u8 *data) 60nvkm_object_rd08(struct nvkm_object *object, u64 addr, u8 *data)
60{ 61{
61 if (likely(object->func->rd08)) 62 if (likely(object->func->rd08))
62 return object->func->rd08(object, addr, data); 63 return object->func->rd08(object, addr, data);
63 return -ENODEV; 64 return -ENODEV;
64} 65}
65 66
66int 67int
67nvkm_object_rd16(struct nvkm_object *object, u64 addr, u16 *data) 68nvkm_object_rd16(struct nvkm_object *object, u64 addr, u16 *data)

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_oproxy.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_oproxy.c 2018/08/27 04:58:30 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_oproxy.c 2018/08/27 07:35:56 1.3
@@ -1,60 +1,61 @@ @@ -1,60 +1,61 @@
1/* $NetBSD: nouveau_nvkm_core_oproxy.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_core_oproxy.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2015 Red Hat Inc. 4 * Copyright 2015 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_oproxy.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_oproxy.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#include <core/oproxy.h> 29#include <core/oproxy.h>
30 30
31static int 31static int
32nvkm_oproxy_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 32nvkm_oproxy_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
33{ 33{
34 return nvkm_object_mthd(nvkm_oproxy(object)->object, mthd, data, size); 34 return nvkm_object_mthd(nvkm_oproxy(object)->object, mthd, data, size);
35} 35}
36 36
37static int 37static int
38nvkm_oproxy_ntfy(struct nvkm_object *object, u32 mthd, 38nvkm_oproxy_ntfy(struct nvkm_object *object, u32 mthd,
39 struct nvkm_event **pevent) 39 struct nvkm_event **pevent)
40{ 40{
41 return nvkm_object_ntfy(nvkm_oproxy(object)->object, mthd, pevent); 41 return nvkm_object_ntfy(nvkm_oproxy(object)->object, mthd, pevent);
42} 42}
43 43
44static int 44static int
45nvkm_oproxy_map(struct nvkm_object *object, u64 *addr, u32 *size) 45nvkm_oproxy_map(struct nvkm_object *object, bus_space_tag_t *tagp, u64 *addr,
 46 u32 *size)
46{ 47{
47 return nvkm_object_map(nvkm_oproxy(object)->object, addr, size); 48 return nvkm_object_map(nvkm_oproxy(object)->object, tagp, addr, size);
48} 49}
49 50
50static int 51static int
51nvkm_oproxy_rd08(struct nvkm_object *object, u64 addr, u8 *data) 52nvkm_oproxy_rd08(struct nvkm_object *object, u64 addr, u8 *data)
52{ 53{
53 return nvkm_object_rd08(nvkm_oproxy(object)->object, addr, data); 54 return nvkm_object_rd08(nvkm_oproxy(object)->object, addr, data);
54} 55}
55 56
56static int 57static int
57nvkm_oproxy_rd16(struct nvkm_object *object, u64 addr, u16 *data) 58nvkm_oproxy_rd16(struct nvkm_object *object, u64 addr, u16 *data)
58{ 59{
59 return nvkm_object_rd16(nvkm_oproxy(object)->object, addr, data); 60 return nvkm_object_rd16(nvkm_oproxy(object)->object, addr, data);
60} 61}

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_user.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_user.c 2018/08/27 04:58:31 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_user.c 2018/08/27 07:35:56 1.3
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: nouveau_nvkm_engine_device_user.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_engine_device_user.c,v 1.3 2018/08/27 07:35:56 riastradh 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_user.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_user.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#define nvkm_udevice(p) container_of((p), struct nvkm_udevice, object) 29#define nvkm_udevice(p) container_of((p), struct nvkm_udevice, object)
30#include "priv.h" 30#include "priv.h"
31#include "ctrl.h" 31#include "ctrl.h"
32 32
33#include <core/client.h> 33#include <core/client.h>
34#include <subdev/fb.h> 34#include <subdev/fb.h>
35#include <subdev/instmem.h> 35#include <subdev/instmem.h>
36#include <subdev/timer.h> 36#include <subdev/timer.h>
37 37
38#include <nvif/class.h> 38#include <nvif/class.h>
39#include <nvif/unpack.h> 39#include <nvif/unpack.h>
40 40
@@ -195,30 +195,32 @@ nvkm_udevice_wr16(struct nvkm_object *ob @@ -195,30 +195,32 @@ nvkm_udevice_wr16(struct nvkm_object *ob
195 nvkm_wr16(udev->device, addr, data); 195 nvkm_wr16(udev->device, addr, data);
196 return 0; 196 return 0;
197} 197}
198 198
199static int 199static int
200nvkm_udevice_wr32(struct nvkm_object *object, u64 addr, u32 data) 200nvkm_udevice_wr32(struct nvkm_object *object, u64 addr, u32 data)
201{ 201{
202 struct nvkm_udevice *udev = nvkm_udevice(object); 202 struct nvkm_udevice *udev = nvkm_udevice(object);
203 nvkm_wr32(udev->device, addr, data); 203 nvkm_wr32(udev->device, addr, data);
204 return 0; 204 return 0;
205} 205}
206 206
207static int 207static int
208nvkm_udevice_map(struct nvkm_object *object, u64 *addr, u32 *size) 208nvkm_udevice_map(struct nvkm_object *object, bus_space_tag_t *tagp, u64 *addr,
 209 u32 *size)
209{ 210{
210 struct nvkm_udevice *udev = nvkm_udevice(object); 211 struct nvkm_udevice *udev = nvkm_udevice(object);
211 struct nvkm_device *device = udev->device; 212 struct nvkm_device *device = udev->device;
 213 *tagp = device->func->resource_tag(device, 0);
212 *addr = device->func->resource_addr(device, 0); 214 *addr = device->func->resource_addr(device, 0);
213 *size = device->func->resource_size(device, 0); 215 *size = device->func->resource_size(device, 0);
214 return 0; 216 return 0;
215} 217}
216 218
217static int 219static int
218nvkm_udevice_fini(struct nvkm_object *object, bool suspend) 220nvkm_udevice_fini(struct nvkm_object *object, bool suspend)
219{ 221{
220 struct nvkm_udevice *udev = nvkm_udevice(object); 222 struct nvkm_udevice *udev = nvkm_udevice(object);
221 struct nvkm_device *device = udev->device; 223 struct nvkm_device *device = udev->device;
222 int ret = 0; 224 int ret = 0;
223 225
224 mutex_lock(&device->mutex); 226 mutex_lock(&device->mutex);

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_channv50.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_channv50.c 2018/08/27 04:58:31 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_channv50.c 2018/08/27 07:35:56 1.3
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: nouveau_nvkm_engine_disp_channv50.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_engine_disp_channv50.c,v 1.3 2018/08/27 07:35:56 riastradh 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_channv50.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_channv50.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#include "channv50.h" 29#include "channv50.h"
30#include "rootnv50.h" 30#include "rootnv50.h"
31 31
32#include <core/client.h> 32#include <core/client.h>
33#include <core/ramht.h> 33#include <core/ramht.h>
34#include <engine/dma.h> 34#include <engine/dma.h>
35 35
36#include <nvif/class.h> 36#include <nvif/class.h>
37#include <nvif/event.h> 37#include <nvif/event.h>
38#include <nvif/unpack.h> 38#include <nvif/unpack.h>
39 39
40static void 40static void
@@ -184,32 +184,34 @@ nv50_disp_chan_ntfy(struct nvkm_object * @@ -184,32 +184,34 @@ nv50_disp_chan_ntfy(struct nvkm_object *
184{ 184{
185 struct nv50_disp_chan *chan = nv50_disp_chan(object); 185 struct nv50_disp_chan *chan = nv50_disp_chan(object);
186 struct nv50_disp *disp = chan->root->disp; 186 struct nv50_disp *disp = chan->root->disp;
187 switch (type) { 187 switch (type) {
188 case NV50_DISP_CORE_CHANNEL_DMA_V0_NTFY_UEVENT: 188 case NV50_DISP_CORE_CHANNEL_DMA_V0_NTFY_UEVENT:
189 *pevent = &disp->uevent; 189 *pevent = &disp->uevent;
190 return 0; 190 return 0;
191 default: 191 default:
192 break; 192 break;
193 } 193 }
194 return -EINVAL; 194 return -EINVAL;
195} 195}
196 196
197int 197static int
198nv50_disp_chan_map(struct nvkm_object *object, u64 *addr, u32 *size) 198nv50_disp_chan_map(struct nvkm_object *object, bus_space_tag_t *tagp,
 199 u64 *addr, u32 *size)
199{ 200{
200 struct nv50_disp_chan *chan = nv50_disp_chan(object); 201 struct nv50_disp_chan *chan = nv50_disp_chan(object);
201 struct nv50_disp *disp = chan->root->disp; 202 struct nv50_disp *disp = chan->root->disp;
202 struct nvkm_device *device = disp->base.engine.subdev.device; 203 struct nvkm_device *device = disp->base.engine.subdev.device;
 204 *tagp = device->func->resource_tag(device, 0);
203 *addr = device->func->resource_addr(device, 0) + 205 *addr = device->func->resource_addr(device, 0) +
204 0x640000 + (chan->chid * 0x1000); 206 0x640000 + (chan->chid * 0x1000);
205 *size = 0x001000; 207 *size = 0x001000;
206 return 0; 208 return 0;
207} 209}
208 210
209static int 211static int
210nv50_disp_chan_child_new(const struct nvkm_oclass *oclass, 212nv50_disp_chan_child_new(const struct nvkm_oclass *oclass,
211 void *data, u32 size, struct nvkm_object **pobject) 213 void *data, u32 size, struct nvkm_object **pobject)
212{ 214{
213 struct nv50_disp_chan *chan = nv50_disp_chan(oclass->parent); 215 struct nv50_disp_chan *chan = nv50_disp_chan(oclass->parent);
214 return chan->func->child_new(chan, oclass, data, size, pobject); 216 return chan->func->child_new(chan, oclass, data, size, pobject);
215} 217}

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/fifo/nouveau_nvkm_engine_fifo_chan.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/fifo/nouveau_nvkm_engine_fifo_chan.c 2018/08/27 04:58:31 1.2
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/fifo/nouveau_nvkm_engine_fifo_chan.c 2018/08/27 07:35:56 1.3
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: nouveau_nvkm_engine_fifo_chan.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $ */ 1/* $NetBSD: nouveau_nvkm_engine_fifo_chan.c,v 1.3 2018/08/27 07:35:56 riastradh 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#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_fifo_chan.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_fifo_chan.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
28 28
29#include "chan.h" 29#include "chan.h"
30 30
31#include <core/client.h> 31#include <core/client.h>
32#include <core/gpuobj.h> 32#include <core/gpuobj.h>
33#include <core/oproxy.h> 33#include <core/oproxy.h>
34#include <subdev/mmu.h> 34#include <subdev/mmu.h>
35#include <engine/dma.h> 35#include <engine/dma.h>
36 36
37struct nvkm_fifo_chan_object { 37struct nvkm_fifo_chan_object {
38 struct nvkm_oproxy oproxy; 38 struct nvkm_oproxy oproxy;
39 struct nvkm_fifo_chan *chan; 39 struct nvkm_fifo_chan *chan;
40 int hash; 40 int hash;
@@ -248,29 +248,32 @@ nvkm_fifo_chan_child_get(struct nvkm_obj @@ -248,29 +248,32 @@ nvkm_fifo_chan_child_get(struct nvkm_obj
248} 248}
249 249
250static int 250static int
251nvkm_fifo_chan_ntfy(struct nvkm_object *object, u32 type, 251nvkm_fifo_chan_ntfy(struct nvkm_object *object, u32 type,
252 struct nvkm_event **pevent) 252 struct nvkm_event **pevent)
253{ 253{
254 struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object); 254 struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
255 if (chan->func->ntfy) 255 if (chan->func->ntfy)
256 return chan->func->ntfy(chan, type, pevent); 256 return chan->func->ntfy(chan, type, pevent);
257 return -ENODEV; 257 return -ENODEV;
258} 258}
259 259
260static int 260static int
261nvkm_fifo_chan_map(struct nvkm_object *object, u64 *addr, u32 *size) 261nvkm_fifo_chan_map(struct nvkm_object *object, bus_space_tag_t *tagp,
 262 u64 *addr, u32 *size)
262{ 263{
263 struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object); 264 struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
 265 /* XXX Uh oh. Can't map this more than once. OK? */
 266 *tagp = chan->bst;
264 *addr = chan->addr; 267 *addr = chan->addr;
265 *size = chan->size; 268 *size = chan->size;
266 return 0; 269 return 0;
267} 270}
268 271
269#ifdef __NetBSD__ 272#ifdef __NetBSD__
270static int 273static int
271nvkm_fifo_chan_ensure_mapped(struct nvkm_fifo_chan *chan) 274nvkm_fifo_chan_ensure_mapped(struct nvkm_fifo_chan *chan)
272{ 275{
273 int ret; 276 int ret;
274 277
275 if (likely(chan->mapped)) 278 if (likely(chan->mapped))
276 goto out; 279 goto out;