Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1079542ybl; Wed, 14 Aug 2019 10:21:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWmIQzwtApHTjSuXLAB5+c61+azWyBktN4NcvnnI5JcScZAjPu+fTeMoAXOdKILp0RVugE X-Received: by 2002:a17:902:f217:: with SMTP id gn23mr456498plb.21.1565803303133; Wed, 14 Aug 2019 10:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803303; cv=none; d=google.com; s=arc-20160816; b=wgHy5g5RIWgsovO08pxivpPo2+EfBPNFH7e1jzyzFJMPDC5RpWfsAkYHeudpF05zil n1fp9HlIaa72KmJYP4PXXRFI37XvEIRwJ7+QvRwzL139fKeWOEGNdbc4Szrhpy2Pymza Lz5i7VMRhTNOMWNaa2rdQh13XTrvZvJUt2R90EIkvtLf3Y2yUMx0pGoBCm0itJXtBd9v 8IbdlhLuSrvbP9DANoSSj0p+ebE4Unj29qlHepQ2OlEgkmCn7E9ePge4rD8JYBYXywHs oW6VuXH02CJOINuN8r8wMtrKlF/qMvsxxQG4f1t1/Y6NkBOkJjrnAl4I0yNeZi7GoBQ8 BBNw== 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=Vls/vEZ25W3llLK8dmrggCMEkBAni2yuYp9LHBwB2f4=; b=gbb6Y+JdJ+oAo1hfniZgGlAJPU+Arz+Ri8uFE5Q8MFjkYdp8dh0TNG0OJyVO9J2czG Zyji8QwDqaAdexcfr+L1zCfbzgXOF8REDEXmSiKOgDgGvbvPDs4xZ3YENJDBxfj4EkYS b9GgZtpvQOSe0AjjPpnTZDgaJDqvwPcCM1708pI0WM8RKoXc4V7wAvIiF/eyvArPYH0t vSGXlmmAtyz//sGrxPaLA+DuUsM8rRMP7GSQlx2qUe3ErDtBt8DzAOvtR/QlGK10MV+q sOdkxv8gN/xy/FKJkey4jwGWZyox+7IFuP+XkceKg87+Kkr4ywOoKZh5Ny1ruIvgROfU gxjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uqqzA2nW; 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 q13si234790pjb.13.2019.08.14.10.21.27; Wed, 14 Aug 2019 10:21:43 -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=uqqzA2nW; 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 S1730402AbfHNRU6 (ORCPT + 99 others); Wed, 14 Aug 2019 13:20:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:32972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730458AbfHNRKT (ORCPT ); Wed, 14 Aug 2019 13:10:19 -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 E71A1208C2; Wed, 14 Aug 2019 17:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802618; bh=6GosC4elGbX+KzDCnJUm/Y+U5J9N5KgRbwtGOYYysbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqqzA2nWi294SM+AylHbJAjLf50Hv/tqX2WrD5AxK+6r/9Ived2Rz4EnhtgkyYP90 xSfi5PLncDb8mvty9CDs5UNqDww1eG9q6vWaIp+3eyujFqckhEdL2IzysmbO7r+/Ne cXNltalj/4OXuwS3dR9jr2Pn5HdTGriSW81Wodfo= 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 4.19 52/91] ALSA: compress: Fix regression on compressed capture streams Date: Wed, 14 Aug 2019 19:01:15 +0200 Message-Id: <20190814165751.788704461@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 e87f2d5b3cc65..127c2713b543a 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -171,10 +171,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 8b78ddffa509a..44e81cf302401 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