Message ID | 20230701094723.29379-1-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10949240vqr; Sat, 1 Jul 2023 03:28:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mSA3mu9AxFk2SGdOVuMwcNRHcFzpKIZ3zlT6JUYUxiDKqa/5rozyswIqjGPzBA8z2W2JG X-Received: by 2002:a05:6870:6c18:b0:187:bd00:d63c with SMTP id na24-20020a0568706c1800b00187bd00d63cmr5971282oab.28.1688207314608; Sat, 01 Jul 2023 03:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688207314; cv=none; d=google.com; s=arc-20160816; b=RL1Qt7TWzQehnankNxe6ZRUMXsgbRGVQ6wJrxI8joOGhR92ezbVrWcKpHkibWnbUaO R+RebmTmy7sB/FlKNXefxkjjsyGTsDlOdEYaLL86FZWHyOijT3nP0al9+m24F7OZqpah F7jTWrMUk9PfSrLGWXvpsWkJOfUN2GAos2IePdni/L1q2io0RFZ7lbKWfzYSv8ycz1tl G3Z2QlG9/WOR17jO0/moD8qAz+6fkO6kYjbzQPMLIGE7gqIsDL8iWlTIFKtRJjv86/Rn NDlbiKT52M2EVR/XmrDUZALI5lfyllZz0ZVPDBAXQiHYzE21bmasLG2o9x3rDYSt8uW8 ZcYQ== 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=2JSEcoR8Ffv0STa240kI0qHcknxhrQ47VGcTFwzC93c=; fh=WKr6jFqwYbxMMFmOaFt4XnPL3YIMcXCo24uZCmlE7Pc=; b=KnnT1lkeiS9Mz22VavJ9NFNxHuEEks5AFDT5EEiuDpv4A8y3OXZzWhCN5SKGHTEK3a 1zuLLVE+CX10h9+bwfNZDKQpqijSADskOPJvxsr47WuhEArEuH+qvicdomFMjyv6HykD VvaXDJ9Z+XQG/O/Pcw6a4LdX125Z5exp0rqQq4xlecHztmWc8CrI6yKUXYHjusK49g7Z KU6Ve74n/j8PZe8bD5mbzJmLIc9Pnfn9loAbo7oJt0fqmmxWCTDnv7VEBBUrd9xRLs9j Srd8x0pBU1FFi81eyJAQvZwCRGQ7AbSPajM6oiG27/BnQjtNVfxIwmq2F88g+yTqayhR SouA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=arndB2iL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a63e603000000b0054ff425ab2csi13656063pgh.234.2023.07.01.03.28.19; Sat, 01 Jul 2023 03:28:34 -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=arndB2iL; 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 S229787AbjGAJsV (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Sat, 1 Jul 2023 05:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjGAJsT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 1 Jul 2023 05:48:19 -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 95E981FE7; Sat, 1 Jul 2023 02:48:18 -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 B8A9C60A57; Sat, 1 Jul 2023 09:48:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21377C433C7; Sat, 1 Jul 2023 09:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688204897; bh=NkKxEelQYImgUCH/jAULU1m4zxje/sLNSE+HtnnRpXY=; h=From:To:Cc:Subject:Date:From; b=arndB2iLmMRvRpc3Y5iGkNQUBEEp/2aZS8DrjgQZDBAhPD8GmBezKeXAw4RYSMmJ+ L9v6h70XjzbT4GH0fTmi5zRAcvRpVQnCrdD3NcBJOPayzBwY+B2u4JPkg+NPlBKPJj V1AHyV25CERQ/pl8HU1oxRX+8xd49AtMsl+TDTq9leAUF0RibUj03Uv9cjlePemQCH jxfrh3gptWOi++lJ6//F6nkIkr5mcWGGtkVn5yIc+WLqGxCdEkeqBwQRqxOAAGl/rF XyBcYzcCUglWINtqWOTnrb3H0X7S0TYciVA/VhSLrU/opTtpb8xdqRf1TIH2fQSkRl J9wrW+fNXADiw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from <johan+linaro@kernel.org>) id 1qFXDN-0007eM-Lo; Sat, 01 Jul 2023 11:48:25 +0200 From: Johan Hovold <johan+linaro@kernel.org> To: Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, stable@vger.kernel.org, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Steev Klimaszewski <steev@kali.org> Subject: [PATCH] ASoC: codecs: wcd938x: fix soundwire initialisation race Date: Sat, 1 Jul 2023 11:47:23 +0200 Message-Id: <20230701094723.29379-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770213673304856965?= X-GMAIL-MSGID: =?utf-8?q?1770213673304856965?= |
Series |
ASoC: codecs: wcd938x: fix soundwire initialisation race
|
|
Commit Message
Johan Hovold
July 1, 2023, 9:47 a.m. UTC
Make sure that the soundwire device used for register accesses has been
enumerated and initialised before trying to read the codec variant
during component probe.
This specifically avoids interpreting (a masked and shifted) -EBUSY
errno as the variant:
wcd938x_codec audio-codec: ASoC: error at soc_component_read_no_lock on audio-codec for register: [0x000034b0] -16
in case the soundwire device has not yet been initialised, which in turn
prevents some headphone controls from being registered.
Fixes: 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reported-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
sound/soc/codecs/wcd938x.c | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On Sat, Jul 1, 2023 at 4:48 AM Johan Hovold <johan+linaro@kernel.org> wrote: > > Make sure that the soundwire device used for register accesses has been > enumerated and initialised before trying to read the codec variant > during component probe. > > This specifically avoids interpreting (a masked and shifted) -EBUSY > errno as the variant: > > wcd938x_codec audio-codec: ASoC: error at soc_component_read_no_lock on audio-codec for register: [0x000034b0] -16 > > in case the soundwire device has not yet been initialised, which in turn > prevents some headphone controls from being registered. > > Fixes: 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver") > Cc: stable@vger.kernel.org # 5.14 > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Reported-by: Steev Klimaszewski <steev@kali.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > --- > sound/soc/codecs/wcd938x.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c > index e3ae4fb2c4db..4571588fad62 100644 > --- a/sound/soc/codecs/wcd938x.c > +++ b/sound/soc/codecs/wcd938x.c > @@ -3080,9 +3080,18 @@ static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev) > static int wcd938x_soc_codec_probe(struct snd_soc_component *component) > { > struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); > + struct sdw_slave *tx_sdw_dev = wcd938x->tx_sdw_dev; > struct device *dev = component->dev; > + unsigned long time_left; > int ret, i; > > + time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete, > + msecs_to_jiffies(2000)); > + if (!time_left) { > + dev_err(dev, "soundwire device init timeout\n"); > + return -ETIMEDOUT; > + } > + > snd_soc_component_init_regmap(component, wcd938x->regmap); > > ret = pm_runtime_resume_and_get(dev); > -- > 2.39.3 > Thank you! Tested with this and the other patch applied on my X13s with a pair of Apple EarPods with 3.5mm Headphone Plug, audio is quite nice through them. Tested-by: Steev Klimaszewski <steev@kali.org>
On Sat, 01 Jul 2023 11:47:23 +0200, Johan Hovold wrote: > Make sure that the soundwire device used for register accesses has been > enumerated and initialised before trying to read the codec variant > during component probe. > > This specifically avoids interpreting (a masked and shifted) -EBUSY > errno as the variant: > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: codecs: wcd938x: fix soundwire initialisation race commit: 6f49256897083848ce9a59651f6b53fc80462397 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index e3ae4fb2c4db..4571588fad62 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -3080,9 +3080,18 @@ static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev) static int wcd938x_soc_codec_probe(struct snd_soc_component *component) { struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); + struct sdw_slave *tx_sdw_dev = wcd938x->tx_sdw_dev; struct device *dev = component->dev; + unsigned long time_left; int ret, i; + time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete, + msecs_to_jiffies(2000)); + if (!time_left) { + dev_err(dev, "soundwire device init timeout\n"); + return -ETIMEDOUT; + } + snd_soc_component_init_regmap(component, wcd938x->regmap); ret = pm_runtime_resume_and_get(dev);