Snap for 9607154 from adefb37275 to udc-release

Change-Id: I36062d953b63d2d7b9393aa7176bda3522133e23
This commit is contained in:
Android Build Coastguard Worker 2023-02-15 02:03:12 +00:00
commit 24325daaba
20 changed files with 166 additions and 6 deletions

18
led/Android.bp Normal file
View file

@ -0,0 +1,18 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_binary {
name: "dump_led",
srcs: ["dump_led.cpp"],
cflags: [
"-Wall",
"-Wextra",
"-Werror",
],
shared_libs: [
"libdump",
],
vendor: true,
relative_install_path: "dump",
}

24
led/dump_led.cpp Normal file
View file

@ -0,0 +1,24 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dump/pixel_dump.h>
int main() {
dumpFileContent("Green LED Brightness", "/sys/class/leds/green/brightness");
dumpFileContent("Green LED Max Brightness", "/sys/class/leds/green/max_brightness");
dumpFileContent("LED Calibration Data", "/mnt/vendor/persist/led/led_calibration_LUT.txt");
return 0;
}

3
led/led.mk Normal file
View file

@ -0,0 +1,3 @@
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/led/sepolicy
PRODUCT_PACKAGES_DEBUG += dump_led

9
led/sepolicy/dump_led.te Normal file
View file

@ -0,0 +1,9 @@
pixel_bugreport(dump_led)
allow dump_led mnt_vendor_file:dir search;
allow dump_led persist_file:dir search;
allow dump_led persist_leds_file:dir search;
allow dump_led persist_leds_file:file r_file_perms;
allow dump_led sysfs_leds:dir search;
allow dump_led sysfs_leds:file r_file_perms;

2
led/sepolicy/file.te Normal file
View file

@ -0,0 +1,2 @@
type persist_leds_file, file_type, vendor_persist_type;

View file

@ -0,0 +1,4 @@
/vendor/bin/dump/dump_led u:object_r:dump_led_exec:s0
/mnt/vendor/persist/led(/.*)? u:object_r:persist_leds_file:s0

View file

