]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/nouveau/nouveau_nvif.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.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
4dc28134 39#include "nouveau_drv.h"
27111a23 40#include "nouveau_usif.h"
0ad72863
BS
41
42static void
3cfb2fac 43nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
0ad72863
BS
44{
45 iounmap(ptr);
46}
47
3cfb2fac 48static void __iomem *
0ad72863
BS
49nvkm_client_map(void *priv, u64 handle, u32 size)
50{
51 return ioremap(handle, size);
52}
53
54static int
55nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
56{
57 return nvkm_ioctl(priv, super, data, size, hack);
58}
59
60static int
61nvkm_client_resume(void *priv)
62{
2c3af924
BS
63 struct nvkm_client *client = priv;
64 return nvkm_object_init(&client->object);
0ad72863
BS
65}
66
67static int
68nvkm_client_suspend(void *priv)
69{
2c3af924
BS
70 struct nvkm_client *client = priv;
71 return nvkm_object_fini(&client->object, true);
0ad72863
BS
72}
73
0ad72863
BS
74static int
75nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
76{
77 const union {
78 struct nvif_notify_req_v0 v0;
79 } *args = header;
80 u8 route;
81
82 if (length == sizeof(args->v0) && args->v0.version == 0) {
83 route = args->v0.route;
84 } else {
85 WARN_ON(1);
86 return NVKM_NOTIFY_DROP;
87 }
88
89 switch (route) {
90 case NVDRM_NOTIFY_NVIF:
91 return nvif_notify(header, length, data, size);
27111a23
BS
92 case NVDRM_NOTIFY_USIF:
93 return usif_notify(header, length, data, size);
0ad72863
BS
94 default:
95 WARN_ON(1);
96 break;
97 }
98
99 return NVKM_NOTIFY_DROP;
100}
101
102static int
5025407b
BS
103nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
104 const char *dbg, void **ppriv)
0ad72863 105{
7c413feb
BS
106 return nvkm_client_new(name, device, cfg, dbg, nvkm_client_ntfy,
107 (struct nvkm_client **)ppriv);
0ad72863
BS
108}
109
110const struct nvif_driver
111nvif_driver_nvkm = {
112 .name = "nvkm",
5025407b 113 .init = nvkm_client_driver_init,
0ad72863
BS
114 .suspend = nvkm_client_suspend,
115 .resume = nvkm_client_resume,
116 .ioctl = nvkm_client_ioctl,
117 .map = nvkm_client_map,
118 .unmap = nvkm_client_unmap,
119 .keep = false,
120};