From: Imre Deak Date: Fri, 1 Apr 2011 15:18:24 +0000 (+0300) Subject: gpu: pvr: add debugfs interface for the command trace X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8476c872de749d79ecb859a922aea07b4b1406b;p=sgx.git gpu: pvr: add debugfs interface for the command trace Signed-off-by: Imre Deak Reviewed-by: Luc Verhaegen --- diff --git a/pvr/pvr_debugfs.c b/pvr/pvr_debugfs.c index 4a9e068..40e30cf 100644 --- a/pvr/pvr_debugfs.c +++ b/pvr/pvr_debugfs.c @@ -40,6 +40,7 @@ #include "mmu.h" #include "bridged_support.h" #include "mm.h" +#include "pvr_trace_cmd.h" struct dentry *pvr_debugfs_dir; static u32 pvr_reset; @@ -232,6 +233,75 @@ static const struct file_operations pvr_debugfs_edm_fops = { }; #endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ +#ifdef CONFIG_PVR_TRACE_CMD + +static void *trcmd_str_buf; +static u8 *trcmd_snapshot; +static size_t trcmd_snapshot_size; +static int trcmd_open_cnt; + +static int pvr_dbg_trcmd_open(struct inode *inode, struct file *file) +{ + int r; + + if (trcmd_open_cnt) + return -EBUSY; + + trcmd_open_cnt++; + + trcmd_str_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!trcmd_str_buf) { + trcmd_open_cnt--; + + return -ENOMEM; + } + + pvr_trcmd_lock(); + + r = pvr_trcmd_create_snapshot(&trcmd_snapshot, &trcmd_snapshot_size); + if (r < 0) { + pvr_trcmd_unlock(); + kfree(trcmd_str_buf); + trcmd_open_cnt--; + + return r; + } + + pvr_trcmd_unlock(); + + return 0; +} + +static int pvr_dbg_trcmd_release(struct inode *inode, struct file *file) +{ + pvr_trcmd_destroy_snapshot(trcmd_snapshot); + kfree(trcmd_str_buf); + trcmd_open_cnt--; + + return 0; +} + +static ssize_t pvr_dbg_trcmd_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + ssize_t ret; + + ret = pvr_trcmd_print(trcmd_str_buf, max_t(size_t, PAGE_SIZE, count), + trcmd_snapshot, trcmd_snapshot_size, ppos); + if (copy_to_user(buffer, trcmd_str_buf, ret)) + return -EFAULT; + + return ret; +} + +static const struct file_operations pvr_dbg_trcmd_fops = { + .owner = THIS_MODULE, + .open = pvr_dbg_trcmd_open, + .release = pvr_dbg_trcmd_release, + .read = pvr_dbg_trcmd_read, +}; +#endif + /* * * HW Recovery dumping support. @@ -1076,7 +1146,13 @@ int pvr_debugfs_init(void) return -ENODEV; } #endif - +#ifdef CONFIG_PVR_TRACE_CMD + if (!debugfs_create_file("command_trace", S_IRUGO, pvr_debugfs_dir, + NULL, &pvr_dbg_trcmd_fops)) { + debugfs_remove_recursive(pvr_debugfs_dir); + return -ENODEV; + } +#endif if (!debugfs_create_file("hwrec_event", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_event_fops)) { debugfs_remove_recursive(pvr_debugfs_dir);