From patchwork Sat Jul 1 09:47:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13299726 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 2CF2BEB64DC for ; Mon, 3 Jul 2023 08:35:30 +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 34D7DDE5; Mon, 3 Jul 2023 10:34:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 34D7DDE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1688373328; bh=NkKxEelQYImgUCH/jAULU1m4zxje/sLNSE+HtnnRpXY=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=eSOHCJtwoDO9pk9CtDkrWp/C6uJQne9DfIcAqIXf/BISB0JxvQpqFxycxDywDjBwp m2T/KR7CV7sy5QVDTOxtYd8wLHNWTmGA4Xa2qNJGes0PWb4CST4F28ESXSQN2EY5vG VY6werUVoCK/2JqLLVzMQZlxrNsUfniSLYdpUhmQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 39480F805CA; Mon, 3 Jul 2023 10:32:51 +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 AE979F805C3; Mon, 3 Jul 2023 10:32:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 331A3F80246; Sat, 1 Jul 2023 11:48:29 +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 5A277F80124 for ; Sat, 1 Jul 2023 11:48:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5A277F80124 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=arndB2iL 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 BC32860AE2; 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 ) id 1qFXDN-0007eM-Lo; Sat, 01 Jul 2023 11:48:25 +0200 From: Johan Hovold To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Srinivas Kandagatla , Steev Klimaszewski 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 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: ENQ6RDZ6J6W2MF3KCKXOPS6DQPUM74RH X-Message-ID-Hash: ENQ6RDZ6J6W2MF3KCKXOPS6DQPUM74RH X-Mailman-Approved-At: Mon, 03 Jul 2023 08:32:48 +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: 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 Reported-by: Steev Klimaszewski Signed-off-by: Johan Hovold --- 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);