Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ba7e9f9 authored by Mohammed Sardar's avatar Mohammed Sardar
Browse files

msm: VPU: Make debugfs support conditional on kernel config



Previously, debugfs support was always included in the
vpu driver. This change makes debugfs support optional
as it is only required for debugging purposes.

Change-Id: I661185d838ee48a3b783c0b7952a33e2c9ab1918
Signed-off-by: default avatarMohammed Sardar <msardar@codeaurora.org>
parent 33197d65
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -10,7 +10,8 @@ obj-$(CONFIG_MSM_VPU) := \
		vpu_channel.o \
		vpu_hfi.o \
		vpu_bus_clock.o \
		vpu_debug.o \

obj-$(CONFIG_DEBUG_FS) += vpu_debug.o

obj-$(CONFIG_MSM_VPU_IN_VCAP) += vpu_in_vcap.o
obj-$(CONFIG_MSM_VPU_OUT_MDSS) += vpu_out_mdss.o
+67 −16
Original line number Diff line number Diff line
@@ -39,6 +39,13 @@
#include "vpu_translate.h"
#include "vpu_debug.h"

#define VPU_SHUTDOWN_DEFAULT_DELAY_MS	1000
#define VPU_IPC_DEFAULT_TIMEOUT_MS	1000
#define VPU_LONG_TIMEOUT_MS		10000000

u32 vpu_shutdown_delay = VPU_SHUTDOWN_DEFAULT_DELAY_MS;
u32 vpu_ipc_timeout = VPU_IPC_DEFAULT_TIMEOUT_MS;

#define MAX_CHANNELS		VPU_CHANNEL_ID_MAX
#define SYSTEM_SESSION_ID	((u32)-1)

@@ -815,8 +822,10 @@ static int ipc_cmd_sync_wait(struct vpu_sync_transact *ptrans, u32 timeout_ms,
		/* timeout */
		char dbg_buf[320];
		size_t dbg_buf_size = 320;

		pr_err("Timeout for transact 0x%08x\n",
			ptrans->seq << TRANS_SEQ_SHIFT | ptrans->id);

		strlcpy(dbg_buf, "", dbg_buf_size);
		/* cid represents Tx & Rx queues index) */
		vpu_hfi_dump_queue_headers(cid, dbg_buf, dbg_buf_size);
@@ -1148,7 +1157,7 @@ int vpu_hw_session_pause(u32 sid)
	packet.hdr.sid = sid;

	pr_debug("IPC Tx%d: CMD_SESSION_PAUSE\n", cid);
	rc = ipc_cmd_simple(cid, &packet.hdr, false, vpu_ipc_timeout/2);
	rc = ipc_cmd_simple(cid, &packet.hdr, false, vpu_ipc_timeout);

	return rc;
}
@@ -1170,7 +1179,7 @@ int vpu_hw_session_resume(u32 sid)
	packet.hdr.sid = sid;

	pr_debug("IPC Tx%d: CMD_SESSION_START\n", cid);
	rc = ipc_cmd_simple(cid, &packet.hdr, false, vpu_ipc_timeout/2);
	rc = ipc_cmd_simple(cid, &packet.hdr, false, vpu_ipc_timeout);

	return rc;
}
@@ -1795,19 +1804,6 @@ int vpu_hw_session_cmd_ext(u32 sid, u32 cmd,
	return rc;
}

int vpu_hw_dump_csr_regs(char *buf, size_t buf_size)
{
	int rc = 0;
	struct vpu_channel_hal *ch_hal = &g_vpu_ch_hal;

	mutex_lock(&ch_hal->pw_lock);
	if (VPU_IS_UP(ch_hal->mode))
		rc = vpu_hfi_dump_csr_regs(buf, buf_size);
	mutex_unlock(&ch_hal->pw_lock);

	return rc;
}

