高通平台如何打开last kmsg


Pstore feature is used to replace last_kmsg feature since kernel 3.10.

To enable it, take the below step (test on MSM8916)
enable below config in kernel config:
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_FTRACE=y 

CONFIG_DEBUG_FS=y
CONFIG_FUNCTION_TRACER=y

and disable below config:
# CONFIG_STRICT_MEMORY_RWX 

-----code changes ------
LINUX/android/kernel/fs/pstore/ram.c
-static ulong ramoops_console_size = MIN_MEM_SIZE;
+static ulong ramoops_console_size = 256*1024UL;

- static ulong mem_address;
+ static ulong mem_address=0x9ff00000;
 module_param(mem_address, ulong, 0400);
 MODULE_PARM_DESC(mem_address,
         "start of reserved RAM used to store oops/panic logs");
 
- static ulong mem_size;
+ static ulong mem_size=0x100000;

kernel/arch/arm/boot/dts/qcom/msm8916-memory.dtsi
        peripheral_mem: pheripheral_region@0 {
            linux,reserve-contiguous-region;
            linux,reserve-region;
            linux,remove-completely;
            reg = <0x0 0x8b600000 0x0 0x0600000>;
            label = "peripheral_mem";
        };
        
+        pstore_reserve_mem: pstore_reserve_mem_region@0 { 
+            linux,reserve-contiguous-region; 
+            linux,reserve-region; 
+            linux,remove-completely; 
+            reg = <0x0 0x9ff00000 0x0 0x00100000>; 
+            label = "pstore_reserve_mem"; 
+        }; 

-----test command ------
enable record ftrace
# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
disable download mode:
# echo 0 > /sys/module/msm_poweroff/parameters/download_mode 
# echo c > /proc/sysrq-trigger
[...device restart] 
# ls /sys/fs/pstore/
  console-ramoops
  dmesg-ramoops-0
  dmesg-ramoops-1
  ftrace-ramoops
# cat /sys/fs/pstore/ftrace-ramoops
0 c08bf830  c08bfbf0  do_page_fault.part.8 <- do_page_fault+0x3c/0xa8
0 c001b770  c08bfb48  fixup_exception <- do_page_fault.part.8+0x32c/0x398
0 c0045bb0  c001b780  search_exception_tables <- fixup_exception+0x20/0x38
0 c008914c  c0045bd8  search_module_extables <- search_exception_tables+0x38/0x44
0 c08bff5c  c008915c  add_preempt_count <- search_module_extables+0x24/0xc0
0 c08bfe78  c00891cc  sub_preempt_count <- search_module_extables+0x94/0xc0
0 c08b2e28  c08bfb64  __do_kernel_fault.part.7 <- do_page_fault.part.8+0x348/0x398

--------------------------------------------------------
workaround for 8916/39/94 64 bit version:
ram_core.c (kernel\fs\pstore)    
+static void *memcpy_pstore(void *dest, const void *src, size_t count)
+{
+    char *tmp = dest;
+    const char *s = src;
+
+    while (count--)
+        *tmp++ = *s++;
+    return dest;
+}

static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
    const void *s, unsigned int start, unsigned int count)
{
    struct persistent_ram_buffer *buffer = prz->buffer;
-    memcpy(buffer->data + start, s, count);
+    memcpy_pstore(buffer->data + start, s, count);
    persistent_ram_update_ecc(prz, start, count);
} Pstore feature is used to replace last_kmsg feature since kernel 3.10.
To enable it, take the below step (test on MSM8916)
enable below config in kernel config:
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_FTRACE=y 

CONFIG_DEBUG_FS=y
CONFIG_FUNCTION_TRACER=y

and disable below config:
# CONFIG_STRICT_MEMORY_RWX 

-----code changes ------
LINUX/android/kernel/fs/pstore/ram.c
-static ulong ramoops_console_size = MIN_MEM_SIZE;
+static ulong ramoops_console_size = 256*1024UL;

- static ulong mem_address;
+ static ulong mem_address=0x9ff00000;
 module_param(mem_address, ulong, 0400);
 MODULE_PARM_DESC(mem_address,
         "start of reserved RAM used to store oops/panic logs");
 
- static ulong mem_size;
+ static ulong mem_size=0x100000;

kernel/arch/arm/boot/dts/qcom/msm8916-memory.dtsi
        peripheral_mem: pheripheral_region@0 {
            linux,reserve-contiguous-region;
            linux,reserve-region;
            linux,remove-completely;
            reg = <0x0 0x8b600000 0x0 0x0600000>;
            label = "peripheral_mem";
        };
        
+        pstore_reserve_mem: pstore_reserve_mem_region@0 { 
+            linux,reserve-contiguous-region; 
+            linux,reserve-region; 
+            linux,remove-completely; 
+            reg = <0x0 0x9ff00000 0x0 0x00100000>; 
+            label = "pstore_reserve_mem"; 
+        }; 

-----test command ------
enable record ftrace
# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
disable download mode:
# echo 0 > /sys/module/msm_poweroff/parameters/download_mode 
# echo c > /proc/sysrq-trigger
[...device restart] 
# ls /sys/fs/pstore/
  console-ramoops
  dmesg-ramoops-0
  dmesg-ramoops-1
  ftrace-ramoops
# cat /sys/fs/pstore/ftrace-ramoops
0 c08bf830  c08bfbf0  do_page_fault.part.8 <- do_page_fault+0x3c/0xa8
0 c001b770  c08bfb48  fixup_exception <- do_page_fault.part.8+0x32c/0x398
0 c0045bb0  c001b780  search_exception_tables <- fixup_exception+0x20/0x38
0 c008914c  c0045bd8  search_module_extables <- search_exception_tables+0x38/0x44
0 c08bff5c  c008915c  add_preempt_count <- search_module_extables+0x24/0xc0
0 c08bfe78  c00891cc  sub_preempt_count <- search_module_extables+0x94/0xc0
0 c08b2e28  c08bfb64  __do_kernel_fault.part.7 <- do_page_fault.part.8+0x348/0x398

--------------------------------------------------------
workaround for 8916/39/94 64 bit version:
ram_core.c (kernel\fs\pstore)    
+static void *memcpy_pstore(void *dest, const void *src, size_t count)
+{
+    char *tmp = dest;
+    const char *s = src;
+
+    while (count--)
+        *tmp++ = *s++;
+    return dest;
+}

static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
    const void *s, unsigned int start, unsigned int count)
{
    struct persistent_ram_buffer *buffer = prz->buffer;
-    memcpy(buffer->data + start, s, count);
+    memcpy_pstore(buffer->data + start, s, count);
    persistent_ram_update_ecc(prz, start, count);
}

你可能感兴趣的:(高通平台如何打开last kmsg)