From 34736d0ae29b8cf4a6db0334933fe93c63d4cb0e Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 4 Apr 2022 12:09:16 -0700 Subject: [PATCH 1/3] Enable Virtual AB Compression on pixel device Test: th Bug: 234082426 Change-Id: If03ed7d412bd7a31885117fdb681c4c31d0366c7 (cherry picked from commit 5f3691316dec80729db09b1dfad3f1b0f763fa49) --- device.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/device.mk b/device.mk index 93bda1c4..8ef0f782 100644 --- a/device.mk +++ b/device.mk @@ -560,7 +560,9 @@ PRODUCT_PACKAGES += \ # Enable project quotas and casefolding for emulated storage without sdcardfs $(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk) -$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota/android_t_baseline.mk) +PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD := gz + # Enforce generic ramdisk allow list $(call inherit-product, $(SRC_TARGET_DIR)/product/generic_ramdisk.mk) From a5fa72f57be07c5affd39df521ba8eef28af74d0 Mon Sep 17 00:00:00 2001 From: George Lee Date: Wed, 18 May 2022 19:44:36 -0700 Subject: [PATCH 2/3] bcl: Add Mitigation Logger - Binary Mitigation Logger logs battery related information for 1 second when it is triggered by under voltage or over current interrupts. Information collected is to help debug system brownout. Bug: 228383769 Test: Boot and Test Signed-off-by: George Lee Change-Id: Icc5bf599eff7715545ed66d352ec00ae5d633aa0 --- battery_mitigation/Android.bp | 45 ++++++++++++++++ battery_mitigation/battery_mitigation.cpp | 64 +++++++++++++++++++++++ battery_mitigation/battery_mitigation.rc | 9 ++++ device.mk | 4 ++ 4 files changed, 122 insertions(+) create mode 100644 battery_mitigation/Android.bp create mode 100644 battery_mitigation/battery_mitigation.cpp create mode 100644 battery_mitigation/battery_mitigation.rc diff --git a/battery_mitigation/Android.bp b/battery_mitigation/Android.bp new file mode 100644 index 00000000..f9d429fb --- /dev/null +++ b/battery_mitigation/Android.bp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 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. + */ +package { + default_applicable_licenses: [ + "//device/google/gs201:device_google_gs201_license", + ], +} + +cc_binary { + name: "battery_mitigation", + relative_install_path: "hw", + proprietary: true, + init_rc: ["battery_mitigation.rc"], + shared_libs: [ + "libpixelmitigation", + "libbase", + "libbinder_ndk", + "libcutils", + "libhardware", + "libhidlbase", + "liblog", + "libutils", + "android.hardware.thermal@2.0" + ], + srcs: [ + "battery_mitigation.cpp", + ], + cflags: [ + "-Wall", + "-Werror", + ], +} diff --git a/battery_mitigation/battery_mitigation.cpp b/battery_mitigation/battery_mitigation.cpp new file mode 100644 index 00000000..fa18d93d --- /dev/null +++ b/battery_mitigation/battery_mitigation.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 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. + */ + +#define LOG_TAG "battery-mitigation" + +#include + +using android::hardware::google::pixel::BatteryMitigation; +using android::hardware::google::pixel::MitigationConfig; + +android::sp bmSp; + +const struct MitigationConfig::Config cfg = { + .SystemPath = { + "/dev/thermal/tz-by-name/batoilo/temp", + "/dev/thermal/tz-by-name/smpl_gm/temp", + "/dev/thermal/tz-by-name/soc/temp", + "/dev/thermal/tz-by-name/vdroop1/temp", + "/dev/thermal/tz-by-name/vdroop2/temp", + "/dev/thermal/tz-by-name/ocp_gpu/temp", + "/dev/thermal/tz-by-name/ocp_tpu/temp", + "/dev/thermal/tz-by-name/soft_ocp_cpu2/temp", + "/dev/thermal/tz-by-name/soft_ocp_cpu1/temp", + "/dev/thermal/tz-by-name/battery/temp", + "/dev/thermal/tz-by-name/battery_cycle/temp", + "/sys/bus/iio/devices/iio:device0/lpf_power", + "/sys/bus/iio/devices/iio:device1/lpf_power", + "/sys/class/power_supply/battery/voltage_now", + "/sys/class/power_supply/battery/current_now", + }, + .FilteredZones = { + "batoilo", + "vdroop1", + "vdroop2", + "smpl_gm", + }, + .SystemName = { + "batoilo", "smpl_gm", "soc", "vdroop1", "vdroop2", "ocp_gpu", + "ocp_tpu", "soft_ocp_cpu2", "soft_ocp_cpu1", "battery", "battery_cycle", + "main", "sub", "voltage_now", "current_now", + }, + .LogFilePath = "/data/vendor/mitigation/lastmeal.txt", +}; + +int main(int /*argc*/, char ** /*argv*/) { + bmSp = new BatteryMitigation(cfg); + while (true) { + pause(); + } + return 0; +} diff --git a/battery_mitigation/battery_mitigation.rc b/battery_mitigation/battery_mitigation.rc new file mode 100644 index 00000000..7b9ef4f2 --- /dev/null +++ b/battery_mitigation/battery_mitigation.rc @@ -0,0 +1,9 @@ +on property:vendor.thermal.link_ready=1 + mkdir /data/vendor/mitigation 0755 system system + chown system system /data/vendor/mitigation + start vendor.battery_mitigation + +service vendor.battery_mitigation /vendor/bin/hw/battery_mitigation + user system + group system + capabilities WAKE_ALARM BLOCK_SUSPEND diff --git a/device.mk b/device.mk index ab15dad2..2c0ec92f 100644 --- a/device.mk +++ b/device.mk @@ -542,6 +542,10 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ ConnectivityOverlay +# Battery Mitigation +PRODUCT_PACKAGES += \ + battery_mitigation + PRODUCT_PACKAGES_DEBUG += \ sg_write_buffer \ f2fs_io \ From fb6e5cf647a131d82886be15eed8ceb065c6b931 Mon Sep 17 00:00:00 2001 From: George Lee Date: Wed, 25 May 2022 14:37:31 -0700 Subject: [PATCH 3/3] dumpstate: Mitigation logger readout Mitigation Logger logs battery related information for 1 second when it is triggered by under voltage or over current interrupts. Information collected is to help debug system brownout. This change is to enable bugreport reading out the mitigation log. Bug: 228383769 Test: Boot and Test Signed-off-by: George Lee Change-Id: Ia735e46fc1b86b1971e8838d43f8733c73793ef8 --- dumpstate/Dumpstate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp index e434f25d..4950337e 100644 --- a/dumpstate/Dumpstate.cpp +++ b/dumpstate/Dumpstate.cpp @@ -453,6 +453,7 @@ void Dumpstate::dumpPowerSection(int fd) { if (!PropertiesHelper::IsUserBuild()) { RunCommandToFd(fd, "gvotables", {"/vendor/bin/sh", "-c", "cat /sys/kernel/debug/gvotables/*/status"}); } + DumpFileToFd(fd, "Lastmeal", "/data/vendor/mitigation/lastmeal.txt"); RunCommandToFd(fd, "Mitigation Stats", {"/vendor/bin/sh", "-c", "echo \"Source\\t\\tCount\\tSOC\\tTime\\tVoltage\"; " "for f in `ls /sys/devices/virtual/pmic/mitigation/last_triggered_count/*` ; " "do count=`cat $f`; "