summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-09 08:00:38 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-09 08:00:38 +0000
commita112710fe161f7384e2cfb5e5548c55aeedfd41b (patch)
tree9eca0c76b18f3e180614f2d8e38db020c42e1326
parent5526cc36bb351ae6bdfd43baf384fa6e7817164a (diff)
parent2f56f5f47a6b97e8a617324039fc81f9b2476241 (diff)
downloadpixel-android12-mainline-resolv-release.tar.gz
Change-Id: I18d8729bf5ee100087a2add02a45f7354d2857c4
-rw-r--r--rebalance_interrupts/rebalance_interrupts.cpp31
-rw-r--r--vibrator/cs40l25/Vibrator.cpp27
2 files changed, 58 insertions, 0 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/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);