diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-13 21:27:09 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-13 21:27:09 +0000 |
commit | 9d668276bd9829cdff46bfebfbf237256b5cf361 (patch) | |
tree | 9eca0c76b18f3e180614f2d8e38db020c42e1326 | |
parent | e5e12b30daec0e872208252ef73f668b4a9c5dc7 (diff) | |
parent | 2f56f5f47a6b97e8a617324039fc81f9b2476241 (diff) | |
download | pixel-android-mainline-12.0.0_r118.tar.gz |
Snap for 7728678 from 2f56f5f47a6b97e8a617324039fc81f9b2476241 to mainline-ipsec-releaseandroid-mainline-12.0.0_r88android-mainline-12.0.0_r73android-mainline-12.0.0_r61android-mainline-12.0.0_r45android-mainline-12.0.0_r28android-mainline-12.0.0_r118android-mainline-12.0.0_r103android-mainline-12.0.0_r10android12-mainline-ipsec-release
Change-Id: I39e756e067e2d343e9ddbeb875914f34a3b65cf5
-rw-r--r-- | rebalance_interrupts/rebalance_interrupts.cpp | 31 | ||||
-rw-r--r-- | thermal/Thermal.cpp | 23 | ||||
-rw-r--r-- | thermal/thermal-helper.cpp | 7 | ||||
-rw-r--r-- | thermal/thermal-helper.h | 2 | ||||
-rw-r--r-- | usb/UsbOverheatEvent.cpp | 9 | ||||
-rw-r--r-- | vibrator/cs40l25/Vibrator.cpp | 27 |
6 files changed, 93 insertions, 6 deletions
diff --git a/rebalance_interrupts/rebalance_interrupts.cpp b/rebalance_interrupts/rebalance_interrupts.cpp index b0d2f69e..77a0bfb0 100644 --- a/rebalance_interrupts/rebalance_interrupts.cpp +++ b/rebalance_interrupts/rebalance_interrupts.cpp @@ -224,6 +224,33 @@ bool RebalanceIrqs(const list<pair<string, list<string>>>& action_to_irqs) { return true; } +void ChownIrqAffinity() { + std::unique_ptr<DIR, decltype(&closedir)> irq_dir(opendir(PROC_IRQDIR), closedir); + if (!irq_dir) { + PLOG(ERROR) << "opening dir " PROC_IRQDIR; + return; + } + + struct dirent *entry; + while ((entry = readdir(irq_dir.get()))) { + // If the directory entry isn't a parsable number, skip it. + // . and .. get skipped here. + unsigned throwaway; + if (!ParseUint(entry->d_name, &throwaway)) + continue; + + string affinity_path(PROC_IRQDIR "/"); + affinity_path += entry->d_name; + affinity_path += "/smp_affinity"; + chown(affinity_path.c_str(), 1000, 1000); + + string affinity_list_path(PROC_IRQDIR "/"); + affinity_list_path += entry->d_name; + affinity_list_path += "/smp_affinity_list"; + chown(affinity_list_path.c_str(), 1000, 1000); + } +} + int main(int /* argc */, char* /* argv */[]) { map<string, list<string>> irq_mapping; list<pair<string, list<string>>> action_to_irqs; @@ -238,6 +265,10 @@ int main(int /* argc */, char* /* argv */[]) { return 1; } + // Change ownership of smp_affinity and smp_affinity_list handles + // from root to system. + ChownIrqAffinity(); + // Some IRQs are already assigned to a subset of cores, usually for // good reason (like some drivers have an IRQ per core, for per-core // queues.) Find the set of IRQs that haven't been mapped to specific diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp index 80aa53c4..c448b709 100644 --- a/thermal/Thermal.cpp +++ b/thermal/Thermal.cpp @@ -121,7 +121,7 @@ Return<void> Thermal::getCurrentTemperatures(bool filterType, TemperatureType_2_ return setInitFailureAndCallback(_hidl_cb, temperatures); } - if (!thermal_helper_.fillCurrentTemperatures(filterType, type, &temperatures)) { + if (!thermal_helper_.fillCurrentTemperatures(filterType, false, type, &temperatures)) { return setFailureAndCallback(_hidl_cb, temperatures, "Failed to read thermal sensors."); } @@ -171,6 +171,8 @@ Return<void> Thermal::registerThermalChangedCallback(const sp<IThermalChangedCal bool filterType, TemperatureType_2_0 type, registerThermalChangedCallback_cb _hidl_cb) { ThermalStatus status; + hidl_vec<Temperature_2_0> temperatures; + if (callback == nullptr) { status.code = ThermalStatusCode::FAILURE; status.debugMessage = "Invalid nullptr callback"; @@ -193,6 +195,21 @@ Return<void> Thermal::registerThermalChangedCallback(const sp<IThermalChangedCal << " Type: " << android::hardware::thermal::V2_0::toString(type); } _hidl_cb(status); + + // Send notification right away after thermal callback registration + if (thermal_helper_.fillCurrentTemperatures(filterType, true, type, &temperatures)) { + for (const auto &t : temperatures) { + if (!filterType || t.type == type) { + LOG(INFO) << "Sending notification: " + << " Type: " << android::hardware::thermal::V2_0::toString(t.type) + << " Name: " << t.name << " CurrentValue: " << t.value + << " ThrottlingStatus: " + << android::hardware::thermal::V2_0::toString(t.throttlingStatus); + callback->notifyThrottling(t); + } + } + } + return Void(); } @@ -565,8 +582,8 @@ Return<void> Thermal::debug(const hidl_handle &handle, const hidl_vec<hidl_strin { dump_buf << "getCurrentTemperatures:" << std::endl; hidl_vec<Temperature_2_0> temperatures; - if (!thermal_helper_.fillCurrentTemperatures(false, TemperatureType_2_0::SKIN, - &temperatures)) { + if (!thermal_helper_.fillCurrentTemperatures( + false, false, TemperatureType_2_0::SKIN, &temperatures)) { dump_buf << "Failed to getCurrentTemperatures." << std::endl; } diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp index cbd63939..6eb0d508 100644 --- a/thermal/thermal-helper.cpp +++ b/thermal/thermal-helper.cpp @@ -1016,7 +1016,8 @@ bool ThermalHelper::fillTemperatures(hidl_vec<Temperature_1_0> *temperatures) co return current_index > 0; } -bool ThermalHelper::fillCurrentTemperatures(bool filterType, TemperatureType_2_0 type, +bool ThermalHelper::fillCurrentTemperatures(bool filterType, bool filterCallback, + TemperatureType_2_0 type, hidl_vec<Temperature_2_0> *temperatures) const { std::vector<Temperature_2_0> ret; for (const auto &name_info_pair : sensor_info_map_) { @@ -1024,13 +1025,15 @@ bool ThermalHelper::fillCurrentTemperatures(bool filterType, TemperatureType_2_0 if (filterType && name_info_pair.second.type != type) { continue; } + if (filterCallback && !name_info_pair.second.send_cb) { + continue; + } if (readTemperature(name_info_pair.first, &temp, nullptr, name_info_pair.second.virtual_sensor_info != nullptr)) { ret.emplace_back(std::move(temp)); } else { LOG(ERROR) << __func__ << ": error reading temperature for sensor: " << name_info_pair.first; - return false; } } *temperatures = ret; diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h index 672d3522..20205979 100644 --- a/thermal/thermal-helper.h +++ b/thermal/thermal-helper.h @@ -112,7 +112,7 @@ class ThermalHelper { ~ThermalHelper() = default; bool fillTemperatures(hidl_vec<Temperature_1_0> *temperatures) const; - bool fillCurrentTemperatures(bool filterType, TemperatureType_2_0 type, + bool fillCurrentTemperatures(bool filterType, bool filterCallback, TemperatureType_2_0 type, hidl_vec<Temperature_2_0> *temperatures) const; bool fillTemperatureThresholds(bool filterType, TemperatureType_2_0 type, hidl_vec<TemperatureThreshold> *thresholds) const; diff --git a/usb/UsbOverheatEvent.cpp b/usb/UsbOverheatEvent.cpp index f00258f5..408a0adf 100644 --- a/usb/UsbOverheatEvent.cpp +++ b/usb/UsbOverheatEvent.cpp @@ -206,6 +206,11 @@ bool UsbOverheatEvent::registerListener() { bool UsbOverheatEvent::startRecording() { lock_guard<mutex> lock(lock_); + + // Bail out if temperature was being monitored previously + if (monitorTemperature) + return true; + wakeLockAcquire(); monitorTemperature = true; cv_.notify_all(); @@ -217,6 +222,10 @@ bool UsbOverheatEvent::stopRecording() { uint64_t flag = 100; unsigned long ret; + // Bail out if temperature was not being monitored previously + if (!monitorTemperature) + return true; + wakeLockRelease(); monitorTemperature = false; ret = TEMP_FAILURE_RETRY(write(event_fd_, &flag, sizeof(flag))); diff --git a/vibrator/cs40l25/Vibrator.cpp b/vibrator/cs40l25/Vibrator.cpp index d3da217b..826a28d8 100644 --- a/vibrator/cs40l25/Vibrator.cpp +++ b/vibrator/cs40l25/Vibrator.cpp @@ -234,6 +234,7 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal) } createPwleMaxLevelLimitMap(); + mIsUnderExternalControl = false; } ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) { @@ -309,6 +310,27 @@ ndk::ScopedAStatus Vibrator::setExternalControl(bool enabled) { ATRACE_NAME("Vibrator::setExternalControl"); setGlobalAmplitude(enabled); + if (isUnderExternalControl() == enabled) { + if (enabled) { + ALOGE("Restart the external process."); + if (mHasHapticAlsaDevice) { + if (!enableHapticPcmAmp(&mHapticPcm, !enabled, mCard, mDevice)) { + ALOGE("Failed to %s haptic pcm device: %d", (enabled ? "enable" : "disable"), + mDevice); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + } + if (mHwApi->hasAspEnable()) { + if (!mHwApi->setAspEnable(!enabled)) { + ALOGE("Failed to set external control (%d): %s", errno, strerror(errno)); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + } + } else { + ALOGE("The external control is already disabled."); + return ndk::ScopedAStatus::ok(); + } + } if (mHasHapticAlsaDevice) { if (!enableHapticPcmAmp(&mHapticPcm, enabled, mCard, mDevice)) { ALOGE("Failed to %s haptic pcm device: %d", (enabled ? "enable" : "disable"), mDevice); @@ -415,6 +437,11 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect> &composi ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, const std::shared_ptr<IVibratorCallback> &callback) { + if (isUnderExternalControl()) { + setExternalControl(false); + ALOGE("Device is under external control mode. Force to disable it to prevent chip hang " + "problem."); + } if (mAsyncHandle.wait_for(ASYNC_COMPLETION_TIMEOUT) != std::future_status::ready) { ALOGE("Previous vibration pending."); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); |