Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e72ff02b authored by Andy Hung's avatar Andy Hung
Browse files

AudioFlinger: Workaround for dumpsys stall

Binder fds may not close immediately due to a race
condition when the last refcount is removed on the remote
binder thread and it is blocked in the kernel waiting for data.
Issue a binder ping command to unblock the remote binder thread
and complete the fd close / release.

Test: adb shell dumpsys media.audio_flinger (repeat many times)
Bug: 111997867
Bug: 177271958
Change-Id: I2237d1af430dfad08f22de6efaec9b04c19bdc5a
parent 6dd2ccb0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -463,6 +463,18 @@ status_t DeviceHalHidl::dump(int fd) {
    hidlHandle->data[0] = fd;
    Return<void> ret = mDevice->debug(hidlHandle, {} /* options */);
    native_handle_delete(hidlHandle);

    // TODO(b/111997867, b/177271958)  Workaround - remove when fixed.
    // A Binder transmitted fd may not close immediately due to a race condition b/111997867
    // when the remote binder thread removes the last refcount to the fd blocks in the
    // kernel for binder activity. We send a Binder ping() command to unblock the thread
    // and complete the fd close / release.
    //
    // See DeviceHalHidl::dump(), EffectHalHidl::dump(), StreamHalHidl::dump(),
    //     EffectsFactoryHalHidl::dumpEffects().

    (void)mDevice->ping(); // synchronous Binder call

    return processReturn("dump", ret);
}

+12 −0
Original line number Diff line number Diff line
@@ -239,6 +239,18 @@ status_t EffectHalHidl::dump(int fd) {
    hidlHandle->data[0] = fd;
    Return<void> ret = mEffect->debug(hidlHandle, {} /* options */);
    native_handle_delete(hidlHandle);

    // TODO(b/111997867, b/177271958)  Workaround - remove when fixed.
    // A Binder transmitted fd may not close immediately due to a race condition b/111997867
    // when the remote binder thread removes the last refcount to the fd blocks in the
    // kernel for binder activity. We send a Binder ping() command to unblock the thread
    // and complete the fd close / release.
    //
    // See DeviceHalHidl::dump(), EffectHalHidl::dump(), StreamHalHidl::dump(),
    //     EffectsFactoryHalHidl::dumpEffects().

    (void)mEffect->ping(); // synchronous Binder call

    return ret.isOk() ? OK : FAILED_TRANSACTION;
}

+12 −0
Original line number Diff line number Diff line
@@ -149,6 +149,18 @@ status_t EffectsFactoryHalHidl::dumpEffects(int fd) {
    hidlHandle->data[0] = fd;
    Return<void> ret = mEffectsFactory->debug(hidlHandle, {} /* options */);
    native_handle_delete(hidlHandle);

    // TODO(b/111997867, b/177271958)  Workaround - remove when fixed.
    // A Binder transmitted fd may not close immediately due to a race condition b/111997867
    // when the remote binder thread removes the last refcount to the fd blocks in the
    // kernel for binder activity. We send a Binder ping() command to unblock the thread
    // and complete the fd close / release.
    //
    // See DeviceHalHidl::dump(), EffectHalHidl::dump(), StreamHalHidl::dump(),
    //     EffectsFactoryHalHidl::dumpEffects().

    (void)mEffectsFactory->ping(); // synchronous Binder call

    return processReturn(__FUNCTION__, ret);
}

+12 −0
Original line number Diff line number Diff line
@@ -158,6 +158,18 @@ status_t StreamHalHidl::dump(int fd) {
    hidlHandle->data[0] = fd;
    Return<void> ret = mStream->debug(hidlHandle, {} /* options */);
    native_handle_delete(hidlHandle);

    // TODO(b/111997867, b/177271958)  Workaround - remove when fixed.
    // A Binder transmitted fd may not close immediately due to a race condition b/111997867
    // when the remote binder thread removes the last refcount to the fd blocks in the
    // kernel for binder activity. We send a Binder ping() command to unblock the thread
    // and complete the fd close / release.
    //
    // See DeviceHalHidl::dump(), EffectHalHidl::dump(), StreamHalHidl::dump(),
    //     EffectsFactoryHalHidl::dumpEffects().

    (void)mStream->ping(); // synchronous Binder call

    mStreamPowerLog.dump(fd);
    return processReturn("dump", ret);
}