1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/sysfs.h>
#include "adreno.h"
#include "adreno_sysfs.h"
static int _ft_policy_store(struct adreno_device *adreno_dev,
unsigned int val)
{
adreno_dev->ft_policy = val & KGSL_FT_POLICY_MASK;
return 0;
}
static unsigned int _ft_policy_show(struct adreno_device *adreno_dev)
{
return adreno_dev->ft_policy;
}
static int _ft_pagefault_policy_store(struct adreno_device *adreno_dev,
unsigned int val)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret = 0;
mutex_lock(&device->mutex);
val &= KGSL_FT_PAGEFAULT_MASK;
if (device->state == KGSL_STATE_ACTIVE)
ret = kgsl_mmu_set_pagefault_policy(&device->mmu,
(unsigned long) val);
if (ret == 0)
adreno_dev->ft_pf_policy = val;
mutex_unlock(&device->mutex);
return 0;
}
static unsigned int _ft_pagefault_policy_show(struct adreno_device *adreno_dev)
{
return adreno_dev->ft_pf_policy;
}
static int _gpu_llc_slice_enable_store(struct adreno_device *adreno_dev,
bool val)
{
adreno_dev->gpu_llc_slice_enable = val;
return 0;
}
static bool _gpu_llc_slice_enable_show(struct adreno_device *adreno_dev)
{
return adreno_dev->gpu_llc_slice_enable;
}
static int _gpuhtw_llc_slice_enable_store(struct adreno_device *adreno_dev,
bool val)
{
adreno_dev->gpuhtw_llc_slice_enable = val;
return 0;
}
static bool _gpuhtw_llc_slice_enable_show(struct adreno_device *adreno_dev)
{
return adreno_dev->gpuhtw_llc_slice_enable;
}
static int _ft_long_ib_detect_store(struct adreno_device *adreno_dev, bool val)
{
adreno_dev->long_ib_detect = val ? true : false;
return 0;
}
static bool _ft_long_ib_detect_show(struct adreno_device *adreno_dev)
{
return adreno_dev->long_ib_detect;
}
static bool _ft_hang_intr_status_show(struct adreno_device *adreno_dev)
{
/* Hang interrupt is always on on all targets */
return true;
}
static int _hwcg_store(struct adreno_device *adreno_dev, bool val)
{
if (adreno_dev->hwcg_enabled == val)
return 0;
return adreno_power_cycle_bool(adreno_dev, &adreno_dev->hwcg_enabled,
val);
}
static bool _hwcg_show(struct adreno_device *adreno_dev)
{
return adreno_dev->hwcg_enabled;
}
static int _throttling_store(struct adreno_device *adreno_dev, bool val)
{
if (!adreno_is_a540(adreno_dev) ||
adreno_dev->throttling_enabled == val)
return 0;
return adreno_power_cycle_bool(adreno_dev,
&adreno_dev->throttling_enabled, val);
}
static bool _throttling_show(struct adreno_device *adreno_dev)
{
return adreno_dev->throttling_enabled;
}
static int _sptp_pc_store(struct adreno_device *adreno_dev, bool val)
{
if (!ADRENO_FEATURE(adreno_dev, ADRENO_SPTP_PC) ||
adreno_dev->sptp_pc_enabled == val)
return 0;
return adreno_power_cycle_bool(adreno_dev, &adreno_dev->sptp_pc_enabled,
val);
}
static bool _sptp_pc_show(struct adreno_device *adreno_dev)
{
return adreno_dev->sptp_pc_enabled;
}
static int _lm_store(struct adreno_device *adreno_dev, bool val)
{
if (!ADRENO_FEATURE(adreno_dev, ADRENO_LM) ||
adreno_dev->lm_enabled == val)
return 0;
return adreno_power_cycle_bool(adreno_dev, &adreno_dev->lm_enabled,
val);
}
static bool _lm_show(struct adreno_device *adreno_dev)
{
return adreno_dev->lm_enabled;
}
static int _ifpc_store(struct adreno_device *adreno_dev, bool val)
{
return gmu_core_dev_ifpc_store(KGSL_DEVICE(adreno_dev), val);
}
static bool _ifpc_show(struct adreno_device *adreno_dev)
{
return gmu_core_dev_ifpc_show(KGSL_DEVICE(adreno_dev));
}
static unsigned int _ifpc_count_show(struct adreno_device *adreno_dev)
{
return adreno_dev->ifpc_count;
}
static bool _acd_show(struct adreno_device *adreno_dev)
{
return adreno_dev->acd_enabled;
}
static int _acd_store(struct adreno_device *adreno_dev, bool val)
{
return gmu_core_dev_acd_set(KGSL_DEVICE(adreno_dev), val);
}
static bool _bcl_show(struct adreno_device *adreno_dev)
{
return adreno_dev->bcl_enabled;
}
static int _bcl_store(struct adreno_device *adreno_dev, bool val)
{
if (!ADRENO_FEATURE(adreno_dev, ADRENO_BCL) ||
adreno_dev->bcl_enabled == val)
return 0;
return adreno_power_cycle_bool(adreno_dev, &adreno_dev->bcl_enabled,
val);
}
ssize_t adreno_sysfs_store_u32(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(dev_get_drvdata(dev));
struct adreno_sysfs_attribute_u32 *_attr =
container_of(attr, struct adreno_sysfs_attribute_u32, attr);
u32 val;
int ret;
ret = kstrtou32(buf, 0, &val);
if (ret)
return ret;
ret = _attr->store(adreno_dev, val);
if (ret)
return ret;
return count;
}
ssize_t adreno_sysfs_show_u32(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(dev_get_drvdata(dev));
struct adreno_sysfs_attribute_u32 *_attr =
container_of(attr, struct adreno_sysfs_attribute_u32, attr);
return scnprintf(buf, PAGE_SIZE, "0x%X\n", _attr->show(adreno_dev));
}
ssize_t adreno_sysfs_store_bool(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(dev_get_drvdata(dev));
struct adreno_sysfs_attribute_bool *_attr =
container_of(attr, struct adreno_sysfs_attribute_bool, attr);
bool val;
int ret;
ret = kstrtobool(buf, &val);
if (ret)
return ret;
ret = _attr->store(adreno_dev, val);
if (ret)
return ret;
return count;
}
ssize_t adreno_sysfs_show_bool(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(dev_get_drvdata(dev));
struct adreno_sysfs_attribute_bool *_attr =
container_of(attr, struct adreno_sysfs_attribute_bool, attr);
return scnprintf(buf, PAGE_SIZE, "%d\n", _attr->show(adreno_dev));
}
static ADRENO_SYSFS_U32(ft_policy);
static ADRENO_SYSFS_U32(ft_pagefault_policy);
static ADRENO_SYSFS_BOOL(ft_long_ib_detect);
static ADRENO_SYSFS_RO_BOOL(ft_hang_intr_status);
static ADRENO_SYSFS_BOOL(gpu_llc_slice_enable);
static ADRENO_SYSFS_BOOL(gpuhtw_llc_slice_enable);
static DEVICE_INT_ATTR(wake_nice, 0644, adreno_wake_nice);
static DEVICE_INT_ATTR(wake_timeout, 0644, adreno_wake_timeout);
static ADRENO_SYSFS_BOOL(sptp_pc);
static ADRENO_SYSFS_BOOL(lm);
static ADRENO_SYSFS_BOOL(hwcg);
static ADRENO_SYSFS_BOOL(throttling);
static ADRENO_SYSFS_BOOL(ifpc);
static ADRENO_SYSFS_RO_U32(ifpc_count);
static ADRENO_SYSFS_BOOL(acd);
static ADRENO_SYSFS_BOOL(bcl);
static const struct attribute *_attr_list[] = {
&adreno_attr_ft_policy.attr.attr,
&adreno_attr_ft_pagefault_policy.attr.attr,
&adreno_attr_ft_long_ib_detect.attr.attr,
&adreno_attr_ft_hang_intr_status.attr.attr,
&dev_attr_wake_nice.attr.attr,
&dev_attr_wake_timeout.attr.attr,
&adreno_attr_sptp_pc.attr.attr,
&adreno_attr_lm.attr.attr,
&adreno_attr_hwcg.attr.attr,
&adreno_attr_throttling.attr.attr,
&adreno_attr_gpu_llc_slice_enable.attr.attr,
&adreno_attr_gpuhtw_llc_slice_enable.attr.attr,
&adreno_attr_ifpc.attr.attr,
&adreno_attr_ifpc_count.attr.attr,
&adreno_attr_acd.attr.attr,
&adreno_attr_bcl.attr.attr,
NULL,
};
/**
* adreno_sysfs_close() - Take down the adreno sysfs files
* @adreno_dev: Pointer to the adreno device
*
* Take down the sysfs files on when the device goes away
*/
void adreno_sysfs_close(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
sysfs_remove_files(&device->dev->kobj, _attr_list);
}
/**
* adreno_sysfs_init() - Initialize adreno sysfs files
* @adreno_dev: Pointer to the adreno device
*
* Initialize many of the adreno specific sysfs files especially for fault
* tolerance and power control
*/
int adreno_sysfs_init(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
return sysfs_create_files(&device->dev->kobj, _attr_list);
}
|