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

Commit 3472ef50 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm-cpe-lsm: Correct handling of stopping LAB thread"

parents 67a01c5c 11ba943d
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -343,6 +343,16 @@ static int msm_cpe_lsm_lab_stop(struct snd_pcm_substream *substream)
			__func__);
		rc = kthread_stop(session->lsm_lab_thread);

		/*
		 * kthread_stop returns EINTR if the thread_fn
		 * was not scheduled before calling kthread_stop.
		 * In this case, we dont need to wait for lab
		 * thread to complete as lab thread will not be
		 * scheduled at all.
		 */
		if (rc == -EINTR)
			goto done;

		/* Wait for the lab thread to exit */
		rc = wait_for_completion_timeout(
				&lab_d->thread_complete,
@@ -355,11 +365,6 @@ static int msm_cpe_lsm_lab_stop(struct snd_pcm_substream *substream)
		}
	}

	lab_d->thread_status = MSM_LSM_LAB_THREAD_STOP;
	lab_d->buf_idx = 0;
	atomic_set(&lab_d->in_count, 0);
	lab_d->dma_write = 0;

	rc = lsm_ops->lab_ch_setup(cpe->core_handle,
				   session,
				   WCD_CPE_PRE_DISABLE);
@@ -392,7 +397,12 @@ static int msm_cpe_lsm_lab_stop(struct snd_pcm_substream *substream)
		dev_err(rtd->dev,
			"%s: POST ch teardown failed, err = %d\n",
			__func__, rc);

done:
	lab_d->thread_status = MSM_LSM_LAB_THREAD_STOP;
	lab_d->buf_idx = 0;
	atomic_set(&lab_d->in_count, 0);
	lab_d->dma_write = 0;

	return 0;
}