blob: 890c8a1805919018a3c8097c07c3dfb21785f86f [file] [log] [blame]
Duy Truonge833aca2013-02-12 13:35:08 -08001/* Copyright (c) 2002,2008-2012, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
Steve Mucklef132c6c2012-06-06 18:30:57 -070014#include <linux/export.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/delay.h>
16#include <linux/debugfs.h>
17#include <linux/uaccess.h>
18#include <linux/io.h>
19
20#include "kgsl.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include "adreno.h"
22
Jeremy Gebbeneebc4612011-08-31 10:15:21 -070023#include "a2xx_reg.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024
25unsigned int kgsl_cff_dump_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026
27static int kgsl_cff_dump_enable_set(void *data, u64 val)
28{
29#ifdef CONFIG_MSM_KGSL_CFF_DUMP
30 kgsl_cff_dump_enable = (val != 0);
31 return 0;
32#else
33 return -EINVAL;
34#endif
35}
36
37static int kgsl_cff_dump_enable_get(void *data, u64 *val)
38{
39 *val = kgsl_cff_dump_enable;
40 return 0;
41}
42
43DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get,
44 kgsl_cff_dump_enable_set, "%llu\n");
45
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046typedef void (*reg_read_init_t)(struct kgsl_device *device);
47typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i,
48 unsigned int *vals, int linec);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049
50void adreno_debugfs_init(struct kgsl_device *device)
51{
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +053052 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
53
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054 if (!device->d_debugfs || IS_ERR(device->d_debugfs))
55 return;
56
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057 debugfs_create_file("cff_dump", 0644, device->d_debugfs, device,
58 &kgsl_cff_dump_enable_fops);
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +053059 debugfs_create_u32("wait_timeout", 0644, device->d_debugfs,
60 &adreno_dev->wait_timeout);
Jeremy Gebbend0ab6ad2012-04-06 11:13:35 -060061 debugfs_create_u32("ib_check", 0644, device->d_debugfs,
62 &adreno_dev->ib_check_level);
Tarun Karra3335f142012-06-19 14:11:48 -070063 /* By Default enable fast hang detection */
64 adreno_dev->fast_hang_detect = 1;
65 debugfs_create_u32("fast_hang_detect", 0644, device->d_debugfs,
66 &adreno_dev->fast_hang_detect);
Tarun Karra987e2f72013-02-14 12:12:22 -080067
68 /* Top level switch to enable/disable userspace FT control */
69 adreno_dev->ft_user_control = 0;
70 debugfs_create_u32("ft_user_control", 0644, device->d_debugfs,
71 &adreno_dev->ft_user_control);
Tarun Karradeeecc02013-01-21 23:42:17 -080072 /*
73 * FT policy can be set to any of the options below.
Tarun Karra3164fb02013-02-05 15:38:51 -080074 * KGSL_FT_DISABLE -> BIT(0) Set to disable FT
75 * KGSL_FT_REPLAY -> BIT(1) Set to enable replay
76 * KGSL_FT_SKIPIB -> BIT(2) Set to skip IB
77 * KGSL_FT_SKIPFRAME -> BIT(3) Set to skip frame
78 * by default set FT policy to KGSL_FT_DEFAULT_POLICY
Tarun Karradeeecc02013-01-21 23:42:17 -080079 */
Tarun Karra3164fb02013-02-05 15:38:51 -080080 adreno_dev->ft_policy = KGSL_FT_DEFAULT_POLICY;
Tarun Karra99678f82013-02-13 13:57:25 -080081 debugfs_create_u32("ft_policy", 0644, device->d_debugfs,
Tarun Karradeeecc02013-01-21 23:42:17 -080082 &adreno_dev->ft_policy);
Tarun Karra99678f82013-02-13 13:57:25 -080083
Tarun Karra696f89e2013-01-27 21:31:40 -080084 /* By default enable long IB detection */
85 adreno_dev->long_ib_detect = 1;
86 debugfs_create_u32("long_ib_detect", 0644, device->d_debugfs,
87 &adreno_dev->long_ib_detect);
Tarun Karra99678f82013-02-13 13:57:25 -080088
89 /*
90 * FT pagefault policy can be set to any of the options below.
91 * KGSL_FT_PAGEFAULT_INT_ENABLE -> BIT(0) set to enable pagefault INT
92 * KGSL_FT_PAGEFAULT_GPUHALT_ENABLE -> BIT(1) Set to enable GPU HALT on
93 * pagefaults. This stalls the GPU on a pagefault on IOMMU v1 HW.
94 * KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE -> BIT(2) Set to log only one
95 * pagefault per page.
96 * KGSL_FT_PAGEFAULT_LOG_ONE_PER_INT -> BIT(3) Set to log only one
97 * pagefault per INT.
98 */
99 adreno_dev->ft_pf_policy = KGSL_FT_PAGEFAULT_DEFAULT_POLICY;
100 debugfs_create_u32("ft_pagefault_policy", 0644, device->d_debugfs,
101 &adreno_dev->ft_pf_policy);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102}