summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian2017-03-21 18:57:44 -0500
committerJin Qian2017-04-03 11:48:30 -0500
commit808f7036096e1f7b4889fe8689702685caa6ccb7 (patch)
tree9ed71971959ee31831a385257944ffb551d7418e /storaged
parent8197093497a65829f4da90b3fda0e281da7b27eb (diff)
downloadplatform-system-core-808f7036096e1f7b4889fe8689702685caa6ccb7.tar.gz
platform-system-core-808f7036096e1f7b4889fe8689702685caa6ccb7.tar.xz
platform-system-core-808f7036096e1f7b4889fe8689702685caa6ccb7.zip
storaged: add support for ufs health info
Test: adb logcat -d -b events | grep storaged_emmc_info Bug: 36228467 Merged-In: I519fe2b8a99c1c31f1fe720bd671904d1ab609bb Change-Id: I519fe2b8a99c1c31f1fe720bd671904d1ab609bb
Diffstat (limited to 'storaged')
-rw-r--r--storaged/include/storaged_info.h8
-rw-r--r--storaged/storaged_info.cpp53
2 files changed, 60 insertions, 1 deletions
diff --git a/storaged/include/storaged_info.h b/storaged/include/storaged_info.h
index cfcdd7f22..913c814ac 100644
--- a/storaged/include/storaged_info.h
+++ b/storaged/include/storaged_info.h
@@ -52,6 +52,14 @@ public:
52 bool report_debugfs(); 52 bool report_debugfs();
53}; 53};
54 54
55class ufs_info_t : public storage_info_t {
56private:
57 const string health_file = "/sys/devices/soc/624000.ufshc/health";
58public:
59 virtual ~ufs_info_t() {}
60 bool report();
61};
62
55void report_storage_health(); 63void report_storage_health();
56 64
57#endif /* _STORAGED_INFO_H_ */ 65#endif /* _STORAGED_INFO_H_ */
diff --git a/storaged/storaged_info.cpp b/storaged/storaged_info.cpp
index 1a5da411f..434bd74ae 100644
--- a/storaged/storaged_info.cpp
+++ b/storaged/storaged_info.cpp
@@ -22,6 +22,7 @@
22#include <android-base/file.h> 22#include <android-base/file.h>
23#include <android-base/parseint.h> 23#include <android-base/parseint.h>
24#include <android-base/logging.h> 24#include <android-base/logging.h>
25#include <android-base/strings.h>
25#include <log/log_event_list.h> 26#include <log/log_event_list.h>
26 27
27#include "storaged.h" 28#include "storaged.h"
@@ -32,7 +33,10 @@ using namespace android::base;
32void report_storage_health() 33void report_storage_health()
33{ 34{
34 emmc_info_t mmc; 35 emmc_info_t mmc;
36 ufs_info_t ufs;
37
35 mmc.report(); 38 mmc.report();
39 ufs.report();
36} 40}
37 41
38void storage_info_t::publish() 42void storage_info_t::publish()
@@ -130,4 +134,51 @@ bool emmc_info_t::report_debugfs()
130 } 134 }
131 135
132 return true; 136 return true;
133} \ No newline at end of file 137}
138
139bool ufs_info_t::report()
140{
141 string buffer;
142 if (!ReadFileToString(health_file, &buffer)) {
143 return false;
144 }
145
146 vector<string> lines = Split(buffer, "\n");
147 if (lines.empty()) {
148 return false;
149 }
150
151 char rev[8];
152 if (sscanf(lines[0].c_str(), "ufs version: 0x%7s\n", rev) < 1) {
153 return false;
154 }
155
156 version = "ufs " + string(rev);
157
158 for (size_t i = 1; i < lines.size(); i++) {
159 char token[32];
160 uint16_t val;
161 int ret;
162 if ((ret = sscanf(lines[i].c_str(),
163 "Health Descriptor[Byte offset 0x%*d]: %31s = 0x%hx",
164 token, &val)) < 2) {
165 continue;
166 }
167
168 if (string(token) == "bPreEOLInfo") {
169 eol = val;
170 } else if (string(token) == "bDeviceLifeTimeEstA") {
171 lifetime_a = val;
172 } else if (string(token) == "bDeviceLifeTimeEstB") {
173 lifetime_b = val;
174 }
175 }
176
177 if (eol == 0 || (lifetime_a == 0 && lifetime_b == 0)) {
178 return false;
179 }
180
181 publish();
182 return true;
183}
184