@ -34,8 +34,14 @@ namespace power {
namespace stats {
CpupmStateResidencyDataProvider::CpupmStateResidencyDataProvider(
const std::string &path, const Config &config)
: mPath(std::move(path)), mConfig(std::move(config)) {}
const std::string &path,
const Config &config,
const std::string &sleepPath,
const SleepConfig &sleepConfig)
: mPath(std::move(path)),
mConfig(std::move(config)),
mSleepPath(std::move(sleepPath)),
mSleepConfig(std::move(sleepConfig)) {}
int32_t CpupmStateResidencyDataProvider::matchState(char const *line) {
for (int32_t i = 0; i < mConfig.states.size(); i++) {
@ -78,6 +84,12 @@ bool CpupmStateResidencyDataProvider::getStateResidencies(
return false;
}
std::unique_ptr<FILE, decltype(&fclose)> sleepFp(fopen(mSleepPath.c_str(), "r"), fclose);
if (!sleepFp) {
PLOG(ERROR) << __func__ << ":Failed to open file " << mSleepPath;
return false;
}
for (int32_t i = 0; i < mConfig.entities.size(); i++) {
std::vector<StateResidency> stateResidencies(mConfig.states.size());
for (int32_t j = 0; j < stateResidencies.size(); j++) {
@ -90,9 +102,29 @@ bool CpupmStateResidencyDataProvider::getStateResidencies(
char *line = nullptr;
int32_t temp, entityIndex, stateId = -1;
uint64_t duration, count;
uint64_t duration, count, sleepDurationMs = 0;
auto it = residencies->end();
int32_t sleepIndex = 0;
// Parse state for sleep duration
while (getline(&line, &len, sleepFp.get()) != -1) {
std::string trimedLine = Trim(std::string(line));
if (StartsWith(trimedLine, mSleepConfig[sleepIndex])) {
if (sleepIndex < mSleepConfig.size() - 1) {
sleepIndex++;
continue;
} else {
std::vector<std::string> parts = Split(trimedLine, " ");
if (parts.size() == 2) {
ParseUint(parts[1], &sleepDurationMs);
sleepDurationMs /= NS_TO_MS;
}
break;
}
}
}
// Parse state for CPUPM entities
while (getline(&line, &len, fp.get()) != -1) {
temp = matchState(line);
// Assign new id only when a new valid state is encountered.
@ -109,7 +141,7 @@ bool CpupmStateResidencyDataProvider::getStateResidencies(
it = residencies->find(mConfig.entities[entityIndex].first);
if (it != residencies->end()) {
if (parseState(line, &duration, &count)) {
it->second[stateId].totalTimeInStateMs = duration / US_TO_MS;
it->second[stateId].totalTimeInStateMs = duration / US_TO_MS + sleepDurationMs;
it->second[stateId].totalStateEntryCount = count;
} else {
LOG(ERROR) << "Failed to parse duration and count from [" << std::string(line)

View file

@ -34,10 +34,16 @@ class CpupmStateResidencyDataProvider : public PowerStats::IStateResidencyDataPr
std::vector<std::pair<std::string, std::string>> states;
};
typedef std::vector<std::string> SleepConfig;
/*
* path - path to cpupm sysfs node.
*/
CpupmStateResidencyDataProvider(const std::string &path, const Config &config);
CpupmStateResidencyDataProvider(
const std::string &path,
const Config &config,
const std::string &sleepPath,
const SleepConfig &sleepConfig);
~CpupmStateResidencyDataProvider() = default;
/*
@ -58,9 +64,13 @@ class CpupmStateResidencyDataProvider : public PowerStats::IStateResidencyDataPr
// A constant to represent the number of microseconds in one millisecond.
const uint64_t US_TO_MS = 1000;
// A constant to represent the number of nanoseconds in one millisecond.
const uint64_t NS_TO_MS = 1000000;
const std::string mPath;
const Config mConfig;
const std::string mSleepPath;
const SleepConfig mSleepConfig;
};
} // namespace stats

View file

@ -2,6 +2,13 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
sh_binary {
name: "dump_memory.sh",
src: "dump_memory.sh",
vendor: true,
sub_dir: "dump",
}
cc_binary {
name: "dump_soc",
srcs: ["dump_soc.cpp"],

22
soc/dump_memory.sh Normal file
View file

@ -0,0 +1,22 @@
#!/vendor/bin/sh
echo "------ ION HEAPS ------"
for d in $(ls -d /d/ion/*)
do
if [ -f $d ]; then
echo --- $d
cat $d
else
for f in $(ls $d)
do
echo --- $d/$f
cat $d/$f
done
fi
done
echo "------ dmabuf info ------"
cat "/d/dma_buf/bufinfo"
echo "------ Page Pinner - longterm pin ------"
cat "/sys/kernel/debug/page_pinner/buffer"

View file

@ -0,0 +1,8 @@
pixel_bugreport(dump_memory)
allow dump_memory vendor_toolbox_exec:file execute_no_trans;
userdebug_or_eng(`
allow dump_memory vendor_dmabuf_debugfs:file r_file_perms;
allow dump_memory vendor_page_pinner_debugfs:dir r_dir_perms;
allow dump_memory vendor_page_pinner_debugfs:file r_file_perms;
')

View file

@ -0,0 +1,2 @@
dontaudit dumpstate vendor_dmabuf_debugfs:file r_file_perms;

3
soc/sepolicy/file.te Normal file
View file

@ -0,0 +1,3 @@
type vendor_dmabuf_debugfs, fs_type, debugfs_type;
type vendor_page_pinner_debugfs, fs_type, debugfs_type;

View file

@ -1 +1,3 @@
/vendor/bin/dump/dump_soc u:object_r:dump_soc_exec:s0
/vendor/bin/dump/dump_soc u:object_r:dump_soc_exec:s0
/vendor/bin/dump/dump_memory\.sh u:object_r:dump_memory_exec:s0

View file

@ -5,3 +5,6 @@ genfscon sysfs /devices/system/chip-id/product_id u:object_r:sysfs_chip_id:
genfscon sysfs /devices/system/chip-id/revision u:object_r:sysfs_chip_id:s0
genfscon sysfs /devices/system/chip-id/raw_str u:object_r:sysfs_chip_id:s0
genfscon debugfs /dma_buf/bufinfo u:object_r:vendor_dmabuf_debugfs:s0
genfscon debugfs /page_pinner u:object_r:vendor_page_pinner_debugfs:s0

View file

@ -1,3 +1,5 @@
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/soc/sepolicy
PRODUCT_PACKAGES += dump_soc
PRODUCT_PACKAGES_DEBUG += dump_memory.sh

1
storage/dumpstate.te Normal file
View file

@ -0,0 +1 @@
allow dumpstate sysfs_scsi_devices_0000:file r_file_perms;

View file

@ -0,0 +1,3 @@
# Access to /sys/devices/platform/*ufs/*
allow hal_health_storage_default sysfs_scsi_devices_0000:dir r_dir_perms;
allow hal_health_storage_default sysfs_scsi_devices_0000:file rw_file_perms;

1
storage/sepolicy/init.te Normal file
View file

@ -0,0 +1 @@
allow init sysfs_scsi_devices_0000:file w_file_perms;

4
storage/sepolicy/vold.te Normal file
View file

@ -0,0 +1,4 @@
allow vold sysfs_scsi_devices_0000:file rw_file_perms;
dontaudit vold dumpstate:fifo_file rw_file_perms;
dontaudit vold dumpstate:fd use ;