Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1075774ybl; Wed, 14 Aug 2019 10:18:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJjVVcNK+13cLaL3SCoBsOnzk5whLfGid95XGst7stOGW3TP3L+UwXPOEBCRIwlNjRz4jw X-Received: by 2002:a17:90a:4803:: with SMTP id a3mr803784pjh.58.1565803085662; Wed, 14 Aug 2019 10:18:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803085; cv=none; d=google.com; s=arc-20160816; b=XtXdO4J2AmUkAuQ+WOOmTMTl32mKSrxAqxuuFPWQ7SAf40lFj8cObjqptxWo1YvDug 3KVKVAbl+M1weRAZRiYTWKZp5as2X8yfe+VUCyN7EjkiZ6Eouv1HEoYeEZybJuz2Z1ey Dtze6s90ETqCf5ydw4ukk/RUe6qWOE6e9Qkn3Dtk80U7wb//AJ3F0+ZBU9lUovpLA2gE oEiDI+ARsb3xbc6c8UT+5MN7ixR7oLVLfc/j1TKua3K/aiNgT5obAdgLcSbOzGiAVVe3 kYiEg6DoQipuy07k/1H8Exfo3HS4Y+M9WMU/rSevzydBwI09MUMMGTtm2zzf4cjxhejA q/qg== 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=TmwoiKM6vG7AtjJ5QGeNGHTBWpMM6xdBZqnsmBxr4tM=; b=P7a+QGftC/QSnku840Bi4cVpPF1C3ntqlHhxs5ALWtSYzBsBQ0DP4OKrn3BbN7lmLf KPWb4qb8OekDM+/FeYgzMkJgM09OAgQHCfyTV5zjPVvgUKjhj0ioiFE5DyanlaioLcIr sF42c1khFCJ6cQmwp4H21Eggg0GvferXVwp1QqwnoG+RPwx7OatAD/u/Ea9PH686w5E3 iz4z+AM0PIShEqyPMKBu3mbq2ol0woTyFFknrees8pYBrR5o6WHm13zbAjQLSJhSa6i7 7hV4TThRv51uNBgVa9+ryOprXWtDpHrFVee6sGCNnd/8LSlTC6jK9a6EXFDRa5qqrZb9 KPlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gu3F3T59; 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 q26si190337pgt.233.2019.08.14.10.17.49; Wed, 14 Aug 2019 10:18:05 -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=gu3F3T59; 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 S1730831AbfHNRRI (ORCPT + 99 others); Wed, 14 Aug 2019 13:17:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:37870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729449AbfHNRNg (ORCPT ); Wed, 14 Aug 2019 13:13:36 -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 162DF2133F; Wed, 14 Aug 2019 17:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802815; bh=r9w7miScZdmWFyZcTYDiMP1IwH1WZO9gDwXNl10KY8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gu3F3T59Xvo5/poc5a/VB5B5mpL+4/K6nK2X9NcDoHuT4hAIFRyBlIAMs13TqqIVy /ObwPqbs0BXXONDjuX8+xVifyqU0gVO7+3vWqkyj/5BykumHVa4fL3/HbsJBB+e+B8 //VH6U3Zu/tloLUdniHGeqsH375rJ6ySGh0q0Dic= 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.14 36/69] ALSA: compress: Fix regression on compressed capture streams Date: Wed, 14 Aug 2019 19:01:34 +0200 Message-Id: <20190814165747.897532300@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 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