1 | /* $NetBSD: nouveau_engine_perfmon_nve0.c,v 1.1.1.1 2014/08/06 12:36:27 riastradh Exp $ */ |
2 | |
3 | /* |
4 | * Copyright 2013 Red Hat Inc. |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation |
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 |
11 | * Software is furnished to do so, subject to the following conditions: |
12 | * |
13 | * The above copyright notice and this permission notice shall be included in |
14 | * all copies or substantial portions of the Software. |
15 | * |
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, |
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 |
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 |
22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * |
24 | * Authors: Ben Skeggs |
25 | */ |
26 | |
27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_engine_perfmon_nve0.c,v 1.1.1.1 2014/08/06 12:36:27 riastradh Exp $" ); |
29 | |
30 | #include "nvc0.h" |
31 | |
32 | /******************************************************************************* |
33 | * Perfmon object classes |
34 | ******************************************************************************/ |
35 | |
36 | /******************************************************************************* |
37 | * PPM context |
38 | ******************************************************************************/ |
39 | |
40 | /******************************************************************************* |
41 | * PPM engine/subdev functions |
42 | ******************************************************************************/ |
43 | |
44 | static const struct nouveau_specdom |
45 | nve0_perfmon_hub[] = { |
46 | { 0x60, (const struct nouveau_specsig[]) { |
47 | { 0x47, "hub00_user_0" }, |
48 | {} |
49 | }, &nvc0_perfctr_func }, |
50 | { 0x40, (const struct nouveau_specsig[]) { |
51 | { 0x27, "hub01_user_0" }, |
52 | {} |
53 | }, &nvc0_perfctr_func }, |
54 | { 0x60, (const struct nouveau_specsig[]) { |
55 | { 0x47, "hub02_user_0" }, |
56 | {} |
57 | }, &nvc0_perfctr_func }, |
58 | { 0x60, (const struct nouveau_specsig[]) { |
59 | { 0x47, "hub03_user_0" }, |
60 | {} |
61 | }, &nvc0_perfctr_func }, |
62 | { 0x40, (const struct nouveau_specsig[]) { |
63 | { 0x03, "host_mmio_rd" }, |
64 | { 0x27, "hub04_user_0" }, |
65 | {} |
66 | }, &nvc0_perfctr_func }, |
67 | { 0x60, (const struct nouveau_specsig[]) { |
68 | { 0x47, "hub05_user_0" }, |
69 | {} |
70 | }, &nvc0_perfctr_func }, |
71 | { 0xc0, (const struct nouveau_specsig[]) { |
72 | { 0x74, "host_fb_rd3x" }, |
73 | { 0x75, "host_fb_rd3x_2" }, |
74 | { 0xa7, "hub06_user_0" }, |
75 | {} |
76 | }, &nvc0_perfctr_func }, |
77 | { 0x60, (const struct nouveau_specsig[]) { |
78 | { 0x47, "hub07_user_0" }, |
79 | {} |
80 | }, &nvc0_perfctr_func }, |
81 | {} |
82 | }; |
83 | |
84 | static const struct nouveau_specdom |
85 | nve0_perfmon_gpc[] = { |
86 | { 0xe0, (const struct nouveau_specsig[]) { |
87 | { 0xc7, "gpc00_user_0" }, |
88 | {} |
89 | }, &nvc0_perfctr_func }, |
90 | {} |
91 | }; |
92 | |
93 | static const struct nouveau_specdom |
94 | nve0_perfmon_part[] = { |
95 | { 0x60, (const struct nouveau_specsig[]) { |
96 | { 0x47, "part00_user_0" }, |
97 | {} |
98 | }, &nvc0_perfctr_func }, |
99 | { 0x60, (const struct nouveau_specsig[]) { |
100 | { 0x47, "part01_user_0" }, |
101 | {} |
102 | }, &nvc0_perfctr_func }, |
103 | {} |
104 | }; |
105 | |
106 | static int |
107 | nve0_perfmon_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
108 | struct nouveau_oclass *oclass, void *data, u32 size, |
109 | struct nouveau_object **pobject) |
110 | { |
111 | struct nvc0_perfmon_priv *priv; |
112 | u32 mask; |
113 | int ret; |
114 | |
115 | ret = nouveau_perfmon_create(parent, engine, oclass, &priv); |
116 | *pobject = nv_object(priv); |
117 | if (ret) |
118 | return ret; |
119 | |
120 | /* PDAEMON */ |
121 | ret = nouveau_perfdom_new(&priv->base, "pwr" , 0, 0, 0, 0, |
122 | nve0_perfmon_pwr); |
123 | if (ret) |
124 | return ret; |
125 | |
126 | /* HUB */ |
127 | ret = nouveau_perfdom_new(&priv->base, "hub" , 0, 0x1b0000, 0, 0x200, |
128 | nve0_perfmon_hub); |
129 | if (ret) |
130 | return ret; |
131 | |
132 | /* GPC */ |
133 | mask = (1 << nv_rd32(priv, 0x022430)) - 1; |
134 | mask &= ~nv_rd32(priv, 0x022504); |
135 | mask &= ~nv_rd32(priv, 0x022584); |
136 | |
137 | ret = nouveau_perfdom_new(&priv->base, "gpc" , mask, 0x180000, |
138 | 0x1000, 0x200, nve0_perfmon_gpc); |
139 | if (ret) |
140 | return ret; |
141 | |
142 | /* PART */ |
143 | mask = (1 << nv_rd32(priv, 0x022438)) - 1; |
144 | mask &= ~nv_rd32(priv, 0x022548); |
145 | mask &= ~nv_rd32(priv, 0x0225c8); |
146 | |
147 | ret = nouveau_perfdom_new(&priv->base, "part" , mask, 0x1a0000, |
148 | 0x1000, 0x200, nve0_perfmon_part); |
149 | if (ret) |
150 | return ret; |
151 | |
152 | nv_engine(priv)->cclass = &nouveau_perfmon_cclass; |
153 | nv_engine(priv)->sclass = nouveau_perfmon_sclass; |
154 | priv->base.last = 7; |
155 | return 0; |
156 | } |
157 | |
158 | struct nouveau_oclass |
159 | nve0_perfmon_oclass = { |
160 | .handle = NV_ENGINE(PERFMON, 0xe0), |
161 | .ofuncs = &(struct nouveau_ofuncs) { |
162 | .ctor = nve0_perfmon_ctor, |
163 | .dtor = _nouveau_perfmon_dtor, |
164 | .init = _nouveau_perfmon_init, |
165 | .fini = nvc0_perfmon_fini, |
166 | }, |
167 | }; |
168 | |