From nobody Fri Oct 24 20:32:38 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88FD8C00140 for ; Mon, 15 Aug 2022 22:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349738AbiHOWfP (ORCPT ); Mon, 15 Aug 2022 18:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351078AbiHOW1e (ORCPT ); Mon, 15 Aug 2022 18:27:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D817641D39; Mon, 15 Aug 2022 12:47:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94CBAB80EB2; Mon, 15 Aug 2022 19:47:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C38A5C433D7; Mon, 15 Aug 2022 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592823; bh=ZcY8ootTVmsrvVa0ppEC/BOYMKO/1AIrNuHec3gCNc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XF89TOx+3yg9qB3iOyReuI2VvefZxYKntM3o2qbiFriR4j1uL3d95qib0JN9lR7z9 IGsNPmA1/qZDwP5BMe/VggLQSiA/ViccbHPxBUWfDvWvdHia5WgNfnk+Dx/X36DWae 0oVKCIkoEsxXk56EnIiWfdPS2DlLjXrTPjbmk1Iw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Srinivas Kandagatla , Mark Brown , Sasha Levin Subject: [PATCH 5.18 0850/1095] ASoC: codecs: wsa881x: handle timeouts in resume path Date: Mon, 15 Aug 2022 20:04:09 +0200 Message-Id: <20220815180504.497172715@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla [ Upstream commit cf6af24b54903f9f70c29b3e5b19cb72cc862d60 ] Currently we do not check if SoundWire slave initialization timeout expired before continuing to access its registers. Its possible that the registers are not accessible if timeout is expired. Handle this by returning timeout in resume path. Reported-by: Pierre-Louis Bossart Fixes: 8dd552458361 ("ASoC: codecs: wsa881x: add runtime pm support") Signed-off-by: Srinivas Kandagatla Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20220630130023.9308-1-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wsa881x.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c index 616b26c70c3b..649c7e73f774 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -1174,11 +1174,17 @@ static int __maybe_unused wsa881x_runtime_resume(st= ruct device *dev) struct sdw_slave *slave =3D dev_to_sdw_dev(dev); struct regmap *regmap =3D dev_get_regmap(dev, NULL); struct wsa881x_priv *wsa881x =3D dev_get_drvdata(dev); + unsigned long time; =20 gpiod_direction_output(wsa881x->sd_n, 1); =20 - wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(WSA881X_PROBE_TIMEOUT)); + time =3D wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(WSA881X_PROBE_TIMEOUT)); + if (!time) { + dev_err(dev, "Initialization not complete, timed out\n"); + gpiod_direction_output(wsa881x->sd_n, 0); + return -ETIMEDOUT; + } =20 regcache_cache_only(regmap, false); regcache_sync(regmap); --=20 2.35.1