From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D62B2C433EF for ; Fri, 8 Oct 2021 15:42:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EED6C6101A for ; Fri, 8 Oct 2021 15:42:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EED6C6101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 A15331688; Fri, 8 Oct 2021 17:41:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A15331688 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633707760; bh=GcQ7HFBYxIxzKkM+TAEzYmdP//8hEzY+IwiM1otm21M=; h=Subject:To:References:From:Date:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TLcCz/solaGnMXfYwWFtNQL3IyOrL3xvYHqC+erBtB5WK0LSIqSf1HTRsSWgCPpFo AtBYG0aVz3zPA3WCLtln0uI0ObrJDlhlPeZdmuubVdCNFC0U8ZTiq3AoPPqk8wZ3vk 3yRUvJ9Do0+WGwbPQYHeTh5I2HGALSrdnD55lRlw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F57EF80240; Fri, 8 Oct 2021 17:41:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41F12F80124; Fri, 8 Oct 2021 17:41:48 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 9BA10F800F0 for ; Fri, 8 Oct 2021 17:41:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9BA10F800F0 X-IronPort-AV: E=McAfee;i="6200,9189,10131"; a="287413296" X-IronPort-AV: E=Sophos;i="5.85,358,1624345200"; d="scan'208";a="287413296" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 08:41:41 -0700 X-IronPort-AV: E=Sophos;i="5.85,358,1624345200"; d="scan'208";a="440680849" Received: from vgopala1-mobl.amr.corp.intel.com (HELO [10.212.34.202]) ([10.212.34.202]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 08:41:40 -0700 Subject: Re: [RFC PATCH v2 0/5] ASoC: soc-pcm: fix trigger race conditions with shared BE To: Takashi Iwai References: <20211004225441.233375-1-pierre-louis.bossart@linux.intel.com> <1efa1c31-7342-05f8-5f73-95e2462d4179@linux.intel.com> <3683cf39-632b-50df-c65d-63779c464850@nvidia.com> <11257d77-9975-3b00-94da-5dc1b5c95fc6@linux.intel.com> <80882fe6-ea30-43f6-8d83-8995dd28c748@linux.intel.com> <60c6a90b-290d-368c-ce61-4d86e70eaa78@linux.intel.com> <75894aba-ca1a-51d6-df7d-ad53fcd89f79@linux.intel.com> From: Pierre-Louis Bossart Message-ID: Date: Fri, 8 Oct 2021 10:41:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Cc: alsa-devel@alsa-project.org, Kuninori Morimoto , Sameer Pujar , vkoul@kernel.org, broonie@kernel.org, Gyeongtaek Lee , Peter Ujfalusi 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" >> dpcm_be_disconnect already uses a spin_lock around >> >> list_del(&dpcm->list_be); >> list_del(&dpcm->list_fe); >> >> and in some other places, are you suggesting we change those to the FE lock? > > Basically yes. > >> Otherwise, I understood your proposal as using three locks (existing >> spinlock, FE lock, BE lock) to deal with DPCM. If the existing spinlock >> and FE lock are combined, we'd still have two locks. > > Stream locks are more fine-grained, hence more efficient :) > The card-level spinlock is superfluous and it can go away. > >> I was suggesting we use only one ;-) > > Basically we need to protect two things: > - The BE links > - The concurrent accesses to BEs > The former belongs to each FE that holds the links, and the FE stream > lock would cover. The latter is rather a per-BE business. > > An oft-seen risk of multiple locks is deadlocking, but in this case, > as long as we keep the lock order FE->BE, nothing wrong can happen. famous last words "nothing wrong can happen." :-) I already added a helper to do this FE lock, I can easily replace the implementation to remove the spin_lock and use the FE PCM lock. we might even add the lock in the definition of for_each_dpcm_be() to avoid misses. Let me try this out today, thanks for the suggestions.