From patchwork Wed Jul 5 12:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 700084 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C0106EB64DA for ; Wed, 5 Jul 2023 14:44:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B3887845; Wed, 5 Jul 2023 16:43:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B3887845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1688568251; bh=MrLDHbklUKpi6qXlkICOurQQLrWotMYZG6zKJgQAjAY=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=r+TFY6pJ6zkId72vCIoru69g+/UmY9xNIF6TWEYqsTls06IUUh12BkWa6xQovxAir wLggLPs1uk+f4DJq3jqx5MfXRhMi/xPG3/DqhgJpC35W6XDT+WrycxJPBFB4ZLkCHq 2JZo3hQkt7VMvGcszyZUc3asaS40SCaVNVNNyExE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B9D55F8058C; Wed, 5 Jul 2023 16:41:49 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 28AA2F8058C; Wed, 5 Jul 2023 16:41:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1743AF80125; Wed, 5 Jul 2023 14:35:12 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DC10AF80153 for ; Wed, 5 Jul 2023 14:33:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DC10AF80153 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=m+8kTaSA 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 1CA0F61510; Wed, 5 Jul 2023 12:33:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F125C433C9; Wed, 5 Jul 2023 12:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688560389; bh=MrLDHbklUKpi6qXlkICOurQQLrWotMYZG6zKJgQAjAY=; h=From:To:Cc:Subject:Date:From; b=m+8kTaSAKikKHrGf9TO3qYgpRMU149MjjocmjN6KKUPV8qFkr5/0Cv7qcumfx3Zsq fhOoBHzADQCEjcoN7P2rQcBbA2RfYUFchFgYcEDjrQdoGaRpluo0tgpsbNX0EKF4W1 oOhpnwmNsskUGHLolkrqjHovCh+WQobWCDMP7CxW0EduDR08SRkKsZ7z8PxIUJqvae ZjG2Q0h9sIY0v1Hdcng2TMzeexs4e2RWKWPgTnPuDa5Ykm1TrzeNIbsJTpe8SJEYur gWdybdcNAKI9ULO9sjYB0fOUHCgtQ2I1UdgzQxf/FBzzvg0x02OSK/w+edNm3HeSZh ahFg3YJg42uKQ== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qH1hK-000846-03; Wed, 05 Jul 2023 14:33:30 +0200 From: Johan Hovold To: Mark Brown , Vinod Koul Cc: Bard Liao , Pierre-Louis Bossart , Sanyog Kale , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral Date: Wed, 5 Jul 2023 14:30:10 +0200 Message-Id: <20230705123018.30903-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-MailFrom: johan+linaro@kernel.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: MP5VFKVK6445GKN33NX6E6YQ7RPKDIL2 X-Message-ID-Hash: MP5VFKVK6445GKN33NX6E6YQ7RPKDIL2 X-Mailman-Approved-At: Wed, 05 Jul 2023 14:41:38 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I've been hitting a race during boot which breaks probe of the sound card on the Lenovo ThinkPad X13s as I've previously reported here: https://lore.kernel.org/all/ZIHMMFtuDtvdpFAZ@hovoldconsulting.com/ The immediate issue appeared to be a probe deferral that was turned into a hard failure, but addressing that in itself only made things worse as it exposed further bugs. I was hoping someone more familiar with the code in question would look into this, but as this affects users of the X13s and breaks audio on my machine every fifth boot or so, I decided to investigate it myself. As expected, the Qualcomm codec drivers are broken and specifically leak resources on component remove, which in turn breaks sound card probe deferrals. The source of the deferral itself appears to be legitimate and was simply due to some audio component not yet having been registered due to random changes in timing during boot. These issues can most easily be reproduced by simply blacklisting the q6apm_dai module and loading it manually after boot. The sound card probe deferral also exposes a bug in the soundwire subsystem, which uses completion structures for signalling that a device has been enumerated on the bus and initialised. The way this is implemented prevents reprobed codec drivers from learning that the soundwire devices are still attached, which causes probe to fail. Included are also two patches that suppresses error messages on component probe deferral to avoid spamming the logs during boot. These patches should preferably all go through the ASoC tree even if merging the soundwire fix separately also works. Note the ASoC tree already has the following related fixes: https://lore.kernel.org/lkml/20230630120318.6571-1-johan+linaro@kernel.org/ https://lore.kernel.org/lkml/20230630142717.5314-1-johan+linaro@kernel.org/ https://lore.kernel.org/lkml/20230701094723.29379-1-johan+linaro@kernel.org/ https://lore.kernel.org/lkml/20230703124701.11734-1-johan+linaro@kernel.org/ Johan Johan Hovold (8): soundwire: fix enumeration completion ASoC: qdsp6: audioreach: fix topology probe deferral ASoC: codecs: wcd938x: fix missing clsh ctrl error handling ASoC: codecs: wcd938x: fix resource leaks on component remove ASoC: codecs: wcd934x: fix resource leaks on component remove ASoC: codecs: wcd-mbhc-v2: fix resource leaks on component remove ASoC: topology: suppress probe deferral errors ASoC: core: suppress probe deferral errors drivers/soundwire/bus.c | 8 ++--- sound/soc/codecs/wcd-mbhc-v2.c | 57 ++++++++++++++++++++++--------- sound/soc/codecs/wcd934x.c | 12 +++++++ sound/soc/codecs/wcd938x.c | 59 +++++++++++++++++++++++++++++---- sound/soc/qcom/qdsp6/topology.c | 4 +-- sound/soc/soc-core.c | 6 ++-- sound/soc/soc-topology.c | 10 ++++-- 7 files changed, 122 insertions(+), 34 deletions(-)