Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28976172rwd; Wed, 5 Jul 2023 05:37:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlEafkA7ceWrQuK1+f6YOsmuUDHyri6kRjI+BoE1aI13JroYNkZpqnqU2OOy1w+vWdEIM7Dr X-Received: by 2002:a17:902:d2cd:b0:1b0:6e16:b92c with SMTP id n13-20020a170902d2cd00b001b06e16b92cmr19651901plc.54.1688560666978; Wed, 05 Jul 2023 05:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688560666; cv=none; d=google.com; s=arc-20160816; b=jSNX3pF5Iz2XsjzbvHEiigs4d7ArPpfn1GPQCiKRUyFvd+fgRHp0Ehs+G5LOchMa1P /nw2U8Z93/2RYYgh4cCND96O2UHV2S2Qneci7pIHhtvw0sBxSbtUxrVOgjOWKKW52fag 2Y8lCxYt7tL9pYsaPBlI1TmCIUkoc80BYwGL3TjH468CevzvrRi1EUWJy35y4jFqeIJe 8ZY53laUR7HcTN6ncMPtgHcr3E12eKBgF15LB3t5BBoihgu5XbGK1Ym4XDrJYqGwM9GV T6ehABnjWg8jd6lRlCF2PI11I9vgnDD8w+1KaYndZ+tgoteb1iAHCH+L0C7gJlxMBvfK XyvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bdJ8hhf6z0Z/eVDJQmE84pQOCGD6VxAmLPnIikKV8og=; fh=Izbxx5vYRCH48EunBM3t8Q/KIyf8hSWF2WSSYO5d+r4=; b=ilS2oDsZApJtTCnO6ITfhScH3sgMBCRXoJisFhYLuJCuasQz8YrmE3eNSUVQtvhDW9 IKJazD4QXLqWtMBVwxq8/dOJXkTY+rjH/R3SqkckI5pOnkZhNJz8spmDOgy/As1H9/9n 5dfSyqT/VF4csHakYeGm868TCfGC7IhszB/DWmoYkFxKxpWd012yukQNnhdjvv1p/KEh teqrWIU1L3YbDltBprsvKL4eM7zpZt7eyb+fe96nSpZCNhejG0Fb6Wl+V6YWIWLnElx4 FRd27kdZiydJe1ixFjGJRe81goJlrFcvvTyNxgb2rAGX4+WmFbyNmr98KkLvm2wI5Ahc X7VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m+8kTaSA; 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 x18-20020a17090300d200b001b89b64c0a4si5399634plc.148.2023.07.05.05.37.33; Wed, 05 Jul 2023 05:37:46 -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=m+8kTaSA; 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 S231868AbjGEMdU (ORCPT + 99 others); Wed, 5 Jul 2023 08:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbjGEMdM (ORCPT ); Wed, 5 Jul 2023 08:33:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7EA119 for ; Wed, 5 Jul 2023 05:33:10 -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 2EB396155B for ; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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(-) -- 2.39.3