drm/nouveau/fifo: audit and version fifo channel classes
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_nvif.c
CommitLineData
0ad72863
BS
1/*
2 * Copyright 2014 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24
25/*******************************************************************************
26 * NVIF client driver - NVKM directly linked
27 ******************************************************************************/
28
29#include <core/client.h>
30#include <core/notify.h>
31#include <core/ioctl.h>
32
33#include <nvif/client.h>
34#include <nvif/driver.h>
35#include <nvif/notify.h>
36#include <nvif/event.h>
37#include <nvif/ioctl.h>
38
39#include "nouveau_drm.h"
40
41static void
42nvkm_client_unmap(void *priv, void *ptr, u32 size)
43{
44 iounmap(ptr);
45}
46
47static void *
48nvkm_client_map(void *priv, u64 handle, u32 size)
49{
50 return ioremap(handle, size);
51}
52
53static int
54nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
55{
56 return nvkm_ioctl(priv, super, data, size, hack);
57}
58
59static int
60nvkm_client_resume(void *priv)
61{
62 return nouveau_client_init(priv);
63}
64
65static int
66nvkm_client_suspend(void *priv)
67{
68 return nouveau_client_fini(priv, true);
69}
70
71static void
72nvkm_client_fini(void *priv)
73{
74 struct nouveau_object *client = priv;
75 nouveau_client_fini(nv_client(client), false);
76 atomic_set(&client->refcount, 1);
77 nouveau_object_ref(NULL, &client);
78}
79
80static int
81nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
82{
83 const union {
84 struct nvif_notify_req_v0 v0;
85 } *args = header;
86 u8 route;
87
88 if (length == sizeof(args->v0) && args->v0.version == 0) {
89 route = args->v0.route;
90 } else {
91 WARN_ON(1);
92 return NVKM_NOTIFY_DROP;
93 }
94
95 switch (route) {
96 case NVDRM_NOTIFY_NVIF:
97 return nvif_notify(header, length, data, size);
98 default:
99 WARN_ON(1);
100 break;
101 }
102
103 return NVKM_NOTIFY_DROP;
104}
105
106static int
107nvkm_client_init(const char *name, u64 device, const char *cfg,
108 const char *dbg, void **ppriv)
109{
110 struct nouveau_client *client;
111 int ret;
112
113 ret = nouveau_client_create(name, device, cfg, dbg, &client);
114 *ppriv = client;
115 if (ret)
116 return ret;
117
118 client->ntfy = nvkm_client_ntfy;
119 return 0;
120}
121
122const struct nvif_driver
123nvif_driver_nvkm = {
124 .name = "nvkm",
125 .init = nvkm_client_init,
126 .fini = nvkm_client_fini,
127 .suspend = nvkm_client_suspend,
128 .resume = nvkm_client_resume,
129 .ioctl = nvkm_client_ioctl,
130 .map = nvkm_client_map,
131 .unmap = nvkm_client_unmap,
132 .keep = false,
133};
This page took 0.032984 seconds and 5 git commands to generate.