Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2967752ybt; Mon, 29 Jun 2020 11:42:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7RlIJ1l4fY5VCT8Xaa47FL57wyTQ4F188hGKanIs1qS86wFSu1JGhiuxlrchZpb33xkSs X-Received: by 2002:a17:906:b813:: with SMTP id dv19mr14808702ejb.119.1593456140497; Mon, 29 Jun 2020 11:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593456140; cv=none; d=google.com; s=arc-20160816; b=dGJNU7Fp5YbY2cu9rnwaXb34D/RJUfbI1H0QHrynaeB0vuxXec/+eLHg3ETdMAM9Q1 TSJ5DZE8hIrYFc5O7kYNC3+lvTXBq/1tUrEMSzxAl/HmnfsxRgd22oY4yWUWmv+5HpHh zILAdhDpjsshYds1iTlB4lsBVJLkGjopTrGNiyhQ9etbLuHMlK0P9dwRgrVS6gyGEPUA U7CK+dxxteFPe0rInOp1vJlOnDExSbqYC8v0cacNvWDB0XembJAbM/RoWPTWHoe2F1sy 52J9IMD5oEBbf+U9yXyfz4kt4J2JAZvR+N6Ii6vMWVWPE6B1RMLhU1f0JuqjD6OHIvxf v+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nvQ+RhtXWl3jUaTSeL3C6NOiSPTnBe/FjJ7qQw/VhRY=; b=Udh6Lr+dEnZm57kqjs3sa0xZgExqgoUApsKpX9DVD0Hn5kNyobCSJCou7vrl1rIL/I qsKH3TEZ50IfDzotu+UoL6rWKVSg3aoxZepj+hSN2iQFvaUHfzqH+h85/XjsRsPcl2CU 0YhgGmaqZ1qTLCRzJr9YeugBdcniutaB0VrlaTIAad+SyGRbh25I5hGuSO1rPreWnb+X 9B44tZfPaIkwdCyiZ4PZe8T07UBznsVnVpgZmAcTLR1YlIDqwv5rgSeCy9jVe+DHSqWY uNoLZrXzHCchIk7YQNyGogcZeoStAtbnAidhLPD8qNLx/EIyDcFHBw3wTBbz6UCoJomx k7pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="i5YR6pw/"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si266933eja.702.2020.06.29.11.41.56; Mon, 29 Jun 2020 11:42: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=@kernel.org header.s=default header.b="i5YR6pw/"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgF2SlN (ORCPT + 99 others); Mon, 29 Jun 2020 14:41:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:60668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728698AbgF2SlH (ORCPT ); Mon, 29 Jun 2020 14:41:07 -0400 Received: from localhost (unknown [122.182.251.219]) (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 3D53423125; Mon, 29 Jun 2020 05:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593407824; bh=crmtCeTm/UluhEluBQPykauUvFRi/Z9kzPRAWcvYg0k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i5YR6pw/aFV2iOyU/9vkfAejtQ2CzfxmUzysh7DBmuU5k6mThFvvnOO3/Y85M8IJN gKHLvO4LX3X6YXz+O5+Jhj6+78ejPHVSmLwVUt+KgCUsBjEjnlYYtRBU1mymTpk1/z VaXloID+owO3dQOa4GY9oSltJigVxf44g4Sp0H9s= Date: Mon, 29 Jun 2020 10:46:59 +0530 From: Vinod Koul To: Charles Keepax Cc: Takashi Iwai , Jaroslav Kysela , Srinivas Kandagatla , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] ALSA: compress: fix partial_drain completion state Message-ID: <20200629051659.GB376808@vkoul-mobl> References: <20200625154651.99758-1-vkoul@kernel.org> <20200625154651.99758-4-vkoul@kernel.org> <20200626103549.GB71940@ediswmail.ad.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200626103549.GB71940@ediswmail.ad.cirrus.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26-06-20, 10:35, Charles Keepax wrote: > > - 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, right somehow my testing missed this, have verified that it is the case. I will remove the locks here, and we should add a comment to note this.. Thanks -- ~Vinod