Add UFS health information into board specific dumpstate
Test: Take bugreport
Bug: 66967195
Change-Id: If0597da342a64bb38fdbd926787e9d0ae6ec4989
Merged-In: If0597da342a64bb38fdbd926787e9d0ae6ec4989
(cherry picked from commit c534149cd19e93dcc7660769b352c61480453532)
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index 505b5b7..01db23f 100755
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -141,6 +141,8 @@
DumpFileToFd(fd, "UFS model", "/sys/block/sda/device/model");
DumpFileToFd(fd, "UFS rev", "/sys/block/sda/device/rev");
DumpFileToFd(fd, "UFS size", "/sys/block/sda/size");
+ DumpFileToFd(fd, "UFS heath", "/sys/devices/soc/624000.ufshc/health");
+ RunCommandToFd(fd, "UFS dump", {"/vendor/bin/sh", "-c", "for f in $(find /sys/kernel/debug/ufshcd0 -type f); do if [[ -r $f && -f $f ]]; then echo --- $f; cat $f; fi; done"});
DumpFileToFd(fd, "RPM Stats", "/d/rpm_stats");
DumpFileToFd(fd, "Power Management Stats", "/d/rpm_master_stats");
diff --git a/init.common.rc b/init.common.rc
index ddc6eac..84bd460 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -814,6 +814,18 @@
write /sys/block/dm-1/queue/read_ahead_kb 128
write /sys/block/sda/queue/iostats 1
+ # UFS health
+ chmod 755 /sys/kernel/debug/ufshcd0
+ chown 644 /sys/kernel/debug/ufshcd0/err_state
+ chmod 644 /sys/kernel/debug/ufshcd0/power_mode
+ chmod 644 /sys/kernel/debug/ufshcd0/host_regs
+ chmod 644 /sys/kernel/debug/ufshcd0/show_hba
+ chmod 644 /sys/kernel/debug/ufshcd0/dump_device_desc
+ chmod 755 /sys/kernel/debug/ufshcd0/stats
+ chmod 644 /sys/kernel/debug/ufshcd0/stats/req_stats
+ chmod 644 /sys/kernel/debug/ufshcd0/stats/query_stats
+ chmod 644 /sys/kernel/debug/ufshcd0/stats/err_stats
+
on property:sys.boot_completed=1 && property:ro.build.type=user
write /proc/sys/kernel/modules_disabled 1
diff --git a/sepolicy/file.te b/sepolicy/file.te
index c8965d3..14cf52f 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -54,6 +54,7 @@
type debugfs_usb, debugfs_type, fs_type;
type debugfs_runtime_pm, debugfs_type, fs_type;
type debugfs_cnss, debugfs_type, fs_type;
+type debugfs_ufs, debugfs_type, fs_type;
# /proc
type proc_kernel_sched, fs_type;
diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts
index c354390..949701b 100644
--- a/sepolicy/genfs_contexts
+++ b/sepolicy/genfs_contexts
@@ -55,6 +55,7 @@
genfscon sysfs /module/diagchar/parameters/timestamp_switch u:object_r:sysfs_timestamp_switch:s0
genfscon sysfs /devices/soc/qpnp-smbcharger-16/power_supply/battery/system_temp_level u:object_r:sysfs_msm_subsys:s0
genfscon sysfs /devices/soc/624000.ufshc/host0/target0:0:0/0:0:0:0 u:object_r:sysfs_scsi_devices_0000:s0
+genfscon sysfs /devices/soc/624000.ufshc/health u:object_r:sysfs_scsi_devices_0000:s0
genfscon sysfs /module/diagchar u:object_r:sysfs_diag:s0
# debugfs
@@ -74,3 +75,4 @@
genfscon debugfs /ipc_logging/fusb302/log u:object_r:debugfs_usb:s0
genfscon debugfs /cnss_runtime_pm u:object_r:debugfs_runtime_pm:s0
genfscon debugfs /cnss-prealloc/status u:object_r:debugfs_cnss:s0
+genfscon debugfs /ufshcd0 u:object_r:debugfs_ufs:s0
diff --git a/sepolicy/hal_dumpstate_impl.te b/sepolicy/hal_dumpstate_impl.te
index 11995d6..f60bbdf 100644
--- a/sepolicy/hal_dumpstate_impl.te
+++ b/sepolicy/hal_dumpstate_impl.te
@@ -57,3 +57,5 @@
# Access to UFS info
allow hal_dumpstate_impl sysfs_scsi_devices_0000:dir r_dir_perms;
allow hal_dumpstate_impl sysfs_scsi_devices_0000:file r_file_perms;
+allow hal_dumpstate_impl debugfs_ufs:dir r_dir_perms;
+allow hal_dumpstate_impl debugfs_ufs:file r_file_perms;