ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

高通ADSP抓取sensor init log

2019-08-23 15:36:24  阅读:1003  来源: 互联网

标签:log ADSP debugfs init static device subsys struct


高通平台adsp sensor的驱动log需要使用QXDM抓取,sensor init是sensor初始化的log信息,这时候QXDM还没有识别到diag口,无法直接获取。
高通支持如下两种获取adsp侧sensor init log的方式。
第一种方式是:通过adb名利重启sensors
a. adb shell stop sensors
b. adb shell “echo ‘related’ > /sys/bus/msm_subsys/devices/subsys1/restart_level”
c. adb shell “echo ‘restart’ >
/sys/kernel/debug/msm_subsys/adsp”
d. adb shell start sensors
PS : 这边有两个注意事项:
1.需要确认好 /sys/bus/msm_subsys/devices/subsys1 是指向 adsp还是其他,具体方法如下cat /sys/bus/msm_subsys/devices/subsys1/name 返回值是否为adsp,如果不是请cat其他subsys*
2.请检查/sys/kernel/debug/msm_subsys/adsp是否存在。高通最近在subsystem_restart.c中将msm_subsys/adsp节点取消了,为了解决该问题,需要导入如下所示的path。

diff --git a/drivers/soc/qcom/subsystem_restart.c b/drivers/soc/qcom/subsystem_restart.c
old mode 100644
new mode 100755
index ea94456..27eb26e
--- a/drivers/soc/qcom/subsystem_restart.c
+++ b/drivers/soc/qcom/subsystem_restart.c
@@ -36,7 +36,7 @@
 #include <soc/qcom/subsystem_notif.h>
 #include <soc/qcom/sysmon.h>
 #include <trace/events/trace_msm_pil_event.h>
-
+#include <linux/debugfs.h>
 #include <asm/current.h>
 
 #include "peripheral-loader.h"
@@ -178,6 +178,10 @@ struct subsys_device {
  enum crash_status crashed;
  int notif_state;
  struct list_head list;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *dentry;
+#endif
+ 
 };
 
 static struct subsys_device *to_subsys(struct device *d)
@@ -356,11 +360,11 @@ static struct device_attribute subsys_attrs[] = {
  __ATTR_NULL,
 };
 
-struct bus_type subsys_bus_type = {
+static struct bus_type subsys_bus_type = {
  .name  = "msm_subsys",
  .dev_attrs = subsys_attrs,
 };
-EXPORT_SYMBOL(subsys_bus_type);
+
 
 static DEFINE_IDA(subsys_ida);
 
@@ -1229,6 +1233,87 @@ void notify_proxy_unvote(struct device *device)
   notify_each_subsys_device(&dev, 1, SUBSYS_PROXY_UNVOTE, NULL);
 }
 
