Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -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 | #ifdef CONFIG_DEBUG_FS |
| 14 | |
| 15 | #include <linux/slab.h> |
| 16 | #include <linux/debugfs.h> |
| 17 | #include "diagchar.h" |
| 18 | #include "diagfwd.h" |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 19 | #include "diagfwd_bridge.h" |
Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 20 | #include "diagfwd_hsic.h" |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 21 | #include "diagmem.h" |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 22 | #include "diag_dci.h" |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 23 | |
| 24 | #define DEBUG_BUF_SIZE 4096 |
| 25 | static struct dentry *diag_dbgfs_dent; |
| 26 | static int diag_dbgfs_table_index; |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 27 | static int diag_dbgfs_finished; |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 28 | static int diag_dbgfs_dci_data_index; |
| 29 | static int diag_dbgfs_dci_finished; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 30 | |
| 31 | static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, |
| 32 | size_t count, loff_t *ppos) |
| 33 | { |
| 34 | char *buf; |
| 35 | int ret; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 36 | unsigned int buf_size; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 37 | buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); |
| 38 | if (!buf) { |
| 39 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 40 | return -ENOMEM; |
| 41 | } |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 42 | buf_size = ksize(buf); |
| 43 | ret = scnprintf(buf, buf_size, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 44 | "modem ch: 0x%x\n" |
| 45 | "lpass ch: 0x%x\n" |
| 46 | "riva ch: 0x%x\n" |
| 47 | "dci ch: 0x%x\n" |
| 48 | "modem cntl_ch: 0x%x\n" |
| 49 | "lpass cntl_ch: 0x%x\n" |
| 50 | "riva cntl_ch: 0x%x\n" |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 51 | "modem cmd ch: 0x%x\n" |
| 52 | "dci cmd ch: 0x%x\n" |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 53 | "CPU Tools id: %d\n" |
| 54 | "Apps only: %d\n" |
| 55 | "Apps master: %d\n" |
| 56 | "Check Polling Response: %d\n" |
| 57 | "polling_reg_flag: %d\n" |
| 58 | "uses device tree: %d\n" |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 59 | "supports separate cmdrsp: %d\n" |
| 60 | "Modem separate cmdrsp: %d\n" |
| 61 | "LPASS separate cmdrsp: %d\n" |
| 62 | "RIVA separate cmdrsp: %d\n" |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 63 | "Modem in_busy_1: %d\n" |
| 64 | "Modem in_busy_2: %d\n" |
| 65 | "LPASS in_busy_1: %d\n" |
| 66 | "LPASS in_busy_2: %d\n" |
| 67 | "RIVA in_busy_1: %d\n" |
| 68 | "RIVA in_busy_2: %d\n" |
| 69 | "DCI Modem in_busy_1: %d\n" |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 70 | "Modem CMD in_busy_1: %d\n" |
| 71 | "Modem CMD in_busy_2: %d\n" |
| 72 | "DCI CMD Modem in_busy_1: %d\n" |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 73 | "Modem supports STM: %d\n" |
| 74 | "LPASS supports STM: %d\n" |
| 75 | "RIVA supports STM: %d\n" |
| 76 | "Modem STM state: %d\n" |
| 77 | "LPASS STM state: %d\n" |
| 78 | "RIVA STM state: %d\n" |
| 79 | "APPS STM state: %d\n" |
| 80 | "Modem STM requested state: %d\n" |
| 81 | "LPASS STM requested state: %d\n" |
| 82 | "RIVA STM requested state: %d\n" |
| 83 | "APPS STM requested state: %d\n" |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 84 | "supports apps hdlc encoding: %d\n" |
| 85 | "Modem hdlc encoding: %d\n" |
| 86 | "Lpass hdlc encoding: %d\n" |
| 87 | "RIVA hdlc encoding: %d\n" |
| 88 | "Modem CMD hdlc encoding: %d\n" |
Dixon Peterson | d2309b4 | 2013-08-28 21:00:05 -0700 | [diff] [blame] | 89 | "Modem DATA in_buf_1_size: %d\n" |
| 90 | "Modem DATA in_buf_2_size: %d\n" |
| 91 | "ADSP DATA in_buf_1_size: %d\n" |
| 92 | "ADSP DATA in_buf_2_size: %d\n" |
| 93 | "RIVA DATA in_buf_1_size: %d\n" |
| 94 | "RIVA DATA in_buf_2_size: %d\n" |
| 95 | "Modem DATA in_buf_1_raw_size: %d\n" |
| 96 | "Modem DATA in_buf_2_raw_size: %d\n" |
| 97 | "ADSP DATA in_buf_1_raw_size: %d\n" |
| 98 | "ADSP DATA in_buf_2_raw_size: %d\n" |
| 99 | "RIVA DATA in_buf_1_raw_size: %d\n" |
| 100 | "RIVA DATA in_buf_2_raw_size: %d\n" |
| 101 | "Modem CMD in_buf_1_size: %d\n" |
| 102 | "Modem CMD in_buf_1_raw_size: %d\n" |
| 103 | "Modem CNTL in_buf_1_size: %d\n" |
| 104 | "ADSP CNTL in_buf_1_size: %d\n" |
| 105 | "RIVA CNTL in_buf_1_size: %d\n" |
| 106 | "Modem DCI in_buf_1_size: %d\n" |
| 107 | "Modem DCI CMD in_buf_1_size: %d\n" |
Ravi Aravamudhan | 91391ce | 2013-10-01 17:09:50 -0700 | [diff] [blame] | 108 | "Received Feature mask from Modem: %d\n" |
| 109 | "Received Feature mask from LPASS: %d\n" |
| 110 | "Received Feature mask from WCNSS: %d\n" |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 111 | "logging_mode: %d\n" |
| 112 | "real_time_mode: %d\n", |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 113 | (unsigned int)driver->smd_data[MODEM_DATA].ch, |
| 114 | (unsigned int)driver->smd_data[LPASS_DATA].ch, |
| 115 | (unsigned int)driver->smd_data[WCNSS_DATA].ch, |
| 116 | (unsigned int)driver->smd_dci[MODEM_DATA].ch, |
| 117 | (unsigned int)driver->smd_cntl[MODEM_DATA].ch, |
| 118 | (unsigned int)driver->smd_cntl[LPASS_DATA].ch, |
| 119 | (unsigned int)driver->smd_cntl[WCNSS_DATA].ch, |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 120 | (unsigned int)driver->smd_cmd[MODEM_DATA].ch, |
| 121 | (unsigned int)driver->smd_dci_cmd[MODEM_DATA].ch, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 122 | chk_config_get_id(), |
| 123 | chk_apps_only(), |
| 124 | chk_apps_master(), |
| 125 | chk_polling_response(), |
| 126 | driver->polling_reg_flag, |
| 127 | driver->use_device_tree, |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 128 | driver->supports_separate_cmdrsp, |
| 129 | driver->separate_cmdrsp[MODEM_DATA], |
| 130 | driver->separate_cmdrsp[LPASS_DATA], |
| 131 | driver->separate_cmdrsp[WCNSS_DATA], |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 132 | driver->smd_data[MODEM_DATA].in_busy_1, |
| 133 | driver->smd_data[MODEM_DATA].in_busy_2, |
| 134 | driver->smd_data[LPASS_DATA].in_busy_1, |
| 135 | driver->smd_data[LPASS_DATA].in_busy_2, |
| 136 | driver->smd_data[WCNSS_DATA].in_busy_1, |
| 137 | driver->smd_data[WCNSS_DATA].in_busy_2, |
| 138 | driver->smd_dci[MODEM_DATA].in_busy_1, |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 139 | driver->smd_cmd[MODEM_DATA].in_busy_1, |
| 140 | driver->smd_cmd[MODEM_DATA].in_busy_2, |
| 141 | driver->smd_dci_cmd[MODEM_DATA].in_busy_1, |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 142 | driver->peripheral_supports_stm[MODEM_DATA], |
| 143 | driver->peripheral_supports_stm[LPASS_DATA], |
| 144 | driver->peripheral_supports_stm[WCNSS_DATA], |
| 145 | driver->stm_state[MODEM_DATA], |
| 146 | driver->stm_state[LPASS_DATA], |
| 147 | driver->stm_state[WCNSS_DATA], |
| 148 | driver->stm_state[APPS_DATA], |
| 149 | driver->stm_state_requested[MODEM_DATA], |
| 150 | driver->stm_state_requested[LPASS_DATA], |
| 151 | driver->stm_state_requested[WCNSS_DATA], |
| 152 | driver->stm_state_requested[APPS_DATA], |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 153 | driver->supports_apps_hdlc_encoding, |
| 154 | driver->smd_data[MODEM_DATA].encode_hdlc, |
| 155 | driver->smd_data[LPASS_DATA].encode_hdlc, |
| 156 | driver->smd_data[WCNSS_DATA].encode_hdlc, |
| 157 | driver->smd_cmd[MODEM_DATA].encode_hdlc, |
Dixon Peterson | d2309b4 | 2013-08-28 21:00:05 -0700 | [diff] [blame] | 158 | (unsigned int)driver->smd_data[MODEM_DATA].buf_in_1_size, |
| 159 | (unsigned int)driver->smd_data[MODEM_DATA].buf_in_2_size, |
| 160 | (unsigned int)driver->smd_data[LPASS_DATA].buf_in_1_size, |
| 161 | (unsigned int)driver->smd_data[LPASS_DATA].buf_in_2_size, |
| 162 | (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_1_size, |
| 163 | (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_2_size, |
| 164 | (unsigned int)driver->smd_data[MODEM_DATA].buf_in_1_raw_size, |
| 165 | (unsigned int)driver->smd_data[MODEM_DATA].buf_in_2_raw_size, |
| 166 | (unsigned int)driver->smd_data[LPASS_DATA].buf_in_1_raw_size, |
| 167 | (unsigned int)driver->smd_data[LPASS_DATA].buf_in_2_raw_size, |
| 168 | (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_1_raw_size, |
| 169 | (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_2_raw_size, |
| 170 | (unsigned int)driver->smd_cmd[MODEM_DATA].buf_in_1_size, |
| 171 | (unsigned int)driver->smd_cmd[MODEM_DATA].buf_in_1_raw_size, |
| 172 | (unsigned int)driver->smd_cntl[MODEM_DATA].buf_in_1_size, |
| 173 | (unsigned int)driver->smd_cntl[LPASS_DATA].buf_in_1_size, |
| 174 | (unsigned int)driver->smd_cntl[WCNSS_DATA].buf_in_1_size, |
| 175 | (unsigned int)driver->smd_dci[MODEM_DATA].buf_in_1_size, |
| 176 | (unsigned int)driver->smd_dci_cmd[MODEM_DATA].buf_in_1_size, |
Ravi Aravamudhan | 91391ce | 2013-10-01 17:09:50 -0700 | [diff] [blame] | 177 | driver->rcvd_feature_mask[MODEM_DATA], |
| 178 | driver->rcvd_feature_mask[LPASS_DATA], |
| 179 | driver->rcvd_feature_mask[WCNSS_DATA], |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 180 | driver->logging_mode, |
| 181 | driver->real_time_mode); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 182 | |
| 183 | #ifdef CONFIG_DIAG_OVER_USB |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 184 | ret += scnprintf(buf+ret, buf_size-ret, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 185 | "usb_connected: %d\n", |
| 186 | driver->usb_connected); |
| 187 | #endif |
| 188 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); |
| 189 | |
| 190 | kfree(buf); |
| 191 | return ret; |
| 192 | } |
| 193 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 194 | static ssize_t diag_dbgfs_read_dcistats(struct file *file, |
| 195 | char __user *ubuf, size_t count, loff_t *ppos) |
| 196 | { |
| 197 | char *buf = NULL; |
Katish Paran | 3e20090 | 2013-12-24 17:46:29 +0530 | [diff] [blame] | 198 | unsigned int bytes_remaining, bytes_written = 0; |
| 199 | unsigned int bytes_in_buf = 0, i = 0; |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 200 | struct diag_dci_data_info *temp_data = dci_data_smd; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 201 | unsigned int buf_size; |
| 202 | buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 203 | |
| 204 | if (diag_dbgfs_dci_finished) { |
| 205 | diag_dbgfs_dci_finished = 0; |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | buf = kzalloc(sizeof(char) * buf_size, GFP_KERNEL); |
| 210 | if (ZERO_OR_NULL_PTR(buf)) { |
| 211 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 212 | return -ENOMEM; |
| 213 | } |
| 214 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 215 | buf_size = ksize(buf); |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 216 | bytes_remaining = buf_size; |
| 217 | |
| 218 | if (diag_dbgfs_dci_data_index == 0) { |
| 219 | bytes_written = |
| 220 | scnprintf(buf, buf_size, |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 221 | "number of clients: %d\n" |
| 222 | "dci proc active: %d\n" |
| 223 | "dci real time vote: %d\n", |
| 224 | driver->num_dci_client, |
| 225 | (driver->proc_active_mask & DIAG_PROC_DCI) ? 1 : 0, |
| 226 | (driver->proc_rt_vote_mask & DIAG_PROC_DCI) ? 1 : 0); |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 227 | bytes_in_buf += bytes_written; |
| 228 | bytes_remaining -= bytes_written; |
| 229 | #ifdef CONFIG_DIAG_OVER_USB |
| 230 | bytes_written = scnprintf(buf+bytes_in_buf, bytes_remaining, |
| 231 | "usb_connected: %d\n", |
| 232 | driver->usb_connected); |
| 233 | bytes_in_buf += bytes_written; |
| 234 | bytes_remaining -= bytes_written; |
| 235 | #endif |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 236 | bytes_written = scnprintf(buf+bytes_in_buf, |
| 237 | bytes_remaining, |
| 238 | "dci power: active, relax: %lu, %lu\n", |
| 239 | driver->diag_dev->power.wakeup-> |
| 240 | active_count, |
| 241 | driver->diag_dev-> |
| 242 | power.wakeup->relax_count); |
| 243 | bytes_in_buf += bytes_written; |
| 244 | bytes_remaining -= bytes_written; |
| 245 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 246 | } |
| 247 | temp_data += diag_dbgfs_dci_data_index; |
| 248 | for (i = diag_dbgfs_dci_data_index; i < DIAG_DCI_DEBUG_CNT; i++) { |
| 249 | if (temp_data->iteration != 0) { |
| 250 | bytes_written = scnprintf( |
| 251 | buf + bytes_in_buf, bytes_remaining, |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 252 | "i %-5ld\t" |
| 253 | "s %-5d\t" |
| 254 | "p %-5d\t" |
| 255 | "c %-5d\t" |
Ravi Aravamudhan | 67db95c | 2013-07-18 10:00:50 -0700 | [diff] [blame] | 256 | "t %-15s\n", |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 257 | temp_data->iteration, |
| 258 | temp_data->data_size, |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 259 | temp_data->peripheral, |
Ravi Aravamudhan | 67db95c | 2013-07-18 10:00:50 -0700 | [diff] [blame] | 260 | temp_data->ch_type, |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 261 | temp_data->time_stamp); |
| 262 | bytes_in_buf += bytes_written; |
| 263 | bytes_remaining -= bytes_written; |
| 264 | /* Check if there is room for another entry */ |
| 265 | if (bytes_remaining < bytes_written) |
| 266 | break; |
| 267 | } |
| 268 | temp_data++; |
| 269 | } |
| 270 | |
| 271 | diag_dbgfs_dci_data_index = (i >= DIAG_DCI_DEBUG_CNT) ? 0 : i + 1; |
| 272 | bytes_written = simple_read_from_buffer(ubuf, count, ppos, buf, |
| 273 | bytes_in_buf); |
| 274 | kfree(buf); |
| 275 | diag_dbgfs_dci_finished = 1; |
| 276 | return bytes_written; |
| 277 | } |
| 278 | |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 279 | static ssize_t diag_dbgfs_read_workpending(struct file *file, |
| 280 | char __user *ubuf, size_t count, loff_t *ppos) |
| 281 | { |
| 282 | char *buf; |
| 283 | int ret; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 284 | unsigned int buf_size; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 285 | |
| 286 | buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); |
| 287 | if (!buf) { |
| 288 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 289 | return -ENOMEM; |
| 290 | } |
| 291 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 292 | buf_size = ksize(buf); |
| 293 | ret = scnprintf(buf, buf_size, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 294 | "Pending status for work_stucts:\n" |
| 295 | "diag_drain_work: %d\n" |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 296 | "Modem data diag_read_smd_work: %d\n" |
| 297 | "LPASS data diag_read_smd_work: %d\n" |
| 298 | "RIVA data diag_read_smd_work: %d\n" |
| 299 | "Modem cntl diag_read_smd_work: %d\n" |
| 300 | "LPASS cntl diag_read_smd_work: %d\n" |
| 301 | "RIVA cntl diag_read_smd_work: %d\n" |
| 302 | "Modem dci diag_read_smd_work: %d\n" |
| 303 | "Modem data diag_notify_update_smd_work: %d\n" |
| 304 | "LPASS data diag_notify_update_smd_work: %d\n" |
| 305 | "RIVA data diag_notify_update_smd_work: %d\n" |
| 306 | "Modem cntl diag_notify_update_smd_work: %d\n" |
| 307 | "LPASS cntl diag_notify_update_smd_work: %d\n" |
| 308 | "RIVA cntl diag_notify_update_smd_work: %d\n" |
| 309 | "Modem dci diag_notify_update_smd_work: %d\n", |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 310 | work_pending(&(driver->diag_drain_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 311 | work_pending(&(driver->smd_data[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 312 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 313 | work_pending(&(driver->smd_data[LPASS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 314 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 315 | work_pending(&(driver->smd_data[WCNSS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 316 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 317 | work_pending(&(driver->smd_cntl[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 318 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 319 | work_pending(&(driver->smd_cntl[LPASS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 320 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 321 | work_pending(&(driver->smd_cntl[WCNSS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 322 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 323 | work_pending(&(driver->smd_dci[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 324 | diag_read_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 325 | work_pending(&(driver->smd_data[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 326 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 327 | work_pending(&(driver->smd_data[LPASS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 328 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 329 | work_pending(&(driver->smd_data[WCNSS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 330 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 331 | work_pending(&(driver->smd_cntl[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 332 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 333 | work_pending(&(driver->smd_cntl[LPASS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 334 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 335 | work_pending(&(driver->smd_cntl[WCNSS_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 336 | diag_notify_update_smd_work)), |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 337 | work_pending(&(driver->smd_dci[MODEM_DATA]. |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 338 | diag_notify_update_smd_work))); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 339 | |
| 340 | #ifdef CONFIG_DIAG_OVER_USB |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 341 | ret += scnprintf(buf+ret, buf_size-ret, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 342 | "diag_proc_hdlc_work: %d\n" |
| 343 | "diag_read_work: %d\n", |
| 344 | work_pending(&(driver->diag_proc_hdlc_work)), |
| 345 | work_pending(&(driver->diag_read_work))); |
| 346 | #endif |
| 347 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); |
| 348 | |
| 349 | kfree(buf); |
| 350 | return ret; |
| 351 | } |
| 352 | |
| 353 | static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf, |
| 354 | size_t count, loff_t *ppos) |
| 355 | { |
| 356 | char *buf; |
| 357 | int ret = 0; |
| 358 | int i; |
Katish Paran | 3e20090 | 2013-12-24 17:46:29 +0530 | [diff] [blame] | 359 | unsigned int bytes_remaining; |
| 360 | unsigned int bytes_in_buffer = 0; |
| 361 | unsigned int bytes_written; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 362 | unsigned int buf_size; |
| 363 | buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 364 | |
| 365 | if (diag_dbgfs_table_index >= diag_max_reg) { |
| 366 | /* Done. Reset to prepare for future requests */ |
| 367 | diag_dbgfs_table_index = 0; |
| 368 | return 0; |
| 369 | } |
| 370 | |
| 371 | buf = kzalloc(sizeof(char) * buf_size, GFP_KERNEL); |
Ashay Jaiswal | f7e265a | 2013-06-05 13:24:38 +0530 | [diff] [blame] | 372 | if (ZERO_OR_NULL_PTR(buf)) { |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 373 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 374 | return -ENOMEM; |
| 375 | } |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 376 | buf_size = ksize(buf); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 377 | bytes_remaining = buf_size; |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 378 | |
| 379 | if (diag_dbgfs_table_index == 0) { |
| 380 | bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining, |
| 381 | "Client ids: Modem: %d, LPASS: %d, " |
| 382 | "WCNSS: %d, APPS: %d\n", |
| 383 | MODEM_DATA, LPASS_DATA, WCNSS_DATA, APPS_DATA); |
| 384 | bytes_in_buffer += bytes_written; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 385 | bytes_remaining -= bytes_written; |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 386 | } |
| 387 | |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 388 | for (i = diag_dbgfs_table_index; i < diag_max_reg; i++) { |
| 389 | /* Do not process empty entries in the table */ |
| 390 | if (driver->table[i].process_id == 0) |
| 391 | continue; |
| 392 | |
| 393 | bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining, |
| 394 | "i: %3d, cmd_code: %4x, subsys_id: %4x, " |
| 395 | "client: %2d, cmd_code_lo: %4x, " |
Ravi Aravamudhan | 8081a13 | 2013-08-02 12:19:28 -0700 | [diff] [blame] | 396 | "cmd_code_hi: %4x, process_id: %5d %s\n", |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 397 | i, |
| 398 | driver->table[i].cmd_code, |
| 399 | driver->table[i].subsys_id, |
| 400 | driver->table[i].client_id, |
| 401 | driver->table[i].cmd_code_lo, |
| 402 | driver->table[i].cmd_code_hi, |
Ravi Aravamudhan | 8081a13 | 2013-08-02 12:19:28 -0700 | [diff] [blame] | 403 | driver->table[i].process_id, |
| 404 | (diag_find_polling_reg(i) ? "<- Polling cmd reg" : "")); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 405 | |
| 406 | bytes_in_buffer += bytes_written; |
| 407 | |
| 408 | /* Check if there is room to add another table entry */ |
| 409 | bytes_remaining = buf_size - bytes_in_buffer; |
Ravi Aravamudhan | 8081a13 | 2013-08-02 12:19:28 -0700 | [diff] [blame] | 410 | |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 411 | if (bytes_remaining < bytes_written) |
| 412 | break; |
| 413 | } |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 414 | diag_dbgfs_table_index = i+1; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 415 | |
| 416 | *ppos = 0; |
| 417 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer); |
| 418 | |
| 419 | kfree(buf); |
| 420 | return ret; |
| 421 | } |
| 422 | |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 423 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 424 | static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, |
| 425 | size_t count, loff_t *ppos) |
| 426 | { |
| 427 | char *buf = NULL; |
| 428 | int ret = 0, i = 0; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 429 | unsigned int buf_size; |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 430 | buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); |
| 431 | if (ZERO_OR_NULL_PTR(buf)) { |
| 432 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 433 | return -ENOMEM; |
| 434 | } |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 435 | buf_size = ksize(buf); |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 436 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 437 | ret = scnprintf(buf, buf_size, |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 438 | "POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n" |
| 439 | "POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n" |
| 440 | "POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n" |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 441 | "POOL_TYPE_WRITE_STRUCT: [0x%p : 0x%p] count = %d\n" |
| 442 | "POOL_TYPE_DCI: [0x%p : 0x%p] count = %d\n", |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 443 | driver->diagpool, |
| 444 | diag_pools_array[POOL_COPY_IDX], |
| 445 | driver->count, |
| 446 | driver->diag_hdlc_pool, |
| 447 | diag_pools_array[POOL_HDLC_IDX], |
| 448 | driver->count_hdlc_pool, |
| 449 | driver->diag_user_pool, |
| 450 | diag_pools_array[POOL_USER_IDX], |
| 451 | driver->count_user_pool, |
| 452 | driver->diag_write_struct_pool, |
| 453 | diag_pools_array[POOL_WRITE_STRUCT_IDX], |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 454 | driver->count_write_struct_pool, |
| 455 | driver->diag_dci_pool, |
| 456 | diag_pools_array[POOL_DCI_IDX], |
| 457 | driver->count_dci_pool); |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 458 | |
| 459 | for (i = 0; i < MAX_HSIC_CH; i++) { |
| 460 | if (!diag_hsic[i].hsic_inited) |
| 461 | continue; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 462 | ret += scnprintf(buf+ret, buf_size-ret, |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 463 | "POOL_TYPE_HSIC_%d: [0x%p : 0x%p] count = %d\n", |
| 464 | i+1, |
| 465 | diag_hsic[i].diag_hsic_pool, |
| 466 | diag_pools_array[POOL_HSIC_IDX + i], |
| 467 | diag_hsic[i].count_hsic_pool); |
| 468 | } |
| 469 | |
| 470 | for (i = 0; i < MAX_HSIC_CH; i++) { |
| 471 | if (!diag_hsic[i].hsic_inited) |
| 472 | continue; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 473 | ret += scnprintf(buf+ret, buf_size-ret, |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 474 | "POOL_TYPE_HSIC_%d_WRITE: [0x%p : 0x%p] count = %d\n", |
| 475 | i+1, |
| 476 | diag_hsic[i].diag_hsic_write_pool, |
| 477 | diag_pools_array[POOL_HSIC_WRITE_IDX + i], |
| 478 | diag_hsic[i].count_hsic_write_pool); |
| 479 | } |
| 480 | |
| 481 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); |
| 482 | |
| 483 | kfree(buf); |
| 484 | return ret; |
| 485 | } |
| 486 | #else |
| 487 | static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, |
| 488 | size_t count, loff_t *ppos) |
| 489 | { |
| 490 | char *buf = NULL; |
| 491 | int ret = 0; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 492 | unsigned int buf_size; |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 493 | |
| 494 | buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); |
| 495 | if (ZERO_OR_NULL_PTR(buf)) { |
| 496 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 497 | return -ENOMEM; |
| 498 | } |
| 499 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 500 | buf_size = ksize(buf); |
| 501 | ret = scnprintf(buf, buf_size, |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 502 | "POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n" |
| 503 | "POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n" |
| 504 | "POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n" |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 505 | "POOL_TYPE_WRITE_STRUCT: [0x%p : 0x%p] count = %d\n" |
| 506 | "POOL_TYPE_DCI: [0x%p : 0x%p] count = %d\n", |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 507 | driver->diagpool, |
| 508 | diag_pools_array[POOL_COPY_IDX], |
| 509 | driver->count, |
| 510 | driver->diag_hdlc_pool, |
| 511 | diag_pools_array[POOL_HDLC_IDX], |
| 512 | driver->count_hdlc_pool, |
| 513 | driver->diag_user_pool, |
| 514 | diag_pools_array[POOL_USER_IDX], |
| 515 | driver->count_user_pool, |
| 516 | driver->diag_write_struct_pool, |
| 517 | diag_pools_array[POOL_WRITE_STRUCT_IDX], |
Katish Paran | 244514d | 2013-08-01 18:39:31 -0700 | [diff] [blame] | 518 | driver->count_write_struct_pool, |
| 519 | driver->diag_dci_pool, |
| 520 | diag_pools_array[POOL_DCI_IDX], |
| 521 | driver->count_dci_pool); |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 522 | |
| 523 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); |
| 524 | |
| 525 | kfree(buf); |
| 526 | return ret; |
| 527 | } |
| 528 | #endif |
| 529 | |
| 530 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 531 | static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 532 | size_t count, loff_t *ppos) |
| 533 | { |
| 534 | char *buf; |
| 535 | int ret; |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 536 | int i; |
Katish Paran | 3e20090 | 2013-12-24 17:46:29 +0530 | [diff] [blame] | 537 | unsigned int bytes_remaining; |
| 538 | unsigned int bytes_in_buffer = 0; |
| 539 | unsigned int bytes_written; |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 540 | unsigned int buf_size; |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 541 | int bytes_hsic_inited = 45; |
| 542 | int bytes_hsic_not_inited = 410; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 543 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 544 | buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; |
| 545 | |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 546 | if (diag_dbgfs_finished) { |
| 547 | diag_dbgfs_finished = 0; |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | buf = kzalloc(sizeof(char) * buf_size, GFP_KERNEL); |
Ashay Jaiswal | f7e265a | 2013-06-05 13:24:38 +0530 | [diff] [blame] | 552 | if (ZERO_OR_NULL_PTR(buf)) { |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 553 | pr_err("diag: %s, Error allocating memory\n", __func__); |
| 554 | return -ENOMEM; |
| 555 | } |
| 556 | |
Sreelakshmi Gownipalli | 965c07f | 2014-01-14 16:54:46 -0800 | [diff] [blame] | 557 | buf_size = ksize(buf); |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 558 | bytes_remaining = buf_size; |
| 559 | |
| 560 | /* Only one smux for now */ |
| 561 | bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining, |
| 562 | "Values for SMUX instance: 0\n" |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 563 | "smux ch: %d\n" |
| 564 | "smux enabled %d\n" |
| 565 | "smux in busy %d\n" |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 566 | "smux connected %d\n\n", |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 567 | driver->lcid, |
| 568 | driver->diag_smux_enabled, |
| 569 | driver->in_busy_smux, |
| 570 | driver->smux_connected); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 571 | |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 572 | bytes_in_buffer += bytes_written; |
| 573 | bytes_remaining = buf_size - bytes_in_buffer; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 574 | |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 575 | bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining, |
| 576 | "HSIC diag_disconnect_work: %d\n", |
| 577 | work_pending(&(driver->diag_disconnect_work))); |
| 578 | |
| 579 | bytes_in_buffer += bytes_written; |
| 580 | bytes_remaining = buf_size - bytes_in_buffer; |
| 581 | |
| 582 | for (i = 0; i < MAX_HSIC_CH; i++) { |
| 583 | if (diag_hsic[i].hsic_inited) { |
| 584 | /* Check if there is room to add another HSIC entry */ |
| 585 | if (bytes_remaining < bytes_hsic_inited) |
| 586 | break; |
| 587 | bytes_written = scnprintf(buf+bytes_in_buffer, |
| 588 | bytes_remaining, |
| 589 | "Values for HSIC Instance: %d\n" |
| 590 | "hsic ch: %d\n" |
| 591 | "hsic_inited: %d\n" |
| 592 | "hsic enabled: %d\n" |
| 593 | "hsic_opened: %d\n" |
| 594 | "hsic_suspend: %d\n" |
| 595 | "in_busy_hsic_read_on_device: %d\n" |
| 596 | "in_busy_hsic_write: %d\n" |
| 597 | "count_hsic_pool: %d\n" |
| 598 | "count_hsic_write_pool: %d\n" |
Ravi Aravamudhan | 910f566 | 2014-01-21 10:07:06 -0800 | [diff] [blame] | 599 | "diag_hsic_pool: %p\n" |
| 600 | "diag_hsic_write_pool: %p\n" |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 601 | "HSIC write_len: %d\n" |
| 602 | "num_hsic_buf_tbl_entries: %d\n" |
| 603 | "HSIC usb_connected: %d\n" |
| 604 | "HSIC diag_read_work: %d\n" |
| 605 | "diag_read_hsic_work: %d\n" |
| 606 | "diag_usb_read_complete_work: %d\n\n", |
| 607 | i, |
| 608 | diag_hsic[i].hsic_ch, |
| 609 | diag_hsic[i].hsic_inited, |
| 610 | diag_hsic[i].hsic_device_enabled, |
| 611 | diag_hsic[i].hsic_device_opened, |
| 612 | diag_hsic[i].hsic_suspend, |
| 613 | diag_hsic[i].in_busy_hsic_read_on_device, |
| 614 | diag_hsic[i].in_busy_hsic_write, |
| 615 | diag_hsic[i].count_hsic_pool, |
| 616 | diag_hsic[i].count_hsic_write_pool, |
Ravi Aravamudhan | 910f566 | 2014-01-21 10:07:06 -0800 | [diff] [blame] | 617 | diag_hsic[i].diag_hsic_pool, |
| 618 | diag_hsic[i].diag_hsic_write_pool, |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 619 | diag_bridge[i].write_len, |
| 620 | diag_hsic[i].num_hsic_buf_tbl_entries, |
| 621 | diag_bridge[i].usb_connected, |
| 622 | work_pending(&(diag_bridge[i].diag_read_work)), |
| 623 | work_pending(&(diag_hsic[i].diag_read_hsic_work)), |
| 624 | work_pending(&(diag_bridge[i].usb_read_complete_work))); |
| 625 | if (bytes_written > bytes_hsic_inited) |
| 626 | bytes_hsic_inited = bytes_written; |
| 627 | } else { |
| 628 | /* Check if there is room to add another HSIC entry */ |
| 629 | if (bytes_remaining < bytes_hsic_not_inited) |
| 630 | break; |
| 631 | bytes_written = scnprintf(buf+bytes_in_buffer, |
| 632 | bytes_remaining, |
| 633 | "HSIC Instance: %d has not been initialized\n\n", |
| 634 | i); |
| 635 | if (bytes_written > bytes_hsic_not_inited) |
| 636 | bytes_hsic_not_inited = bytes_written; |
| 637 | } |
| 638 | |
| 639 | bytes_in_buffer += bytes_written; |
| 640 | |
| 641 | bytes_remaining = buf_size - bytes_in_buffer; |
| 642 | } |
| 643 | |
| 644 | *ppos = 0; |
| 645 | ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer); |
| 646 | |
| 647 | diag_dbgfs_finished = 1; |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 648 | kfree(buf); |
| 649 | return ret; |
| 650 | } |
| 651 | |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 652 | const struct file_operations diag_dbgfs_bridge_ops = { |
| 653 | .read = diag_dbgfs_read_bridge, |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 654 | }; |
| 655 | #endif |
| 656 | |
| 657 | const struct file_operations diag_dbgfs_status_ops = { |
| 658 | .read = diag_dbgfs_read_status, |
| 659 | }; |
| 660 | |
| 661 | const struct file_operations diag_dbgfs_table_ops = { |
| 662 | .read = diag_dbgfs_read_table, |
| 663 | }; |
| 664 | |
| 665 | const struct file_operations diag_dbgfs_workpending_ops = { |
| 666 | .read = diag_dbgfs_read_workpending, |
| 667 | }; |
| 668 | |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 669 | const struct file_operations diag_dbgfs_mempool_ops = { |
| 670 | .read = diag_dbgfs_read_mempool, |
| 671 | }; |
| 672 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 673 | const struct file_operations diag_dbgfs_dcistats_ops = { |
| 674 | .read = diag_dbgfs_read_dcistats, |
| 675 | }; |
| 676 | |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 677 | void diag_debugfs_init(void) |
| 678 | { |
| 679 | diag_dbgfs_dent = debugfs_create_dir("diag", 0); |
| 680 | if (IS_ERR(diag_dbgfs_dent)) |
| 681 | return; |
| 682 | |
| 683 | debugfs_create_file("status", 0444, diag_dbgfs_dent, 0, |
| 684 | &diag_dbgfs_status_ops); |
| 685 | |
| 686 | debugfs_create_file("table", 0444, diag_dbgfs_dent, 0, |
| 687 | &diag_dbgfs_table_ops); |
| 688 | |
| 689 | debugfs_create_file("work_pending", 0444, diag_dbgfs_dent, 0, |
| 690 | &diag_dbgfs_workpending_ops); |
| 691 | |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 692 | debugfs_create_file("mempool", 0444, diag_dbgfs_dent, 0, |
| 693 | &diag_dbgfs_mempool_ops); |
| 694 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 695 | debugfs_create_file("dci_stats", 0444, diag_dbgfs_dent, 0, |
| 696 | &diag_dbgfs_dcistats_ops); |
| 697 | |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 698 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
| 699 | debugfs_create_file("bridge", 0444, diag_dbgfs_dent, 0, |
| 700 | &diag_dbgfs_bridge_ops); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 701 | #endif |
| 702 | |
| 703 | diag_dbgfs_table_index = 0; |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 704 | diag_dbgfs_finished = 0; |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 705 | diag_dbgfs_dci_data_index = 0; |
| 706 | diag_dbgfs_dci_finished = 0; |
| 707 | |
| 708 | /* DCI related structures */ |
| 709 | dci_data_smd = kzalloc(sizeof(struct diag_dci_data_info) * |
| 710 | DIAG_DCI_DEBUG_CNT, GFP_KERNEL); |
| 711 | if (ZERO_OR_NULL_PTR(dci_data_smd)) |
| 712 | pr_warn("diag: could not allocate memory for dci debug info\n"); |
| 713 | |
| 714 | mutex_init(&dci_stat_mutex); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | void diag_debugfs_cleanup(void) |
| 718 | { |
| 719 | if (diag_dbgfs_dent) { |
| 720 | debugfs_remove_recursive(diag_dbgfs_dent); |
| 721 | diag_dbgfs_dent = NULL; |
| 722 | } |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 723 | |
| 724 | kfree(dci_data_smd); |
| 725 | mutex_destroy(&dci_stat_mutex); |
Dixon Peterson | d6a20a9 | 2012-09-27 15:58:50 -0700 | [diff] [blame] | 726 | } |
| 727 | #else |
| 728 | void diag_debugfs_init(void) { } |
| 729 | void diag_debugfs_cleanup(void) { } |
| 730 | #endif |