Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1083793ybl; Wed, 14 Aug 2019 10:25:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzA5K02L01TcoLsGY8eeo/foUWjOwi+PeMC4HPnTttyp5ROW1qHRwZgUkw6ROOQSP1Ou+gI X-Received: by 2002:a63:fb14:: with SMTP id o20mr263977pgh.136.1565803554675; Wed, 14 Aug 2019 10:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803554; cv=none; d=google.com; s=arc-20160816; b=Trl9QfQpeqnC6KI9NnAEw1/l7aonYFFCgApPdswTeGjPBj0DfLUBafCmJRx1rEwqll MdEVDkmq0IZBp5egXskw3r/6gMgn7G+jmJudMxOlZKkdd7Z9TPUli3+hrcl/iYAGaReq pKtsn9/djAOVXqJMGO8xp9kG5CJ8WUSU0lalEd+FdL7dh12pYTw/TUbjQ82xOsRQBBFe XTWC9NEMz1I5q3rGV0NMJ45UqiV0ZWrVluiiZ+eqSpROQjvm7EVqutknnQkTDkAA21zo CbHUGLG22kn4O2D7CwozGlwDJgpAe5NoDaA9vPp0H5uLycqRlKPIlSXF4QqfnmnwAZwh VRFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVGq2QFvk2fY6FmrSk9wSWawNnJ8g0kLu8ztwGQO9yM=; b=EeIOOkuvOAslFUu9oBuC4ZxA2N9AgpNf5AQ97TuFxi5Z8wa2injcVyXWY7F/n9+Qlq V5kkSxlqebEZWkKEUEb4EPzwKLp0GMv+jrkcSySAYWq8FDvg4EGs85EB9b8R0blLZwNo fHeycYcf30b5ArFXvf6/LKelZ0UVJgi4ZOPvxCxcayI2SkEC7YoQmNcJmuW1o+FQp0RF LsOPI63S7P/Vr0i8k8gqRtBVlb21xpm20aHos5j3WX4MxByNy9CgCMcxueacoS5zPHIE QaV/Bc/y7EgmJOMOgsQYJslszr5XiF/iSAF3P8dIOKjA976bmS+6xYyzkkS5rzDDA8kF p+Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LfK6LnJc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si250913pla.283.2019.08.14.10.25.38; Wed, 14 Aug 2019 10:25:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LfK6LnJc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729783AbfHNRHE (ORCPT + 99 others); Wed, 14 Aug 2019 13:07:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:56332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729771AbfHNRHA (ORCPT ); Wed, 14 Aug 2019 13:07:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0F6A216F4; Wed, 14 Aug 2019 17:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802419; bh=Sv+DXEGPymd/+4y5/R4DkHHb5EDXEL2AbcdXfNwWVSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfK6LnJcw/sbUYEMw21bnarVYW7i79jaAalr0+WuIn4n3BaQegwew/abRgw9w7KPo MEzqN7nfzbXlN6uHgDa5uKSK1WNt0Y2CZnBCyG0NTFGRQOd+kGJNAIXESRtglmwGvX aq9+iCahJSMhoCzRehWv+FOhpU7Y+axrzLlQk//s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Vinod Koul , Takashi Iwai , Sasha Levin Subject: [PATCH 5.2 092/144] ALSA: compress: Fix regression on compressed capture streams Date: Wed, 14 Aug 2019 19:00:48 +0200 Message-Id: <20190814165803.722429368@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 c5188ff724d12..bc88d6f964da9 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -173,10 +173,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 99b8821587053..d79aee6b9edd2 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -574,10 +574,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; } @@ -693,8 +690,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