+#ifdef CONFIG_DEBUG_FS
+static ssize_t subsys_debugfs_read(struct file *filp, char __user *ubuf,
+  size_t cnt, loff_t *ppos)
+{
+ int r;
+ char buf[40];
+ struct subsys_device *subsys = filp->private_data;
+
+ r = snprintf(buf, sizeof(buf), "%d\n", subsys->count);
+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+}
+
+static ssize_t subsys_debugfs_write(struct file *filp,
+  const char __user *ubuf, size_t cnt, loff_t *ppos)
+{
+ struct subsys_device *subsys = filp->private_data;
+ char buf[10];
+ char *cmp;
+
+ cnt = min(cnt, sizeof(buf) - 1);
+ if (copy_from_user(&buf, ubuf, cnt))
+  return -EFAULT;
+ buf[cnt] = '\0';
+ cmp = strstrip(buf);
+
+ if (!strcmp(cmp, "restart")) {
+  if (subsystem_restart_dev(subsys))
+   return -EIO;
+ } else if (!strcmp(cmp, "get")) {
+  if (subsystem_get(subsys->desc->name))
+   return -EIO;
+ } else if (!strcmp(cmp, "put")) {
+  subsystem_put(subsys);
+ } else {
+  return -EINVAL;
+ }
+
+ return cnt;
+}
+
+static const struct file_operations subsys_debugfs_fops = {
+ .open = simple_open,
+ .read = subsys_debugfs_read,
+ .write = subsys_debugfs_write,
+};
+
+static struct dentry *subsys_base_dir;
+
+static int __init subsys_debugfs_init(void)
+{
+ subsys_base_dir = debugfs_create_dir("msm_subsys", NULL);
+ return !subsys_base_dir ? -ENOMEM : 0;
+}
+
+static void subsys_debugfs_exit(void)
+{
+ debugfs_remove_recursive(subsys_base_dir);
+}
+
+static int subsys_debugfs_add(struct subsys_device *subsys)
+{
+ if (!subsys_base_dir)
+  return -ENOMEM;
+
+ subsys->dentry = debugfs_create_file(subsys->desc->name,
+    S_IRUGO | S_IWUSR, subsys_base_dir,
+    subsys, &subsys_debugfs_fops);
+ return !subsys->dentry ? -ENOMEM : 0;
+}
+
+static void subsys_debugfs_remove(struct subsys_device *subsys)
+{
+ debugfs_remove(subsys->dentry);
+}
+#else
+static int __init subsys_debugfs_init(void) { return 0; };
+static void subsys_debugfs_exit(void) { }
+static int subsys_debugfs_add(struct subsys_device *subsys) { return 0; }
+static void subsys_debugfs_remove(struct subsys_device *subsys) { }
+#endif
+
 static int subsys_device_open(struct inode *inode, struct file *file)
 {
  struct subsys_device *device, *subsys_dev = 0;
@@ -1668,8 +1753,18 @@ struct subsys_device *subsys_register(struct subsys_desc *desc)
 
  mutex_init(&subsys->track.lock);
 
+ ret = subsys_debugfs_add(subsys);
+ if (ret) {
+  ida_simple_remove(&subsys_ida, subsys->id);
+  wakeup_source_trash(&subsys->ssr_wlock);
+  kfree(subsys);
+  return ERR_PTR(ret);
+ }
+
+
  ret = device_register(&subsys->dev);
  if (ret) {
+  subsys_debugfs_remove(subsys);
   put_device(&subsys->dev);
   return ERR_PTR(ret);
  }
@@ -1731,6 +1826,7 @@ err_setup_irqs:
  if (ofnode)
   subsys_remove_restart_order(ofnode);
 err_register:
+subsys_debugfs_remove(subsys);
  device_unregister(&subsys->dev);
  return ERR_PTR(ret);
 }
@@ -1759,6 +1855,7 @@ void subsys_unregister(struct subsys_device *subsys)
   WARN_ON(subsys->count);
   device_unregister(&subsys->dev);
   mutex_unlock(&subsys->track.lock);
+  subsys_debugfs_remove(subsys);
   subsys_char_device_remove(subsys);
   sysmon_notifier_unregister(subsys->desc);
   if (subsys->desc->edge)
@@ -1799,6 +1896,10 @@ static int __init subsys_restart_init(void)
  if (ret)
   goto err_bus;
 
+ ret = subsys_debugfs_init();
+ if (ret)
+  goto err_debugfs;
+
  char_class = class_create(THIS_MODULE, "subsys");
  if (IS_ERR(char_class)) {
   ret = -ENOMEM;
@@ -1816,6 +1917,8 @@ static int __init subsys_restart_init(void)
 err_soc:
  class_destroy(char_class);
 err_class:
+ subsys_debugfs_exit();
+err_debugfs:
  bus_unregister(&subsys_bus_type);
 err_bus:
  destroy_workqueue(ssr_wq);
diff --git a/include/soc/qcom/subsystem_restart.h b/include/soc/qcom/subsystem_restart.h
old mode 100644
new mode 100755
index 9a4d013..da258d2
--- a/include/soc/qcom/subsystem_restart.h
+++ b/include/soc/qcom/subsystem_restart.h
@@ -18,7 +18,7 @@
 #include <linux/interrupt.h>
 
 struct subsys_device;
-extern struct bus_type subsys_bus_type;
+//extern struct bus_type subsys_bus_type;
 
 enum {
  RESET_SOC = 0,

第二种方式是:在adsp侧sensor init时添加delay,加大SMGR_DELAY_US延时,从而实现等到QXDM 识别到diag口后才执行sensor init 操作。

If ADSP SSR can
not work, you can add delay in the sensor init code (it is just for debug ADSP
init issue, need remove it after finish debug);
sns_smgr_main.c
void sns_smgr_task(void* p_arg)
{
  smgr_init();
  sns_smgr_sensor_init();
  sns_init_done();
  sns_smgr_mr_init(sns_smgr.sig_grp);
  **SMGR_DELAY_US(6000000);**    // 这边是延时6s,按照需要修改这边延时抓取log。


标签:log,ADSP,debugfs,init,static,device,subsys,struct
来源: https://blog.csdn.net/weixin_32104133/article/details/100038313

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有