From patchwork Tue Jul 9 10:52:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 11036845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85586112C for ; Tue, 9 Jul 2019 10:53:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 722F2286A8 for ; Tue, 9 Jul 2019 10:53:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 644EB286CB; Tue, 9 Jul 2019 10:53:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E44ED286A8 for ; Tue, 9 Jul 2019 10:53:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 92AE615E5; Tue, 9 Jul 2019 12:52:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 92AE615E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1562669591; bh=3ga4g9mKBth7fR3RCOrE+fWGM0pkpTNmVEKPShwDdIc=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Zs0smrW1M5IdgSvhooT+rCoeb7hDUZdOOf42SeG6iejcysrNOcLLtCaaReIdn4dPf hZHiRnObhAC+qi/KeLAdliZ4fp34+5aohsoS7wOgIA1+X6lrfleYIa1eodDDSdETNM V+8vDn9N+TEljPh1NMj9B0tm91ybRnxmBl5f1XAg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0C4DEF801A4; Tue, 9 Jul 2019 12:52:21 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CFBEF80291; Tue, 9 Jul 2019 12:52:19 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5493AF801A4 for ; Tue, 9 Jul 2019 12:52:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5493AF801A4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Yxf0K7g2" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69ApQ9U032173; Tue, 9 Jul 2019 05:52:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=PODMain02222019; bh=WD2nOPniAsNiBDxFHEuITMKa7DmLv7L3kOJ0x2KM2fc=; b=Yxf0K7g2mIjVJ/2Nm28+0aXxgYO2v60gOGAf88CGMmRAqx4lYCJFxvoMX6SJFAv2Tvz6 ob1GFj4tPozWHP7qUBgY5CbEovcBO0QCkC86MuFQ9ZR7ZtdxUzABa7p0DujTtrmwvtgC ECoVCARj1+DjdoerK/E+uytpViJOjuGb4GqZssR0oEjFBlCncR6+MzRzaNuwcgjLFsHE mVUBTw3VkCQoNPCoDeR/JrLlWOxF3bzFiZ9ZBS0g+1CqqykFuhmWNEo2Tgz9gzvYhGZK eaov8gJVV5ww/9MZ4EKZAkO7QSZh1CZ/AtsEwc5OSeZQap9xkt5xZ3ZtTERLm5CKCeXW sA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail4.cirrus.com ([87.246.98.35]) by mx0b-001ae601.pphosted.com with ESMTP id 2tjr2nv7uj-1; Tue, 09 Jul 2019 05:52:12 -0500 Received: from EDIEX01.ad.cirrus.com (ediex01.ad.cirrus.com [198.61.84.80]) by mail4.cirrus.com (Postfix) with ESMTP id 15089611C8AF; Tue, 9 Jul 2019 05:52:19 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 9 Jul 2019 11:52:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 11:52:11 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 7684144; Tue, 9 Jul 2019 11:52:11 +0100 (BST) From: Charles Keepax To: , Date: Tue, 9 Jul 2019 11:52:08 +0100 Message-ID: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090133 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 1/4] ALSA: compress: Fix regression on compressed capture streams X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 a1a6fd75cfe50..f031495311ee4 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -587,10 +587,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; } @@ -706,8 +703,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; From patchwork Tue Jul 9 10:52:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 11036847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9C57112C for ; Tue, 9 Jul 2019 10:54:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4570286A8 for ; Tue, 9 Jul 2019 10:54:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9478E286CB; Tue, 9 Jul 2019 10:54:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC476286A8 for ; Tue, 9 Jul 2019 10:54:09 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C153A1666; Tue, 9 Jul 2019 12:53:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C153A1666 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1562669646; bh=ry6HJM5ZZE4ErUODb+dlJUOIfi81KtMA/gyl5pDTUCI=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Lea5fEfPMZkB3IuEJsTmhqKEEhl7kphorDWSp0Lkhorg/5SGZ0znfdFDi5awhYZ0x uBOviKcGGZP8+P0lacyxTvsRgijKGhLr0wxa2mTjQFDRC3aZvOan71L9TIDXLE7i9m O3xoH96jcNEb+sh+0sg5l7m871zgR9HYUMomap0A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2461BF80276; Tue, 9 Jul 2019 12:52:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 360D5F800E0; Tue, 9 Jul 2019 12:52:19 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6AA84F80273 for ; Tue, 9 Jul 2019 12:52:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6AA84F80273 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="oY/rzRDg" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69AnWOa030937; Tue, 9 Jul 2019 05:52:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=S2kgSC89PPGo4ARkpTYN+EH1hMiZ6T0R9qbXANwpzhg=; b=oY/rzRDg+9ezl2JhxABtaj3hSBSpDZxjQ4z1ynkvsyaz3u3TYIASiuJeH+boz3G6V8Rr LdD+8FLpwjPTOz/b/QEswouIeyrYV5MahctLDT5MXFxn3aRS7ttVikkXL8ALwPAvLvHD D7qxjPzzI4MwhzTxBlbcg6Qd3rX+3I7tnrd5rRoUN7+ULGXqBQJKxU1iZ0poW5wrhF+u Xa3BU+onbqfhb0gi37hSDhrj8JaWgpkZBilCFvmEkPCE8xvymbu1wXANmMVHnxe2cLbe gixKCDYRt+C/ZKfI5q19aueHEsCxmP8CB+WQqlFeIQaNh3G+4qleZpwRuVnRaH09zyT6 mA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail4.cirrus.com ([87.246.98.35]) by mx0b-001ae601.pphosted.com with ESMTP id 2tjr2nv7uh-1; Tue, 09 Jul 2019 05:52:12 -0500 Received: from EDIEX01.ad.cirrus.com (ediex01.ad.cirrus.com [198.61.84.80]) by mail4.cirrus.com (Postfix) with ESMTP id 1F41D611C8B3; Tue, 9 Jul 2019 05:52:19 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 9 Jul 2019 11:52:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 11:52:11 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 8647D2C5; Tue, 9 Jul 2019 11:52:11 +0100 (BST) From: Charles Keepax To: , Date: Tue, 9 Jul 2019 11:52:09 +0100 Message-ID: <20190709105211.11741-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> References: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090133 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 2/4] ALSA: compress: Prevent bypasses of set_params X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, whilst in SNDRV_PCM_STATE_OPEN it is possible to call snd_compr_stop, snd_compr_drain and snd_compr_partial_drain, which allow a transition to SNDRV_PCM_STATE_SETUP. The stream should only be able to move to the setup state once it has received a SNDRV_COMPRESS_SET_PARAMS ioctl. Fix this issue by not allowing those ioctls whilst in the open state. Signed-off-by: Charles Keepax --- sound/core/compress_offload.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index f031495311ee4..e1a216fd832f9 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -724,9 +724,15 @@ static int snd_compr_stop(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); if (!retval) { snd_compr_drain_notify(stream); @@ -814,9 +820,14 @@ static int snd_compr_drain(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); if (retval) { @@ -853,9 +864,16 @@ static int snd_compr_next_track(struct snd_compr_stream *stream) static int snd_compr_partial_drain(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } + /* stream can be drained only when next track has been signalled */ if (stream->next_track == false) return -EPERM; From patchwork Tue Jul 9 10:52:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 11036851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9632D13B1 for ; Tue, 9 Jul 2019 10:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 826A628438 for ; Tue, 9 Jul 2019 10:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 753FA286AE; Tue, 9 Jul 2019 10:55:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEDFC28438 for ; Tue, 9 Jul 2019 10:55:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 145BB1681; Tue, 9 Jul 2019 12:54:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 145BB1681 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1562669738; bh=CZpY8V+v6Sj8/cLi/u5pAMaaqZuNBPAzWjprBVgBhoI=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tyE6Ys3yiQADgZV+z+e9gEFMdpFvyg/hkuZPQAFtxgeV4jQveaLH47oKqrkDujuIu 5Lye8zQcbqXDWuF0ZXrP7rDpC9e8X5EElgV3Q7JoUPzUKsHK79bS02a3hk7cZIZEqH B+JIVz/WOGo5A03Qv6mfWQPnNA0qRk9p2dky5kqQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 18D93F802BC; Tue, 9 Jul 2019 12:52:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C46A8F801A4; Tue, 9 Jul 2019 12:52:20 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3BFD5F80275 for ; Tue, 9 Jul 2019 12:52:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3BFD5F80275 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="HJnWsLgr" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69AnEXo027065; Tue, 9 Jul 2019 05:52:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=n6mOsrLEc1rquRsX7VcRJeg67j0IOHDnDDeq9aDydss=; b=HJnWsLgrbF57PXsYZp1dxLDjy7qAjsarXoGto00iMOXvet38shfNamJusYOhDrEH1VPt Cq00dDysuhbJh2n2/6931jS6VV/B0S32FqkBn8xURWHp8ZARyBX49S6nD3RiQR6BOUoD cmwWzdXwDx4HXLuBM/EBVAv8JDuROJTXI6dOPBwLA8eQQESbWhhLKYvofMs6v74c3Gfr c+eWD/O8L10KMM1kZOr0Q2Ke+DoDUO+1GIf9/XCG445Vy7Jxn0D9eKhp7wKJyXSrerfx klL4iZ3c39HIh+aQVqrMdSvmWcOn6MMNzCgH3kRR4L8eNAc0z1IFZ8XzFTzULpYJZaZp wQ== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2tjs204d9u-1; Tue, 09 Jul 2019 05:52:12 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail1.cirrus.com (Postfix) with ESMTP id 40B85611C8B1; Tue, 9 Jul 2019 05:52:12 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 9 Jul 2019 11:52:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 11:52:11 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 961A02A1; Tue, 9 Jul 2019 11:52:11 +0100 (BST) From: Charles Keepax To: , Date: Tue, 9 Jul 2019 11:52:10 +0100 Message-ID: <20190709105211.11741-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> References: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090133 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 3/4] ALSA: compress: Don't allow drain operations on capture streams X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Partial drain and next track are intended for gapless playback and don't really have an obvious interpretation for a capture stream, so makes sense to not allow those operations on capture streams. Drain would make sense on a capture stream but currently the implementation of drain involves the kernel waiting for the DSP to consume its available data, whereas a capture drain would involve waiting for user-space to consume the data available on the DSP. Disallow drain on capture streams until that is implemented. Signed-off-by: Charles Keepax --- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index e1a216fd832f9..c7d56cee0d510 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -829,6 +829,10 @@ static int snd_compr_drain(struct snd_compr_stream *stream) break; } + /* drain not implemented for capture streams yet */ + if (stream->direction == SND_COMPRESS_CAPTURE) + return -EPERM; + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); if (retval) { pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval); @@ -847,6 +851,10 @@ static int snd_compr_next_track(struct snd_compr_stream *stream) if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) return -EPERM; + /* next track doesn't have any meaning for capture streams */ + if (stream->direction == SND_COMPRESS_CAPTURE) + return -EPERM; + /* you can signal next track if this is intended to be a gapless stream * and current track metadata is set */ @@ -874,6 +882,10 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) break; } + /* partial drain doesn't have any meaning for capture streams */ + if (stream->direction == SND_COMPRESS_CAPTURE) + return -EPERM; + /* stream can be drained only when next track has been signalled */ if (stream->next_track == false) return -EPERM; From patchwork Tue Jul 9 10:52:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 11036849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54DF813B1 for ; Tue, 9 Jul 2019 10:54:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 449D2286A8 for ; Tue, 9 Jul 2019 10:54:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3778E286CB; Tue, 9 Jul 2019 10:54:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A31C286A8 for ; Tue, 9 Jul 2019 10:54:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D8D731678; Tue, 9 Jul 2019 12:54:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D8D731678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1562669692; bh=rk+R47fd86zUruVk9XOMl1NURRL9WFX3prOS8b6LJqc=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tVyn3/PHcP1k3kEm1asjZ2nRtxPuywcgojF9/hbYWV3DA/2AZmgPquHvfpjRr67X4 vOPvPN9LVWk/1wn4SAPNZlmzy86SUvOGzEqgrFAfcUBufJNtM7RnH4Jpb4I2z1gYxm 8G1OeEHE4swMg1CydNpXF3+CEgzUUMXcbdoiJdks= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 01C4DF802A1; Tue, 9 Jul 2019 12:52:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9CEA9F80273; Tue, 9 Jul 2019 12:52:20 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3609DF80274 for ; Tue, 9 Jul 2019 12:52:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3609DF80274 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="q0sV75Gf" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69Ao53D027594; Tue, 9 Jul 2019 05:52:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=K6W3UgBGQKK0RMk9ZcV7yxdzMr8xHOWcu91QWBy6hsw=; b=q0sV75Gfg4tKgz4/I3dPQGAgzMYWBfT3plljvBfe6PcktmuSd8TWG6xZh81xQ3LjxgzL J0+1DJuYN+GWlnGDcd1aJn+qmUYvt6bhrbbl9bPezzvrelHIO8sXWiSU5dfsAySJNfZm lsCn2TdnX9Dn2iMU0ZljmAMtxc5t8iQDFyYAqkeQ9kH6kIptKOBj4E/M2RX0WNYBF+nH OzgIdQ0FOhgM5uubZeAtq28EfTa3BTcDqvpY6E3gSTPJn7Ff6p1ysgGW0K91Ef2lCvOh Qbq4SzyJ0xP5a7enG2LVQ2zelrIWHbt+9XzhyGE98pyuBS0pKlhV85V4AlicfNCmNYW3 aA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2tjs204d9v-1; Tue, 09 Jul 2019 05:52:13 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail1.cirrus.com (Postfix) with ESMTP id 98486611C8B8; Tue, 9 Jul 2019 05:52:12 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 9 Jul 2019 11:52:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 11:52:11 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id A46672DB; Tue, 9 Jul 2019 11:52:11 +0100 (BST) From: Charles Keepax To: , Date: Tue, 9 Jul 2019 11:52:11 +0100 Message-ID: <20190709105211.11741-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> References: <20190709105211.11741-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=911 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090133 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 4/4] ALSA: compress: Be more restrictive about when a drain is allowed X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Draining makes little sense in the situation of hardware overrun, as the hardware will have consumed all its available samples. Additionally, draining whilst the stream is paused would presumably get stuck as no data is being consumed on the DSP side. Signed-off-by: Charles Keepax --- sound/core/compress_offload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index c7d56cee0d510..9fcd06395a046 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -824,7 +824,10 @@ static int snd_compr_drain(struct snd_compr_stream *stream) case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_SETUP: case SNDRV_PCM_STATE_PREPARED: + case SNDRV_PCM_STATE_PAUSED: return -EPERM; + case SNDRV_PCM_STATE_XRUN: + return -EPIPE; default: break; } @@ -877,7 +880,10 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_SETUP: case SNDRV_PCM_STATE_PREPARED: + case SNDRV_PCM_STATE_PAUSED: return -EPERM; + case SNDRV_PCM_STATE_XRUN: + return -EPIPE; default: break; }