Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp504400ybt; Fri, 26 Jun 2020 04:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDTss2vBvnK4gGGkYi6Z7H3gpap6LtUkG/tex/ttbM4vRr6OZOWSxhCHnQB+Mwj7wBJBdP X-Received: by 2002:a17:906:1b1a:: with SMTP id o26mr2167027ejg.176.1593172700122; Fri, 26 Jun 2020 04:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593172700; cv=none; d=google.com; s=arc-20160816; b=DNzMYjfx7VusbZqGt9cX3ywBhfE/lMGgTIga7MxnsBwtoXc8tNe+aRxnIPKDdjQDDI hz0VCDdv52Sj/NBLQ59IHx6RQFtfYEx5bcoKsgFf+ctR3CfVVmR/7P7j2ykbq3dxHGsW TAwCeE9OX3SvmQEZhaeeLy38USWm78HrmMB1AtI5OZZRmpinUR9howEGuMtxvmVuDAAL g+igNrJJE2tDhABECkGGKjMcOPv6nU3alLzyI7RugYoBiz0QPeMnnyUpGuoieWcR1BNC dByFRfVERPQVSXn1GtSdpRDt41lFNq4zQuCx3wjaoCsAxaxRB2HszfICYoRLJ0zotzez wrgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JpR8L4CQUgN3gWJ+RaStLce3t5Jm419G1nKBeC1oJcI=; b=CCHkAxm90MPGWp9DJ0GA0BQIcSwuGGYKDg5FzgEO3v0DMCLLTBDEuKeYfYdAVs4X1Q pC8KaBkRTUF1ZrDbWXdEJebqukso19mk13FZlfWjyFCV2QnV7ZZDD8d2gtUabeD9E/r6 Awqb9Ky8qfFEmBUJ0nJIoatqwPyzeLRoSKlh4QZ1lEkstNliew1w3YPh6OTAUSWPe8Z/ isqWY70+z8QEtoExjB1KWS5+Ds9v1yb//xlk2au6Us6BJN+YxENZQOp2X1qxcv/Cob3p wMwwCPBxb/8NEaUEwfJBtoAZAYRapvQcm+n8MOodIAizCzqGrEd0vM5Tm14d/hICQ+qt FuDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=LYdiuUMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si9300684ejq.20.2020.06.26.04.57.56; Fri, 26 Jun 2020 04:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=LYdiuUMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgFZKgo (ORCPT + 99 others); Fri, 26 Jun 2020 06:36:44 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:40100 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725601AbgFZKgo (ORCPT ); Fri, 26 Jun 2020 06:36:44 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05QAYSJM000369; Fri, 26 Jun 2020 05:35:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=JpR8L4CQUgN3gWJ+RaStLce3t5Jm419G1nKBeC1oJcI=; b=LYdiuUMrfDaOxrq9RFIavsXd8d3eBK5U5J1GMoRbtPaXUpNddjU9FiIIRBrttJTfgYza K+cHaJmDpDfJg4s2hadfw9LJF5NBa2Y/6MD2zoB2eJdeWCJD4/CjdsNhNthGQWvzyogV r/6U11E0AMnXJ7qOvaZBPTedTUICu4Wo+YwASh3lvsrJFoPKsx/94+/WGy69jMyVr3xZ XHPB0qmAMkNahGh8uFIYYGTNw8NSJLYa4lUthPkW7X0RhwZ5h/5VGfFOwae9vjvwnbC/ 9tHzZFCziFu26nQD5ERgs0z95Kb+UQMA56J5A3b6nU0dkQrnlam7rAxP6Zj76Xb5fR2e FA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 31uus3c3ww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 26 Jun 2020 05:35:51 -0500 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.1913.5; Fri, 26 Jun 2020 11:35:49 +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.1913.5 via Frontend Transport; Fri, 26 Jun 2020 11:35:49 +0100 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 0D54C2C5; Fri, 26 Jun 2020 10:35:49 +0000 (UTC) Date: Fri, 26 Jun 2020 10:35:49 +0000 From: Charles Keepax To: Vinod Koul CC: Takashi Iwai , Jaroslav Kysela , Srinivas Kandagatla , Pierre-Louis Bossart , , Subject: Re: [PATCH v3 3/3] ALSA: compress: fix partial_drain completion state Message-ID: <20200626103549.GB71940@ediswmail.ad.cirrus.com> References: <20200625154651.99758-1-vkoul@kernel.org> <20200625154651.99758-4-vkoul@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200625154651.99758-4-vkoul@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com ip4:5.172.152.52 -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 cotscore=-2147483648 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006260077 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 09:16:51PM +0530, Vinod Koul wrote: > On partial_drain completion we should be in SNDRV_PCM_STATE_RUNNING > state, so set that for partially draining streams in > snd_compr_drain_notify() and use a flag for partially draining streams > > While at it, add locks for stream state change in > snd_compr_drain_notify() as well. > > Fixes: f44f2a5417b2 ("ALSA: compress: fix drain calls blocking other compress functions (v6)") > Reviewed-by: Srinivas Kandagatla > Tested-by: Srinivas Kandagatla > Signed-off-by: Vinod Koul > --- > @@ -187,7 +189,15 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) > if (snd_BUG_ON(!stream)) > return; > > - stream->runtime->state = SNDRV_PCM_STATE_SETUP; > + mutex_lock(&stream->device->lock); > + /* for partial_drain case we are back to running state on success */ > + if (stream->partial_drain) { > + stream->runtime->state = SNDRV_PCM_STATE_RUNNING; > + stream->partial_drain = false; /* clear this flag as well */ > + } else { > + stream->runtime->state = SNDRV_PCM_STATE_SETUP; > + } > + mutex_unlock(&stream->device->lock); You have added locking here in snd_compr_drain_notify but.... > > wake_up(&stream->runtime->sleep); > } > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index e618580feac4..1c4b2cf450a0 100644 > --- a/sound/core/compress_offload.c > +++ b/sound/core/compress_offload.c > @@ -803,6 +803,9 @@ static int snd_compr_stop(struct snd_compr_stream *stream) > > retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); > if (!retval) { > + /* clear flags and stop any drain wait */ > + stream->partial_drain = false; > + stream->metadata_set = false; > snd_compr_drain_notify(stream); that can be called from snd_compr_stop here which is already holding the lock resulting in deadlock. Thanks, Charles