From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAB97C32750 for ; Fri, 2 Aug 2019 13:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFB8A21773 for ; Fri, 2 Aug 2019 13:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564752307; bh=nEEjdQyCnzLF7xcM6Z3mxPj0nH0nurFNEVCNFZGJvF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=O0wX/9gqA8UUNne6Y9Ticqwp+r6BzQLf/Fmr4UcKMVD2I+S99q1nbVbLkzLHXP57j ykmAWAMjE67bbzNJmxmibXhVjDIkIvKsjXnE99x2duXtJwG8iqZN6po5wSCsnFhPtu zRjUVV6sx7PQiKeH9f/idLgfChpQR76qUiwQTdIA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394298AbfHBNY5 (ORCPT ); Fri, 2 Aug 2019 09:24:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394275AbfHBNYx (ORCPT ); Fri, 2 Aug 2019 09:24:53 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA6D020644; Fri, 2 Aug 2019 13:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564752292; bh=nEEjdQyCnzLF7xcM6Z3mxPj0nH0nurFNEVCNFZGJvF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZ5HAplHHiDS/KvFM2BF8KL+wC/n1Z0hnrU+OFFU5nHGqhUPfDpZeiRsB2xB5LdUJ Zl+ehz/8iCzexUOEOA+0+p79OJ3yWi7LVFVCTEYCipPtz5uaTv58eKhKKfIPqKoyG1 nPEI8ASeL4/N9/+EClG+CDyL/ZzySjk1dCVDgGd8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Charles Keepax , Vinod Koul , Takashi Iwai , Sasha Levin Subject: [PATCH AUTOSEL 4.14 15/30] ALSA: compress: Fix regression on compressed capture streams Date: Fri, 2 Aug 2019 09:24:07 -0400 Message-Id: <20190802132422.13963-15-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802132422.13963-1-sashal@kernel.org> References: <20190802132422.13963-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Charles Keepax [ Upstream commit 4475f8c4ab7b248991a60d9c02808dbb813d6be8 ] A previous fix to the stop handling on compressed capture streams causes some knock on issues. The previous fix updated snd_compr_drain_notify to set the state back to PREPARED for capture streams. This causes some issues however as the handling for snd_compr_poll differs between the two states and some user-space applications were relying on the poll failing after the stream had been stopped. To correct this regression whilst still fixing the original problem the patch was addressing, update the capture handling to skip the PREPARED state rather than skipping the SETUP state as it has done until now. Fixes: 4f2ab5e1d13d ("ALSA: compress: Fix stop handling on compressed capture streams") Signed-off-by: Charles Keepax Acked-by: Vinod Koul Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- include/sound/compress_driver.h | 5 +---- sound/core/compress_offload.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index 392bac18398ba..33a07c3badf01 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -186,10 +186,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) if (snd_BUG_ON(!stream)) return; - if (stream->direction == SND_COMPRESS_PLAYBACK) - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - else - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; + stream->runtime->state = SNDRV_PCM_STATE_SETUP; wake_up(&stream->runtime->sleep); } diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 555df64d46ffc..cf1317546b0ff 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -575,10 +575,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) stream->metadata_set = false; stream->next_track = false; - if (stream->direction == SND_COMPRESS_PLAYBACK) - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - else - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; + stream->runtime->state = SNDRV_PCM_STATE_SETUP; } else { return -EPERM; } @@ -694,8 +691,17 @@ static int snd_compr_start(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED) + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_SETUP: + if (stream->direction != SND_COMPRESS_CAPTURE) + return -EPERM; + break; + case SNDRV_PCM_STATE_PREPARED: + break; + default: return -EPERM; + } + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START); if (!retval) stream->runtime->state = SNDRV_PCM_STATE_RUNNING; -- 2.20.1