static inline void raw_init_channel(struct vpu_channel *ch, u32 cid)
{
	mutex_init(&ch->chlock);
@@ -2398,6 +2394,60 @@ int vpu_hw_sys_g_property_ext(void __user *data, u32 data_size,
	return rc;
}

#ifdef CONFIG_DEBUG_FS

void vpu_hw_debug_on(void)
{
	/* make the timeout very long */
	vpu_ipc_timeout = VPU_LONG_TIMEOUT_MS;
	vpu_hfi_set_pil_timeout(VPU_LONG_TIMEOUT_MS);
	vpu_hfi_set_watchdog(0);
}

void vpu_hw_debug_off(void)
{
	/* enable timeouts */
	vpu_ipc_timeout = VPU_IPC_DEFAULT_TIMEOUT_MS;
	vpu_hfi_set_pil_timeout(VPU_PIL_DEFAULT_TIMEOUT_MS);
	vpu_hfi_set_watchdog(1);
}

size_t vpu_hw_print_queues(char *buf, size_t buf_size)
{
	return vpu_hfi_print_queues(buf, buf_size);
}

int vpu_hw_dump_csr_regs(char *buf, size_t buf_size)
{
	int rc = 0;
	struct vpu_channel_hal *ch_hal = &g_vpu_ch_hal;

	mutex_lock(&ch_hal->pw_lock);

	if (VPU_IS_UP(ch_hal->mode))
		rc = vpu_hfi_dump_csr_regs(buf, buf_size);

	mutex_unlock(&ch_hal->pw_lock);

	return rc;
}

int vpu_hw_dump_csr_regs_no_lock(char *buf, size_t buf_size)
{
	int rc = 0;
	struct vpu_channel_hal *ch_hal = &g_vpu_ch_hal;

	if (VPU_IS_UP(ch_hal->mode))
		rc = vpu_hfi_dump_csr_regs(buf, buf_size);

	return rc;
}

int vpu_hw_dump_smem_line(char *buf, size_t size, u32 offset)
{
	return vpu_hfi_dump_smem_line(buf, size, offset);
}

int vpu_hw_sys_print_log(char __user *user_buf, char *fmt_buf,
		int buf_size)
{
@@ -2482,3 +2532,4 @@ u32 vpu_hw_sys_get_power_mode(void)
	return mode;
}

#endif /* CONFIG_DEBUG_FS */
+49 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -328,6 +328,30 @@ enum flush_buf_type {
};
int vpu_hw_session_flush(u32 sid, enum flush_buf_type);


#ifdef CONFIG_DEBUG_FS

extern u32 vpu_shutdown_delay;

/**
 * vpu_hw_debug_on() - turn on debugging mode for vpu
 */
void vpu_hw_debug_on(void);

/**
 * vpu_hw_debug_off() - turn off debugging mode for vpu
 */
void vpu_hw_debug_off(void);

/**
 * vpu_hw_print_queues() - print the content of the IPC queues
 * @buf:	debug buffer to write into
 * @buf_size:	maximum size to read, in bytes
 *
 * Return:	the number of bytes read
 */
size_t vpu_hw_print_queues(char *buf, size_t buf_size);

/**
 * vpu_hw_dump_csr_regs() - dump the contents of the VPU CSR registers into buf
 * @buf:	debug buffer to write into
@@ -337,6 +361,27 @@ int vpu_hw_session_flush(u32 sid, enum flush_buf_type);
 */
int vpu_hw_dump_csr_regs(char *buf, size_t buf_size);

/**
 * vpu_hw_dump_csr_regs_no_lock() - dump the contents of the VPU CSR registers
 * into buf. Do not hold mutex in order to be able to dump csr registers while
 * firmware boots.
 * @buf:	debug buffer to write into
 * @buf_size:	maximum size to read, in bytes
 *
 * Return: The number of bytes read
 */
int vpu_hw_dump_csr_regs_no_lock(char *buf, size_t buf_size);

/**
 * vpu_hw_dump_smem_line() - dump the content of shared memory
 * @buf:	buffer to write into
 * @buf_size:	maximum size to read, in bytes
 * @offset:	smem read location (<base_addr> + offset)
 *
 * Return: the number of valid bytes in buf
 */
int vpu_hw_dump_smem_line(char *buf, size_t size, u32 offset);

/**
 * vpu_hw_sys_print_log() - Read the content of the VPU logging queue
 * @user_buf:	logging buffer to write into
@@ -373,4 +418,7 @@ void vpu_hw_sys_set_power_mode(u32 mode);
 *	3 VPU is in dynamic scaling mode
 */
u32 vpu_hw_sys_get_power_mode(void);

#endif /* CONFIG_DEBUG_FS */

#endif /* __H_VPU_CHANNEL_H__ */
+22 −22
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -23,16 +23,12 @@
#include "vpu_v4l2.h"
#include "vpu_ioctl_internal.h"
#include "vpu_channel.h"
#include "vpu_hfi.h"
#include "vpu_bus_clock.h"

#define BUF_SIZE	(SZ_4K)
#define RW_MODE		(S_IRUSR | S_IWUSR)


u32 vpu_pil_timeout = 500; /* ms */
u32 vpu_shutdown_delay = 1000; /* ms */
u32 vpu_ipc_timeout = 1000; /* ms */
static int vpu_debug_on;

struct fw_log_info {
	/* wq woken by hfi layer when fw log msg received */
@@ -149,7 +145,7 @@ static ssize_t read_queue_state(struct file *file, char __user *user_buf,
		return -ENOMEM;
	}

	size = vpu_hfi_print_queues(dbg_buf, BUF_SIZE);
	size = vpu_hw_print_queues(dbg_buf, BUF_SIZE);
	ret = simple_read_from_buffer(user_buf, len, ppos, dbg_buf, size);

	kfree(dbg_buf);
@@ -173,6 +169,14 @@ static ssize_t read_csr_regs(struct file *file, char __user *user_buf,
		return -ENOMEM;
	}

	/* If debug mode is on, a lock may still be
	 * held (while in process of booting up firmware).
	 * We need to still be able to dump csr registers
	 * in this case. Do not attempt to acquire the lock.
	 */
	if (vpu_debug_on)
		size = vpu_hw_dump_csr_regs_no_lock(dbg_buf, BUF_SIZE);
	else
		size = vpu_hw_dump_csr_regs(dbg_buf, BUF_SIZE);
	if (size > 0)
		ret = simple_read_from_buffer(user_buf, len, ppos,
@@ -188,21 +192,16 @@ static const struct file_operations csr_regs_ops = {
	.read = read_csr_regs,
};

static void debugon(void)
static void debug_on(void)
{
	/* make the timeout very long */
	vpu_pil_timeout = 10000000;
	vpu_ipc_timeout = 10000000;

	vpu_hfi_set_watchdog(0);
	vpu_debug_on = 1;
	vpu_hw_debug_on();
}

static void debugoff(void)
static void debug_off(void)
{
	/* enable the timeouts */
	vpu_pil_timeout = 500;
	vpu_ipc_timeout = 1000;
	vpu_hfi_set_watchdog(1);
	vpu_hw_debug_off();
	vpu_debug_on = 0;
}

static ssize_t write_cmd(struct file *file, const char __user *user_buf,
@@ -229,9 +228,9 @@ static ssize_t write_cmd(struct file *file, const char __user *user_buf,
	else if (strcmp(cmp, "dynamic") == 0)
		vpu_hw_sys_set_power_mode(VPU_POWER_DYNAMIC);
	else if (strcmp(cmp, "debugon") == 0)
		debugon();
		debug_on();
	else if (strcmp(cmp, "debugoff") == 0)
		debugoff();
		debug_off();

	return len;
}
@@ -268,7 +267,7 @@ static int smem_data_show(struct seq_file *m, void *private)
	 */
	for (; offset <= smem->offset + smem->size; offset += 4 * sizeof(u32)) {
		int ret;
		ret = vpu_hfi_dump_smem_line(cbuf, sizeof(cbuf), offset);
		ret = vpu_hw_dump_smem_line(cbuf, sizeof(cbuf), offset);
		if (ret > 0) {
			seq_printf(m, "%s", cbuf);
		} else {
@@ -424,6 +423,7 @@ struct dentry *init_vpu_debugfs(struct vpu_dev_core *core)
	}

	/* create cmd entry */
	vpu_debug_on = 0;
	attr = debugfs_create_file("cmd", RW_MODE, root, NULL,
			&vpu_cmd_ops);
	if (IS_ERR_OR_NULL(attr)) {
+17 −7
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -18,11 +18,7 @@

#include "vpu_v4l2.h"


extern u32 vpu_pil_timeout;
extern u32 vpu_shutdown_delay;
extern u32 vpu_ipc_timeout;

#ifdef CONFIG_DEBUG_FS

/* functions to init and deinit VPU debugfs entries */
struct dentry *init_vpu_debugfs(struct vpu_dev_core *core);
@@ -32,5 +28,19 @@ void cleanup_vpu_debugfs(struct dentry *dir);
/* hfi layer uses this to inform debug layer that firmware sent a log msg */
void vpu_wakeup_fw_logging_wq(void);

#endif /* __H_VPU_DEBUG_H__ */
#else

static inline struct dentry *init_vpu_debugfs(struct vpu_dev_core *core)
{
	return NULL;
}

static inline void cleanup_vpu_debugfs(struct dentry *dir)
{ }

static inline void vpu_wakeup_fw_logging_wq(void)
{ }

#endif /* CONFIG_DEBUG_FS */

#endif /* __H_VPU_DEBUG_H__ */
Loading