From f3ca63ccb89160a8ebf51466928ef7fcc673a17b Mon Sep 17 00:00:00 2001
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Date: Wed, 2 Jun 2021 21:14:48 +0300
Subject: [PATCH] dmic: fix pause/release error leading to invalid
 dmic_active_fifos

The 'in_active' parameter of dmic_stop() is used to control whether
the fifo should be released or not. In case of COMP_TRIGGER_PAUSE,
this should be false and the 'dmic_active_fifos' count should not
be modified.

Without this fix:

  PAUSED -> RELEASE -> dmic_start() -> no change on dmic_active_fifos

  ACTIVE -> PAUSE   -> dmic_stop()  -> dmic_active_fifos--

If a test case repeatedly pauses and releases, 'dmic_active_fifos'
will go out-of-sync.

Fix the issue that dmic_stop for PAUSE does not release the fifo
reference.

Fixes: 22731744cb04 ("dmic: don't decrement active FIFO count below 0")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 src/drivers/intel/dmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/drivers/intel/dmic.c b/src/drivers/intel/dmic.c
index fff265cf9ac0..ae6b131e5f26 100644
--- a/src/drivers/intel/dmic.c
+++ b/src/drivers/intel/dmic.c
@@ -1527,7 +1527,7 @@ static int dmic_trigger(struct dai *dai, int cmd, int direction)
 		break;
 	case COMP_TRIGGER_PAUSE:
 		dmic->state = COMP_STATE_PAUSED;
-		dmic_stop(dai, true);
+		dmic_stop(dai, false);
 		break;
 	case COMP_TRIGGER_RESUME:
 		dmic_context_restore(dai);