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

Commit 90e613f9 authored by Sharad Sangle's avatar Sharad Sangle Committed by Gerrit - the friendly Code Review server
Browse files

hal: handle EINRESET error on pcm_open

Watchdog is hitting due to excessive logging
in kernel space, while SSR/PDR stress test.

Framework try to call pcm_open or compress_open
until the sound card offline event is received in
case of SSR/PDR, there is a window between actual
SSR/PDR and the offline event and this window at
times gets bigger due to excessive logging in
driver space, due to excessive logging offline event
get delayed, and during this window if framework
try to call pcm_open or compress_open multiple times
then there is excessive logging in driver layer
leading to watchdog hit .

In case of SSR\PDR, pcm_open will result in
error with return type EINRESET. As a workaround,
handle error EINRESET return type in hal when
pcm_open or compress_open is called to avoid
excessive logging in driver layer.

CRs-fixed: 2223369
Change-Id: Icc18b5a343cedc1ead004e06e22261850a7bda33
parent 17bad40b
Loading
Loading
Loading
Loading
+55 −0
Original line number Original line Diff line number Diff line
@@ -2565,6 +2565,14 @@ int start_input_stream(struct stream_in *in)
            in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
            in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
                               flags, &config);
                               flags, &config);
            ATRACE_END();
            ATRACE_END();
            if (errno == ENETRESET && !pcm_is_ready(in->pcm)) {
                ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
                adev->card_status = CARD_STATUS_OFFLINE;
                in->card_status = CARD_STATUS_OFFLINE;
                ret = -EIO;
                goto error_open;
            }

            if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
            if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
                ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
                ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
                if (in->pcm != NULL) {
                if (in->pcm != NULL) {
@@ -3195,6 +3203,14 @@ int start_output_stream(struct stream_out *out)
            out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
            out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
                               flags, &out->config);
                               flags, &out->config);
            ATRACE_END();
            ATRACE_END();
            if (errno == ENETRESET && !pcm_is_ready(out->pcm)) {
                ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
                out->card_status = CARD_STATUS_OFFLINE;
                adev->card_status = CARD_STATUS_OFFLINE;
                ret = -EIO;
                goto error_open;
            }

            if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
            if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
                ALOGE("%s: %s", __func__, pcm_get_error(out->pcm));
                ALOGE("%s: %s", __func__, pcm_get_error(out->pcm));
                if (out->pcm != NULL) {
                if (out->pcm != NULL) {
@@ -3240,6 +3256,14 @@ int start_output_stream(struct stream_out *out)
                                   out->pcm_device_id,
                                   out->pcm_device_id,
                                   COMPRESS_IN, &out->compr_config);
                                   COMPRESS_IN, &out->compr_config);
        ATRACE_END();
        ATRACE_END();
        if (errno == ENETRESET && !is_compress_ready(out->compr)) {
                ALOGE("%s: compress_open failed errno:%d\n", __func__, errno);
                adev->card_status = CARD_STATUS_OFFLINE;
                out->card_status = CARD_STATUS_OFFLINE;
                ret = -EIO;
                goto error_open;
        }

        if (out->compr && !is_compress_ready(out->compr)) {
        if (out->compr && !is_compress_ready(out->compr)) {
            ALOGE("%s: failed /w error %s", __func__, compress_get_error(out->compr));
            ALOGE("%s: failed /w error %s", __func__, compress_get_error(out->compr));
            compress_close(out->compr);
            compress_close(out->compr);
@@ -5191,8 +5215,15 @@ static int out_create_mmap_buffer(const struct audio_stream_out *stream,
    uint32_t buffer_size;
    uint32_t buffer_size;


    ALOGD("%s", __func__);
    ALOGD("%s", __func__);
    lock_output_stream(out);
    pthread_mutex_lock(&adev->lock);
    pthread_mutex_lock(&adev->lock);


    if (CARD_STATUS_OFFLINE == out->card_status ||
        CARD_STATUS_OFFLINE == adev->card_status) {
        ALOGW("out->card_status or adev->card_status offline, try again");
        ret = -EIO;
        goto exit;
    }
    if (info == NULL || min_size_frames == 0) {
    if (info == NULL || min_size_frames == 0) {
        ALOGE("%s: info = %p, min_size_frames = %d", __func__, info, min_size_frames);
        ALOGE("%s: info = %p, min_size_frames = %d", __func__, info, min_size_frames);
        ret = -EINVAL;
        ret = -EINVAL;
@@ -5217,6 +5248,14 @@ static int out_create_mmap_buffer(const struct audio_stream_out *stream,
          __func__, adev->snd_card, out->pcm_device_id, out->config.channels);
          __func__, adev->snd_card, out->pcm_device_id, out->config.channels);
    out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
    out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
                        (PCM_OUT | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &out->config);
                        (PCM_OUT | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &out->config);
    if (errno == ENETRESET && !pcm_is_ready(out->pcm)) {
        ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
        out->card_status = CARD_STATUS_OFFLINE;
        adev->card_status = CARD_STATUS_OFFLINE;
        ret = -EIO;
        goto exit;
    }

    if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
    if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
        step = "open";
        step = "open";
        ret = -ENODEV;
        ret = -ENODEV;
@@ -5270,6 +5309,7 @@ exit:
        }
        }
    }
    }
    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&out->lock);
    return ret;
    return ret;
}
}


@@ -5807,6 +5847,13 @@ static int in_create_mmap_buffer(const struct audio_stream_in *stream,
    pthread_mutex_lock(&adev->lock);
    pthread_mutex_lock(&adev->lock);
    ALOGV("%s in %p", __func__, in);
    ALOGV("%s in %p", __func__, in);


    if (CARD_STATUS_OFFLINE == in->card_status||
        CARD_STATUS_OFFLINE == adev->card_status) {
        ALOGW("in->card_status or adev->card_status offline, try again");
        ret = -EIO;
        goto exit;
    }

    if (info == NULL || min_size_frames == 0) {
    if (info == NULL || min_size_frames == 0) {
        ALOGE("%s invalid argument info %p min_size_frames %d", __func__, info, min_size_frames);
        ALOGE("%s invalid argument info %p min_size_frames %d", __func__, info, min_size_frames);
        ret = -EINVAL;
        ret = -EINVAL;
@@ -5832,6 +5879,14 @@ static int in_create_mmap_buffer(const struct audio_stream_in *stream,
          __func__, adev->snd_card, in->pcm_device_id, in->config.channels);
          __func__, adev->snd_card, in->pcm_device_id, in->config.channels);
    in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
    in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
                        (PCM_IN | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &in->config);
                        (PCM_IN | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &in->config);
    if (errno == ENETRESET && !pcm_is_ready(in->pcm)) {
        ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
        in->card_status = CARD_STATUS_OFFLINE;
        adev->card_status = CARD_STATUS_OFFLINE;
        ret = -EIO;
        goto exit;
    }

    if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
    if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
        step = "open";
        step = "open";
        ret = -ENODEV;
        ret = -ENODEV;