From 3354e92ca597f432d7ae99d82b372a05702acdd4 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Mon, 13 Feb 2023 12:57:10 -0800 Subject: [PATCH 1/8] Remove deprecated f2fsstat Change-Id: I35d4482bc91f29f2748fd29edbe5b96bce68c0a3 Signed-off-by: Jaegeuk Kim --- device.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/device.mk b/device.mk index 7ae05b78..dfdab1a1 100644 --- a/device.mk +++ b/device.mk @@ -554,7 +554,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES_DEBUG += \ f2fs_io \ check_f2fs \ - f2fsstat \ f2fs.fibmap \ dump.f2fs From c9a60c3497f4bab4bc86c53376a11799d0184f70 Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Mon, 13 Feb 2023 11:56:39 +0800 Subject: [PATCH 2/8] Move led dump to tablet only Bug: 240530709 Test: adb bugreport Change-Id: I41ab1c21462a2efcdfe2eae0f9aab4ccaa52bbb6 --- dumpstate/Dumpstate.cpp | 16 ---------------- dumpstate/Dumpstate.h | 1 - 2 files changed, 17 deletions(-) diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp index efa9e254..5131d434 100644 --- a/dumpstate/Dumpstate.cpp +++ b/dumpstate/Dumpstate.cpp @@ -218,7 +218,6 @@ Dumpstate::Dumpstate() { "Devfreq", [this](int fd) { dumpDevfreqSection(fd); } }, { "power", [this](int fd) { dumpPowerSection(fd); } }, { "display", [this](int fd) { dumpDisplaySection(fd); } }, - { "led", [this](int fd) { dumpLEDSection(fd); } }, { "pixel-trace", [this](int fd) { dumpPixelTraceSection(fd); } }, }, mLogSections{ @@ -585,21 +584,6 @@ void Dumpstate::dumpDisplaySection(int fd) { } } -// Dump items related to LED -void Dumpstate::dumpLEDSection(int fd) { - struct stat buffer; - - if (!PropertiesHelper::IsUserBuild()) { - if (!stat("/sys/class/leds/green", &buffer)) { - DumpFileToFd(fd, "Green LED Brightness", "/sys/class/leds/green/brightness"); - DumpFileToFd(fd, "Green LED Max Brightness", "/sys/class/leds/green/max_brightness"); - } - if (!stat("/mnt/vendor/persist/led/led_calibration_LUT.txt", &buffer)) { - DumpFileToFd(fd, "LED Calibration Data", "/mnt/vendor/persist/led/led_calibration_LUT.txt"); - } - } -} - void Dumpstate::dumpModemLogs(int fd, const std::string &destDir) { std::string extendedLogDir = MODEM_EXTENDED_LOG_DIRECTORY; std::string modemLogHistoryDir = MODEM_LOG_HISTORY_DIRECTORY; diff --git a/dumpstate/Dumpstate.h b/dumpstate/Dumpstate.h index 75079e31..a91ef13c 100644 --- a/dumpstate/Dumpstate.h +++ b/dumpstate/Dumpstate.h @@ -57,7 +57,6 @@ class Dumpstate : public BnDumpstateDevice { void dumpDevfreqSection(int fd); void dumpMemorySection(int fd); void dumpDisplaySection(int fd); - void dumpLEDSection(int fd); void dumpPixelTraceSection(int fd); void dumpLogSection(int fd, int fdModem); From 3f1d4813cc2f26ac300de5b199e16479f007347a Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Tue, 14 Feb 2023 11:32:33 +0800 Subject: [PATCH 3/8] Move memory dump to gs-common Bug: 240530709 Test: adb bugreport Change-Id: I04431cd22b3ec1cc8a1bb0c6e3a7b482ad5963f2 --- dumpstate/Dumpstate.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp index 5131d434..58a28286 100644 --- a/dumpstate/Dumpstate.cpp +++ b/dumpstate/Dumpstate.cpp @@ -520,18 +520,6 @@ void Dumpstate::dumpDevfreqSection(int fd) { // Dump items related to memory void Dumpstate::dumpMemorySection(int fd) { - RunCommandToFd(fd, "ION HEAPS", {"/vendor/bin/sh", "-c", - "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"}); - DumpFileToFd(fd, "dmabuf info", "/d/dma_buf/bufinfo"); - DumpFileToFd(fd, "Page Pinner - longterm pin", "/sys/kernel/debug/page_pinner/buffer"); RunCommandToFd(fd, "CMA info", {"/vendor/bin/sh", "-c", "for d in $(ls -d /d/cma/*); do " "echo --- $d;" From f2a55fc82e71b68eb5ee3257c6736b68954997fa Mon Sep 17 00:00:00 2001 From: Erik Staats Date: Mon, 13 Feb 2023 23:19:09 +0000 Subject: [PATCH 4/8] Set acd-com.google.umfw_stat permissions, owner, and group Bug: 254464877 Test: Verified /dev/acd-com.google.umfw_stat permissions, owner, and group. Change-Id: I9a1a781aadf592911cbc03f3fe92cb9c66ffcf57 --- conf/ueventd.gs201.rc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/ueventd.gs201.rc b/conf/ueventd.gs201.rc index 03996b36..957d2790 100644 --- a/conf/ueventd.gs201.rc +++ b/conf/ueventd.gs201.rc @@ -143,6 +143,9 @@ # AoC /dev/aoc 0660 system system +# AoC stats (UmfwStat) +/dev/acd-com.google.umfw_stat 0660 system system + # Sensors (USF) /dev/acd-com.google.usf 0660 system system /dev/acd-com.google.usf.non_wake_up 0660 system system From ef2da8cce4a93b92b133dd8abb6d56a710bcd6a2 Mon Sep 17 00:00:00 2001 From: Solti Date: Thu, 9 Feb 2023 05:11:34 +0000 Subject: [PATCH 5/8] Update how USE_ANGLE is defined USE_ANGLE can be overridden. If the parent mk files don't define USE_ANGLE, then we treat it as not-using-angle. Test: build by cmd: `lunch panther_angle-userdebug` and then manual download the build to test on a Pixel device. Change-Id: I19d38ba98b5e1adc87d71643c733ce91e178d6a0 Bug: 266433747 Bug: 267670142 --- device.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device.mk b/device.mk index 3e8f1e3c..40b9c9c3 100644 --- a/device.mk +++ b/device.mk @@ -201,8 +201,8 @@ USES_GAUDIO := true # Must match BOARD_USES_SWIFTSHADER in BoardConfig.mk USE_SWIFTSHADER := false -# Must match BOARD_USES_ANGLE in BoardConfig.mk -USE_ANGLE := false +# by default, USE_ANGLE is false +USE_ANGLE ?= false # HWUI TARGET_USES_VULKAN = true From b8ff3f3f68398734064609d0c024f7ecdcafe4e4 Mon Sep 17 00:00:00 2001 From: Doug Zobel Date: Tue, 7 Feb 2023 10:48:10 -0600 Subject: [PATCH 6/8] dumpstate: Collect PCIe link stats [DO NOT MERGE] Collect PCIe link statistics in dumpstate. DO NOT MERGE because the same functionality is already implemented in dump_pcie.sh in upstream branches. Test: adb bugreport && unzip bugreport*.zip && grep link_stats dumpstate_board.txt Bug: 266561593 Change-Id: I5b530b68f8c8cd6ed2bc5016d5aef55c3caafbd8 Signed-off-by: Doug Zobel --- dumpstate/Dumpstate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp index b85f12dc..98cfeb2c 100644 --- a/dumpstate/Dumpstate.cpp +++ b/dumpstate/Dumpstate.cpp @@ -1210,6 +1210,10 @@ void Dumpstate::dumpLEDSection(int fd) { void Dumpstate::dumpPCIeSection(int fd) { DumpFileToFd(fd, "PCIe0 Logs", "/dev/logbuffer_pcie0"); DumpFileToFd(fd, "PCIe1 Logs", "/dev/logbuffer_pcie1"); + RunCommandToFd(fd, "PCIe Link Statistics", {"/vendor/bin/sh", "-c", + "for f in ls /sys/devices/platform/14520000.pcie/link_stats/* " + " /sys/devices/platform/11920000.pcie/link_stats/*; do " + " echo \"$f: `cat $f`\"; done"}); } void Dumpstate::dumpModemSection(int fd) { From 4e38e3b8c35ae7894fae0a0ba10f48726c6ffbdf Mon Sep 17 00:00:00 2001 From: Roy Luo Date: Wed, 8 Feb 2023 19:38:32 +0000 Subject: [PATCH 7/8] Add shell command to send vendor command to GL852G Bug: 261923350 Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd Change-Id: I83b56d28cfd89dfaf51fce88f97020196402f972 Signed-off-by: Roy Luo --- usb/usb/Android.bp | 1 + usb/usb/Usb.cpp | 115 +++++++++++++++++++++++- usb/usb/Usb.h | 6 +- usb/usb/android.hardware.usb-service.rc | 2 +- 4 files changed, 121 insertions(+), 3 deletions(-) diff --git a/usb/usb/Android.bp b/usb/usb/Android.bp index 6817e87d..3421a96d 100644 --- a/usb/usb/Android.bp +++ b/usb/usb/Android.bp @@ -40,6 +40,7 @@ cc_binary { "libbinder", "libhidlbase", "liblog", + "libusbhost", "libutils", "libhardware", "android.hardware.thermal@1.0", diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index 8ba4a745..533aca8a 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -22,10 +22,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -35,6 +37,7 @@ #include #include #include +#include #include "Usb.h" @@ -48,6 +51,8 @@ using android::base::Trim; using android::hardware::google::pixel::getStatsService; using android::hardware::google::pixel::PixelAtoms::VendorUsbPortOverheat; using android::hardware::google::pixel::reportUsbPortOverheat; +using android::String8; +using android::Vector; namespace aidl { namespace android { @@ -79,6 +84,12 @@ constexpr int kSamplingIntervalSec = 5; void queryVersionHelper(android::hardware::usb::Usb *usb, std::vector *currentPortStatus); +#define CTRL_TRANSFER_TIMEOUT_MSEC 1000 +#define GL852G_VENDOR_ID 0x05e3 +#define GL852G_PRODUCT_ID1 0x0608 +#define GL852G_PRODUCT_ID2 0x0610 +#define GL852G_VENDOR_CMD_REQ 0xe3 + ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int64_t in_transactionId) { bool result = true; @@ -683,7 +694,7 @@ Status getPortStatusHelper(android::hardware::usb::Usb *usb, PortRole currentRole; currentRole.set(PortPowerRole::NONE); - if (getCurrentRoleHelper(port.first, port.second, ¤tRole) == Status::SUCCESS){ + if (getCurrentRoleHelper(port.first, port.second, ¤tRole) == Status::SUCCESS) { (*currentPortStatus)[i].currentPowerRole = currentRole.get(); } else { ALOGE("Error while retrieving portNames"); @@ -1029,6 +1040,108 @@ ScopedAStatus Usb::setCallback(const shared_ptr& in_callback) { return ScopedAStatus::ok(); } +struct hub_vendor_cmd { + // wValue filed of standard device request + int value; + // wIndex field of standard device request + int index; + // Output pipe to shell command + int out; + // Whether the hub is found + bool found; +}; + +static int usbDeviceAdded(const char *devname, void* client_data) { + struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data; + uint16_t vendorId, productId; + struct usb_device *device = usb_device_open(devname); + + if (!device) { + dprintf(cmd->out, "usb_device_open failed\n"); + return 0; + } + + // The vendor cmd only applies to USB Hubs of Genesys Logic, Inc. + // The request field of vendor cmd is fixed to 0xe3. + vendorId = usb_device_get_vendor_id(device); + productId = usb_device_get_product_id(device); + if (vendorId == GL852G_VENDOR_ID && + (productId == GL852G_PRODUCT_ID1 || productId == GL852G_PRODUCT_ID2)) { + int ret = usb_device_control_transfer( + device, USB_DIR_OUT | USB_TYPE_VENDOR, + GL852G_VENDOR_CMD_REQ, cmd->value, cmd->index, NULL, 0, + CTRL_TRANSFER_TIMEOUT_MSEC); + dprintf(cmd->out, "Vendor cmd %s (wValue %x, wIndex %x, return %d)\n", + ret? "failed" : "succeeded", cmd->value, cmd->index, ret); + // Stop iterating through usb devices once the hub is found. + cmd->found = true; + return 1; + } + + return 0; +} + +static int usbDiscoveryDone(void *client_data) +{ + struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data; + + dprintf(cmd->out, "Done USB discovery, hub %s found\n", + cmd->found ? "is" : "not"); + + return 1; +} + +static status_t sendHubVendorCmd(int out, Vector& args) { + if (args.size() < 3) { + dprintf(out, "Incorrect number of argument supplied\n"); + return ::android::UNKNOWN_ERROR; + } + struct hub_vendor_cmd cmd = { + .value = std::stoi(args[1].c_str(), NULL, 16), + .index = std::stoi(args[2].c_str(), NULL, 16), + .out = out, + .found = false + }; + + struct usb_host_context *ctx; + ctx = usb_host_init(); + if (!ctx) { + dprintf(out, "usb_host_init failed\n"); + return ::android::UNKNOWN_ERROR; + } + + usb_host_run(ctx, usbDeviceAdded, NULL, usbDiscoveryDone, &cmd); + usb_host_cleanup(ctx); + + return ::android::NO_ERROR; +} + +status_t Usb::handleShellCommand(int in, int out, int err, const char** argv, + uint32_t argc) { + uid_t uid = AIBinder_getCallingUid(); + if (uid != AID_ROOT && uid != AID_SHELL) { + return ::android::PERMISSION_DENIED; + } + + Vector utf8Args; + utf8Args.setCapacity(argc); + for (uint32_t i = 0; i < argc; i++) { + utf8Args.push(String8(argv[i])); + } + + if (argc >= 1) { + if (!utf8Args[0].compare(String8("hub-vendor-cmd"))) { + return sendHubVendorCmd(out, utf8Args); + } + } + + dprintf(out, "usage: adb shell cmd hub-vendor-cmd VALUE INDEX\n" + " VALUE wValue field in hex format, e.g. f321\n" + " INDEX wIndex field in hex format, e.g. f321\n"); + + return ::android::NO_ERROR; +} + } // namespace usb } // namespace hardware } // namespace android diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h index d8d6d001..121694a2 100644 --- a/usb/usb/Usb.h +++ b/usb/usb/Usb.h @@ -43,6 +43,7 @@ using ::android::hardware::google::pixel::usb::ZoneInfo; using ::android::hardware::thermal::V2_0::TemperatureType; using ::android::hardware::thermal::V2_0::ThrottlingSeverity; using ::android::sp; +using ::android::status_t; using ::ndk::ScopedAStatus; using ::std::shared_ptr; using ::std::string; @@ -68,9 +69,12 @@ struct Usb : public BnUsb { ScopedAStatus enableUsbDataWhileDocked(const string& in_portName, int64_t in_transactionId) override; ScopedAStatus limitPowerTransfer(const string& in_portName, bool in_limit, - int64_t in_transactionId) override; + int64_t in_transactionId) override; ScopedAStatus resetUsbPort(const string& in_portName, int64_t in_transactionId) override; + status_t handleShellCommand(int in, int out, int err, const char** argv, + uint32_t argc) override; + std::shared_ptr<::aidl::android::hardware::usb::IUsbCallback> mCallback; // Protects mCallback variable pthread_mutex_t mLock; diff --git a/usb/usb/android.hardware.usb-service.rc b/usb/usb/android.hardware.usb-service.rc index 3ee952aa..06cf891d 100644 --- a/usb/usb/android.hardware.usb-service.rc +++ b/usb/usb/android.hardware.usb-service.rc @@ -1,7 +1,7 @@ service vendor.usb /vendor/bin/hw/android.hardware.usb-service class hal user system - group system shell wakelock + group system shell wakelock usb capabilities WAKE_ALARM BLOCK_SUSPEND on post-fs From 5f6267c0b031c57fa95b3a76ff33bc9421e2e90b Mon Sep 17 00:00:00 2001 From: Xiang Wang Date: Thu, 19 Jan 2023 10:50:51 -0800 Subject: [PATCH 8/8] Update USB HAL clients to use Thermal stable AIDL Bug: b/264594715 Test: boot test Change-Id: I2ff6095e8ea6f0c5cc48b303585b65acc8a14f53 --- usb/usb/Android.bp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usb/usb/Android.bp b/usb/usb/Android.bp index 3421a96d..07e66ead 100644 --- a/usb/usb/Android.bp +++ b/usb/usb/Android.bp @@ -45,6 +45,7 @@ cc_binary { "libhardware", "android.hardware.thermal@1.0", "android.hardware.thermal@2.0", + "android.hardware.thermal-V1-ndk", "android.hardware.usb.gadget@1.0", "android.hardware.usb-V1-ndk", "android.hardware.usb.gadget-V1-ndk", @@ -52,11 +53,11 @@ cc_binary { "android.frameworks.stats-V1-ndk", "pixelatoms-cpp", "libbinder_ndk", - ], static_libs: [ "libpixelusb-aidl", "libpixelstats", + "libpixelthermalwrapper", ], export_shared_lib_headers: [ "android.frameworks.stats-V1-ndk",