Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2002,2008-2012, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 14 | #include <linux/export.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #include "adreno.h" |
| 22 | |
Jeremy Gebben | eebc461 | 2011-08-31 10:15:21 -0700 | [diff] [blame] | 23 | #include "a2xx_reg.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | |
| 25 | unsigned int kgsl_cff_dump_enable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | |
| 27 | static 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 | |
| 37 | static int kgsl_cff_dump_enable_get(void *data, u64 *val) |
| 38 | { |
| 39 | *val = kgsl_cff_dump_enable; |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get, |
| 44 | kgsl_cff_dump_enable_set, "%llu\n"); |
| 45 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | typedef void (*reg_read_init_t)(struct kgsl_device *device); |
| 47 | typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i, |
| 48 | unsigned int *vals, int linec); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 49 | |
| 50 | void adreno_debugfs_init(struct kgsl_device *device) |
| 51 | { |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 52 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 53 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 54 | if (!device->d_debugfs || IS_ERR(device->d_debugfs)) |
| 55 | return; |
| 56 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | debugfs_create_file("cff_dump", 0644, device->d_debugfs, device, |
| 58 | &kgsl_cff_dump_enable_fops); |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 59 | debugfs_create_u32("wait_timeout", 0644, device->d_debugfs, |
| 60 | &adreno_dev->wait_timeout); |
Jeremy Gebben | d0ab6ad | 2012-04-06 11:13:35 -0600 | [diff] [blame] | 61 | debugfs_create_u32("ib_check", 0644, device->d_debugfs, |
| 62 | &adreno_dev->ib_check_level); |
Tarun Karra | 3335f14 | 2012-06-19 14:11:48 -0700 | [diff] [blame] | 63 | /* 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 Karra | 987e2f7 | 2013-02-14 12:12:22 -0800 | [diff] [blame^] | 67 | |
| 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 Karra | deeecc0 | 2013-01-21 23:42:17 -0800 | [diff] [blame] | 72 | /* |
| 73 | * FT policy can be set to any of the options below. |
Tarun Karra | 3164fb0 | 2013-02-05 15:38:51 -0800 | [diff] [blame] | 74 | * 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 Karra | deeecc0 | 2013-01-21 23:42:17 -0800 | [diff] [blame] | 79 | */ |
Tarun Karra | 3164fb0 | 2013-02-05 15:38:51 -0800 | [diff] [blame] | 80 | adreno_dev->ft_policy = KGSL_FT_DEFAULT_POLICY; |
Tarun Karra | 99678f8 | 2013-02-13 13:57:25 -0800 | [diff] [blame] | 81 | debugfs_create_u32("ft_policy", 0644, device->d_debugfs, |
Tarun Karra | deeecc0 | 2013-01-21 23:42:17 -0800 | [diff] [blame] | 82 | &adreno_dev->ft_policy); |
Tarun Karra | 99678f8 | 2013-02-13 13:57:25 -0800 | [diff] [blame] | 83 | |
Tarun Karra | 696f89e | 2013-01-27 21:31:40 -0800 | [diff] [blame] | 84 | /* 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 Karra | 99678f8 | 2013-02-13 13:57:25 -0800 | [diff] [blame] | 88 | |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | } |