Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame^] | 1 | /* Copyright (c) 2002,2008-2012, The Linux Foundation. All rights reserved. |
| 2 | * |
| 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 | |
| 14 | #include <linux/export.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/debugfs.h> |
| 17 | #include <linux/uaccess.h> |
| 18 | #include <linux/io.h> |
| 19 | |
| 20 | #include "kgsl.h" |
| 21 | #include "adreno.h" |
| 22 | #include "kgsl_cffdump.h" |
| 23 | |
| 24 | #include "a2xx_reg.h" |
| 25 | |
| 26 | unsigned int kgsl_cff_dump_enable; |
| 27 | |
| 28 | DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get, |
| 29 | kgsl_cff_dump_enable_set, "%llu\n"); |
| 30 | |
| 31 | static int _active_count_get(void *data, u64 *val) |
| 32 | { |
| 33 | struct kgsl_device *device = data; |
| 34 | unsigned int i = atomic_read(&device->active_cnt); |
| 35 | |
| 36 | *val = (u64) i; |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | DEFINE_SIMPLE_ATTRIBUTE(_active_count_fops, _active_count_get, NULL, "%llu\n"); |
| 41 | |
| 42 | typedef void (*reg_read_init_t)(struct kgsl_device *device); |
| 43 | typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i, |
| 44 | unsigned int *vals, int linec); |
| 45 | |
| 46 | void adreno_debugfs_init(struct kgsl_device *device) |
| 47 | { |
| 48 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 49 | |
| 50 | if (!device->d_debugfs || IS_ERR(device->d_debugfs)) |
| 51 | return; |
| 52 | |
| 53 | debugfs_create_file("cff_dump", 0644, device->d_debugfs, device, |
| 54 | &kgsl_cff_dump_enable_fops); |
| 55 | debugfs_create_u32("wait_timeout", 0644, device->d_debugfs, |
| 56 | &adreno_dev->wait_timeout); |
| 57 | debugfs_create_u32("ib_check", 0644, device->d_debugfs, |
| 58 | &adreno_dev->ib_check_level); |
| 59 | /* By Default enable fast hang detection */ |
| 60 | adreno_dev->fast_hang_detect = 1; |
| 61 | debugfs_create_u32("fast_hang_detect", 0644, device->d_debugfs, |
| 62 | &adreno_dev->fast_hang_detect); |
| 63 | /* |
| 64 | * FT policy can be set to any of the options below. |
| 65 | * KGSL_FT_OFF -> BIT(0) Set to turn off FT |
| 66 | * KGSL_FT_REPLAY -> BIT(1) Set to enable replay |
| 67 | * KGSL_FT_SKIPIB -> BIT(2) Set to skip IB |
| 68 | * KGSL_FT_SKIPFRAME -> BIT(3) Set to skip frame |
| 69 | * KGSL_FT_DISABLE -> BIT(4) Set to disable FT for faulting context |
| 70 | * by default set FT policy to KGSL_FT_DEFAULT_POLICY |
| 71 | */ |
| 72 | adreno_dev->ft_policy = KGSL_FT_DEFAULT_POLICY; |
| 73 | debugfs_create_u32("ft_policy", 0644, device->d_debugfs, |
| 74 | &adreno_dev->ft_policy); |
| 75 | /* By default enable long IB detection */ |
| 76 | adreno_dev->long_ib_detect = 1; |
| 77 | debugfs_create_u32("long_ib_detect", 0644, device->d_debugfs, |
| 78 | &adreno_dev->long_ib_detect); |
| 79 | |
| 80 | /* |
| 81 | * FT pagefault policy can be set to any of the options below. |
| 82 | * KGSL_FT_PAGEFAULT_INT_ENABLE -> BIT(0) set to enable pagefault INT |
| 83 | * KGSL_FT_PAGEFAULT_GPUHALT_ENABLE -> BIT(1) Set to enable GPU HALT on |
| 84 | * pagefaults. This stalls the GPU on a pagefault on IOMMU v1 HW. |
| 85 | * KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE -> BIT(2) Set to log only one |
| 86 | * pagefault per page. |
| 87 | * KGSL_FT_PAGEFAULT_LOG_ONE_PER_INT -> BIT(3) Set to log only one |
| 88 | * pagefault per INT. |
| 89 | */ |
| 90 | adreno_dev->ft_pf_policy = KGSL_FT_PAGEFAULT_DEFAULT_POLICY; |
| 91 | debugfs_create_u32("ft_pagefault_policy", 0644, device->d_debugfs, |
| 92 | &adreno_dev->ft_pf_policy); |
| 93 | |
| 94 | debugfs_create_file("active_cnt", 0444, device->d_debugfs, device, |
| 95 | &_active_count_fops); |
| 96 | } |