drm/nvc0-/gr: generate grctx template at init time, not first context ctor
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nvc0_software.c
1 /*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25 #include "drmP.h"
26
27 #include "nouveau_drv.h"
28 #include <core/ramht.h>
29 #include "nouveau_software.h"
30
31 #include "nv50_display.h"
32
33 struct nvc0_software_priv {
34 struct nouveau_software_priv base;
35 };
36
37 struct nvc0_software_chan {
38 struct nouveau_software_chan base;
39 };
40
41 static int
42 nvc0_software_context_new(struct nouveau_channel *chan, int engine)
43 {
44 struct nvc0_software_chan *pch;
45
46 pch = kzalloc(sizeof(*pch), GFP_KERNEL);
47 if (!pch)
48 return -ENOMEM;
49
50 nouveau_software_context_new(chan, &pch->base);
51 chan->engctx[engine] = pch;
52 return 0;
53 }
54
55 static void
56 nvc0_software_context_del(struct nouveau_channel *chan, int engine)
57 {
58 struct nvc0_software_chan *pch = chan->engctx[engine];
59 chan->engctx[engine] = NULL;
60 kfree(pch);
61 }
62
63 static int
64 nvc0_software_object_new(struct nouveau_channel *chan, int engine,
65 u32 handle, u16 class)
66 {
67 return 0;
68 }
69
70 static int
71 nvc0_software_init(struct drm_device *dev, int engine)
72 {
73 return 0;
74 }
75
76 static int
77 nvc0_software_fini(struct drm_device *dev, int engine, bool suspend)
78 {
79 return 0;
80 }
81
82 static void
83 nvc0_software_destroy(struct drm_device *dev, int engine)
84 {
85 struct nvc0_software_priv *psw = nv_engine(dev, engine);
86
87 NVOBJ_ENGINE_DEL(dev, SW);
88 kfree(psw);
89 }
90
91 int
92 nvc0_software_create(struct drm_device *dev)
93 {
94 struct nvc0_software_priv *psw = kzalloc(sizeof(*psw), GFP_KERNEL);
95 if (!psw)
96 return -ENOMEM;
97
98 psw->base.base.destroy = nvc0_software_destroy;
99 psw->base.base.init = nvc0_software_init;
100 psw->base.base.fini = nvc0_software_fini;
101 psw->base.base.context_new = nvc0_software_context_new;
102 psw->base.base.context_del = nvc0_software_context_del;
103 psw->base.base.object_new = nvc0_software_object_new;
104 nouveau_software_create(&psw->base);
105
106 NVOBJ_ENGINE_ADD(dev, SW, &psw->base.base);
107 NVOBJ_CLASS(dev, 0x906e, SW);
108 return 0;
109 }
This page took 0.041914 seconds and 5 git commands to generate.