Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29137552rwd; Wed, 5 Jul 2023 07:42:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGEJT4ISi/ihuaQ7geeH/9OQPUnGYufiChyUAzgYaJLQCC+Cot/+yllc5S3G4ww5C/Tuq1o X-Received: by 2002:a05:6a00:854:b0:681:50fd:2b93 with SMTP id q20-20020a056a00085400b0068150fd2b93mr23999432pfk.25.1688568168654; Wed, 05 Jul 2023 07:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688568168; cv=none; d=google.com; s=arc-20160816; b=AbJi1rOm/UsHPNd30jJEY/UenzHV7ElmJp0Q2KBclqtp5USiKQlF+95PSvf6NQyQOq mV2z/XbehD7d64PJ+bfqEZuJq4nKzE7mTeITU6llhC6eFJ3WDQ+PjWqp0dQYfAtKD4gK r4q7SJR5Zzp7Vu0llG/V52Pnddwc718tO2voCFca/nZ1WW0+mXHnSGE247+rmI2TS1NO AhaRK65UeQ/ozcvdKMuAWqngOifxRaF2wyfar6E5grsnRovZ+9RUn5UZctdxaMCz6p9J D0lr98R2QFRmCCiGFDzbkqTRqyvXRPXgJGuJH3Mfh/Ahv8a0vIV07e9UA8tZwJ2KQAbK MnBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LMS3oJc732XR5fCaL0hDWWgOaK+2caBpCCeB4NLs74o=; fh=94lb5/HkD/+xUSE5dRlB7dynnfswPfkoPFNOt76Lj7Y=; b=d/vKXpBPnaE5PaDUbQWJnrNBaluzxZze9iGMaY/F9ooKzTAuqJnwQ49U8Q72+VKeN5 7kilU2gSFWsnLKd5/fX/bqRpSXm6teElCOXXtWw3Bl0UvE/ZDBIxl+4DyIYFsExWTp9y JmlLAU8Wivhui5mKqI/syVPUNhaOG322qkAbeOPsIKdg/9npCF/rDj91+CAaCeEyfcSL M34dorpjgVwMrIyGePuadHoGeJy911iK8A8c9B5UlLi8S+nX7yA36ny398DjwlKRx6KT CfoRiw0EuhliI1+5Mj8x58A3jqXlZZPT/xlkyLvgemyGn8ICQOMSxA3zoi+0TbyhjqSO /mEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tHyEobZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w29-20020a63161d000000b0053f23442f24si23543235pgl.502.2023.07.05.07.42.35; Wed, 05 Jul 2023 07:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tHyEobZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232051AbjGEOak (ORCPT + 99 others); Wed, 5 Jul 2023 10:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231984AbjGEOaj (ORCPT ); Wed, 5 Jul 2023 10:30:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58330CF; Wed, 5 Jul 2023 07:30:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E8E5861578; Wed, 5 Jul 2023 14:30:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 530FCC433C7; Wed, 5 Jul 2023 14:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688567437; bh=mioA+NwZpkg7KB16O0oCsl2L7Ti3kUkbc08ZUpiE4dQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tHyEobZ4yZ6Rf5P4cpd7HdExbDFfbfwjSd9AOkAamID+KUpZLK3UX1Ssiu3WEZob9 k/S/wpYG3g5A+k/Zd9q4qO9qNtok2xT0r1VnWKJ8ffAo5OtFxZBdnxjW8HqTlznM2k dy6Ih2YDHHoWWcJeC74ZCp68RRIXR969V9jXPKOOTAwZevqQlW8Jfa21AJxEKzD6Ie I9kSC7ozj89z0APRO985AwxivYx5Jejt3rEuv87AeietuvgV7417+qJkqGMp8AgF8q CBK/6Ksld10CgpxWIHyvxj/5lgIZHaWqVBIAjZV9MzAqTPgYowu7FKAEnBTwJ6jQ1F YgNkRGtArbf7A== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qH3Wz-0000g3-1S; Wed, 05 Jul 2023 16:30:58 +0200 Date: Wed, 5 Jul 2023 16:30:57 +0200 From: Johan Hovold To: Pierre-Louis Bossart Cc: Johan Hovold , Mark Brown , Vinod Koul , Bard Liao , Sanyog Kale , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Rander Wang Subject: Re: [PATCH 1/8] soundwire: fix enumeration completion Message-ID: References: <20230705123018.30903-1-johan+linaro@kernel.org> <20230705123018.30903-2-johan+linaro@kernel.org> <907ad7a3-3384-c0c4-90a9-5beab4cc45e0@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <907ad7a3-3384-c0c4-90a9-5beab4cc45e0@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 05, 2023 at 02:53:17PM +0200, Pierre-Louis Bossart wrote: > On 7/5/23 14:30, Johan Hovold wrote: > > The soundwire subsystem uses two completion structures that allow > > drivers to wait for soundwire device to become enumerated on the bus and > > initialised by their drivers, respectively. > > > > The code implementing the signalling is currently broken as it does not > > signal all current and future waiters and also uses the wrong > > reinitialisation function, which can potentially lead to memory > > corruption if there are still waiters on the queue. > > That change sounds good, but I am not following the two paragraphs below. > > > Not signalling future waiters specifically breaks sound card probe > > deferrals as codec drivers can not tell that the soundwire device is > > already attached when being reprobed. > > What makes you say that? There is a test in the probe and the codec > driver will absolutely be notified, see bus_type.c > > if (drv->ops && drv->ops->update_status) { > ret = drv->ops->update_status(slave, slave->status); > if (ret < 0) > dev_warn(dev, "%s: update_status failed with status %d\n", __func__, > ret); > } I'm talking about signalling the codec driver using the soundwire device via the completion structs. Unless the underling device is detached and reattached, trying to wait for completion a second time will currently timeout instead of returning immediately. This affects codecs like rt5682, which wait for completion in component probe (see rt5682_probe()). > > Some codec runtime PM > > implementations suffer from similar problems as waiting for enumeration > > during resume can also timeout despite the device already having been > > enumerated. > > I am not following this either. Are you saying the wait_for_completion() > times out because of the init_completion/reinit_completion confusion, or > something else. It times out because the completion counter is not saturated unless you use complete_all(). Drivers that wait unconditionally in resume, will time out the second time they are runtime resumed unless the underlying device has been detached and reattached in the meantime (e.g. wsa881x_runtime_resume()). Johan