sdm: Synchronized write of xlogs

am: e0f39648ed

Change-Id: Id999a95b7a6b5990c5ead01b610f4c5806356d09
This commit is contained in:
Naseer Ahmed 2017-07-17 20:50:36 +00:00 committed by android-build-merger
commit c6942b3c1e
1 changed files with 17 additions and 1 deletions

View File

@ -46,6 +46,7 @@
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include "hw_device.h"
#include "hw_primary.h"
@ -1359,7 +1360,14 @@ DisplayError HWDevice::DumpDebugData() {
DLOGW("Pingpong timeout occurred in the driver.");
#ifdef USER_DEBUG
// Save the xlogs on ping pong time out
std::ofstream dst("/data/vendor/display/mdp_xlog");
const char* xlog_path = "/data/vendor/display/mdp_xlog";
DLOGD("Dumping debugfs data to %s", xlog_path);
std::ostringstream dst;
auto file = open(xlog_path, O_CREAT | O_DSYNC | O_RDWR, "w+");
if (file < 0) {
DLOGE("Couldn't open file: err:%d (%s)",errno, strerror(errno));
return kErrorResources;
}
dst << "+++ MDP:XLOG +++" << std::endl;
std::ifstream src("/sys/kernel/debug/mdp/xlog/dump");
dst << src.rdbuf() << std::endl;
@ -1379,6 +1387,14 @@ DisplayError HWDevice::DumpDebugData() {
src.open("/sys/kernel/debug/mdp/xlog/vbif_dbgbus_xlog");
dst << src.rdbuf() << std::endl;
src.close();
auto ret = write(file, dst.str().c_str(), dst.str().size());
if (ret < 0) {
DLOGE("Failed to write xlog data err: %d (%s)", errno, strerror(errno));
} else {
fsync(file);
}
close(file);
DLOGD("Finished dumping xlogs");;
#endif
return kErrorNone;
}