Skip to content
Snippets Groups Projects
Commit ad82c662 authored by Andrew Lehmer's avatar Andrew Lehmer
Browse files

Merge branch 'android-msm-angler-3.10-nyc-mr2' into android-msm-angler-3.10-oc


October 2017.2

Bug: 64693751
Change-Id: Ia1f3015683540b05e165f30649860000c940d549
Signed-off-by: default avatarAndrew Lehmer <alehmer@google.com>
parents 1da3ab4f 69169ebb
No related branches found
No related tags found
No related merge requests found
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. /* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
...@@ -101,6 +101,7 @@ static char *debugfs_buf; ...@@ -101,6 +101,7 @@ static char *debugfs_buf;
static u32 debugfs_buf_size; static u32 debugfs_buf_size;
static u32 debugfs_buf_used; static u32 debugfs_buf_used;
static int wraparound; static int wraparound;
static struct mutex sps_debugfs_lock;
struct dentry *dent; struct dentry *dent;
struct dentry *dfile_info; struct dentry *dfile_info;
...@@ -118,6 +119,7 @@ static struct sps_bam *phy2bam(phys_addr_t phys_addr); ...@@ -118,6 +119,7 @@ static struct sps_bam *phy2bam(phys_addr_t phys_addr);
/* record debug info for debugfs */ /* record debug info for debugfs */
void sps_debugfs_record(const char *msg) void sps_debugfs_record(const char *msg)
{ {
mutex_lock(&sps_debugfs_lock);
if (debugfs_record_enabled) { if (debugfs_record_enabled) {
if (debugfs_buf_used + MAX_MSG_LEN >= debugfs_buf_size) { if (debugfs_buf_used + MAX_MSG_LEN >= debugfs_buf_size) {
debugfs_buf_used = 0; debugfs_buf_used = 0;
...@@ -131,6 +133,7 @@ void sps_debugfs_record(const char *msg) ...@@ -131,6 +133,7 @@ void sps_debugfs_record(const char *msg)
debugfs_buf_size - debugfs_buf_used, debugfs_buf_size - debugfs_buf_used,
"\n**** end line of sps log ****\n\n"); "\n**** end line of sps log ****\n\n");
} }
mutex_unlock(&sps_debugfs_lock);
} }
/* read the recorded debug info to userspace */ /* read the recorded debug info to userspace */
...@@ -140,6 +143,7 @@ static ssize_t sps_read_info(struct file *file, char __user *ubuf, ...@@ -140,6 +143,7 @@ static ssize_t sps_read_info(struct file *file, char __user *ubuf,
int ret = 0; int ret = 0;
int size; int size;
mutex_lock(&sps_debugfs_lock);
if (debugfs_record_enabled) { if (debugfs_record_enabled) {
if (wraparound) if (wraparound)
size = debugfs_buf_size - MAX_MSG_LEN; size = debugfs_buf_size - MAX_MSG_LEN;
...@@ -149,6 +153,7 @@ static ssize_t sps_read_info(struct file *file, char __user *ubuf, ...@@ -149,6 +153,7 @@ static ssize_t sps_read_info(struct file *file, char __user *ubuf,
ret = simple_read_from_buffer(ubuf, count, ppos, ret = simple_read_from_buffer(ubuf, count, ppos,
debugfs_buf, size); debugfs_buf, size);
} }
mutex_unlock(&sps_debugfs_lock);
return ret; return ret;
} }
...@@ -193,11 +198,13 @@ static ssize_t sps_set_info(struct file *file, const char __user *buf, ...@@ -193,11 +198,13 @@ static ssize_t sps_set_info(struct file *file, const char __user *buf,
new_buf_size = buf_size_kb * SZ_1K; new_buf_size = buf_size_kb * SZ_1K;
mutex_lock(&sps_debugfs_lock);
if (debugfs_record_enabled) { if (debugfs_record_enabled) {
if (debugfs_buf_size == new_buf_size) { if (debugfs_buf_size == new_buf_size) {
/* need do nothing */ /* need do nothing */
pr_info("sps:debugfs: input buffer size " pr_info("sps:debugfs: input buffer size "
"is the same as before.\n"); "is the same as before.\n");
mutex_unlock(&sps_debugfs_lock);
return count; return count;
} else { } else {
/* release the current buffer */ /* release the current buffer */
...@@ -217,12 +224,14 @@ static ssize_t sps_set_info(struct file *file, const char __user *buf, ...@@ -217,12 +224,14 @@ static ssize_t sps_set_info(struct file *file, const char __user *buf,
if (!debugfs_buf) { if (!debugfs_buf) {
debugfs_buf_size = 0; debugfs_buf_size = 0;
pr_err("sps:fail to allocate memory for debug_fs.\n"); pr_err("sps:fail to allocate memory for debug_fs.\n");
mutex_unlock(&sps_debugfs_lock);
return -ENOMEM; return -ENOMEM;
} }
debugfs_buf_used = 0; debugfs_buf_used = 0;
wraparound = false; wraparound = false;
debugfs_record_enabled = true; debugfs_record_enabled = true;
mutex_unlock(&sps_debugfs_lock);
return count; return count;
} }
...@@ -270,6 +279,7 @@ static ssize_t sps_set_logging_option(struct file *file, const char __user *buf, ...@@ -270,6 +279,7 @@ static ssize_t sps_set_logging_option(struct file *file, const char __user *buf,
return count; return count;
} }
mutex_lock(&sps_debugfs_lock);
if (((option == 0) || (option == 2)) && if (((option == 0) || (option == 2)) &&
((logging_option == 1) || (logging_option == 3))) { ((logging_option == 1) || (logging_option == 3))) {
debugfs_record_enabled = false; debugfs_record_enabled = false;
...@@ -281,6 +291,7 @@ static ssize_t sps_set_logging_option(struct file *file, const char __user *buf, ...@@ -281,6 +291,7 @@ static ssize_t sps_set_logging_option(struct file *file, const char __user *buf,
} }
logging_option = option; logging_option = option;
mutex_unlock(&sps_debugfs_lock);
return count; return count;
} }
...@@ -607,6 +618,8 @@ static void sps_debugfs_init(void) ...@@ -607,6 +618,8 @@ static void sps_debugfs_init(void)
goto bam_addr_err; goto bam_addr_err;
} }
mutex_init(&sps_debugfs_lock);
return; return;
bam_addr_err: bam_addr_err:
......
...@@ -61,11 +61,6 @@ extern u8 logging_option; ...@@ -61,11 +61,6 @@ extern u8 logging_option;
extern u8 debug_level_option; extern u8 debug_level_option;
extern u8 print_limit_option; extern u8 print_limit_option;
#define SPS_DEBUGFS(msg, args...) do { \
char buf[MAX_MSG_LEN]; \
snprintf(buf, MAX_MSG_LEN, msg"\n", ##args); \
sps_debugfs_record(buf); \
} while (0)
#define SPS_ERR(msg, args...) do { \ #define SPS_ERR(msg, args...) do { \
if (logging_option != 1) { \ if (logging_option != 1) { \
if (unlikely(print_limit_option > 2)) \ if (unlikely(print_limit_option > 2)) \
...@@ -73,8 +68,6 @@ extern u8 print_limit_option; ...@@ -73,8 +68,6 @@ extern u8 print_limit_option;
else \ else \
pr_err(msg, ##args); \ pr_err(msg, ##args); \
} \ } \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#define SPS_INFO(msg, args...) do { \ #define SPS_INFO(msg, args...) do { \
if (logging_option != 1) { \ if (logging_option != 1) { \
...@@ -83,8 +76,6 @@ extern u8 print_limit_option; ...@@ -83,8 +76,6 @@ extern u8 print_limit_option;
else \ else \
pr_info(msg, ##args); \ pr_info(msg, ##args); \
} \ } \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#define SPS_DBG(msg, args...) do { \ #define SPS_DBG(msg, args...) do { \
if ((unlikely(logging_option > 1)) \ if ((unlikely(logging_option > 1)) \
...@@ -95,8 +86,6 @@ extern u8 print_limit_option; ...@@ -95,8 +86,6 @@ extern u8 print_limit_option;
pr_info(msg, ##args); \ pr_info(msg, ##args); \
} else \ } else \
pr_debug(msg, ##args); \ pr_debug(msg, ##args); \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#define SPS_DBG1(msg, args...) do { \ #define SPS_DBG1(msg, args...) do { \
if ((unlikely(logging_option > 1)) \ if ((unlikely(logging_option > 1)) \
...@@ -107,8 +96,6 @@ extern u8 print_limit_option; ...@@ -107,8 +96,6 @@ extern u8 print_limit_option;
pr_info(msg, ##args); \ pr_info(msg, ##args); \
} else \ } else \
pr_debug(msg, ##args); \ pr_debug(msg, ##args); \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#define SPS_DBG2(msg, args...) do { \ #define SPS_DBG2(msg, args...) do { \
if ((unlikely(logging_option > 1)) \ if ((unlikely(logging_option > 1)) \
...@@ -119,8 +106,6 @@ extern u8 print_limit_option; ...@@ -119,8 +106,6 @@ extern u8 print_limit_option;
pr_info(msg, ##args); \ pr_info(msg, ##args); \
} else \ } else \
pr_debug(msg, ##args); \ pr_debug(msg, ##args); \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#define SPS_DBG3(msg, args...) do { \ #define SPS_DBG3(msg, args...) do { \
if ((unlikely(logging_option > 1)) \ if ((unlikely(logging_option > 1)) \
...@@ -131,8 +116,6 @@ extern u8 print_limit_option; ...@@ -131,8 +116,6 @@ extern u8 print_limit_option;
pr_info(msg, ##args); \ pr_info(msg, ##args); \
} else \ } else \
pr_debug(msg, ##args); \ pr_debug(msg, ##args); \
if (unlikely(debugfs_record_enabled)) \
SPS_DEBUGFS(msg, ##args); \
} while (0) } while (0)
#else #else
#define SPS_DBG3(x...) pr_debug(x) #define SPS_DBG3(x...) pr_debug(x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment