From patchwork Thu Jun 30 13:00:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 586102 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 28E0BC43334 for ; Thu, 30 Jun 2022 13:01:29 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C35C120C; Thu, 30 Jun 2022 15:00:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C35C120C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1656594087; bh=M7FK/98M1MjZHDrciJgIdj/7vtKx2z9WNYWbwzUrqMw=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=kwSg9138hGybfiv7sVjXoNPWcR1EKGu6SubQDLrxhoboKaplFKsJ6RcEgOidR0ZIg EjFEuYmQ9f/XILv9b+Ck6RW8TNSb9uAlgGbDowKNkX+9Jz2R5ghIDmoxcqE8lYycJA VmA7y76ZnAR2X7giwo5hz81QzGQdXuY3koLCcseU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 565BAF804D2; Thu, 30 Jun 2022 15:00:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EF8B7F804DA; Thu, 30 Jun 2022 15:00:35 +0200 (CEST) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CDB79F80107 for ; Thu, 30 Jun 2022 15:00:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CDB79F80107 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="it46n3LR" Received: by mail-wm1-x32b.google.com with SMTP id l2-20020a05600c4f0200b0039c55c50482so1674538wmq.0 for ; Thu, 30 Jun 2022 06:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Nh7MOeHqpu+KJjz+AQfMOAMAr6taCyP+a8n4nKC3Ilk=; b=it46n3LRqtbFUNmtsO5pMTfu8XVzRaw4AkZn64FfFqiNM1TD6/fI7WCexAZ0kter1B 8V8OaDXmnLHFEVjmxaS1FdoZ/0Pf84G9bzIqI4QqQjedMkhnBmQBdU+PwdgSJrtv6ILa YojZAZPCS0q0Vzyef/v9d8v/StEujzRRvmdoxuC2JuWaNkyDRB8bjFaK+5U8690VKtQr A+dV+PdyNl/h0Za7ayvfNFEkp5xg/LIVabnTWn9hG40wAoh2NyJdEByXSjWVz2jTA68x 5s7wTsAYHACQpXHMeszYGlsMUuVIWWWm/MTFVxmXg0L7vTMs+K/LI3Fcoc+RyBlDDobT xHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Nh7MOeHqpu+KJjz+AQfMOAMAr6taCyP+a8n4nKC3Ilk=; b=Hf0l90YX4GHOhukE8wjkXaU4Kyedjs/ien15+TRhDb/kYJ+beNiqftJ5I9wFXG27uh YpSKINSFp9z1c+bOqPYP5E5dvov03IatN17NsmPY+x+WivXbLFPqWY7QgJnOLBXRy7WB fRBE6kOJiLtojz0LqeZTCqxzRA62+FGAUBSzF3EQ69BfgxCvtfDqmCAYI3lDSpB3v2MC dCQzHly3miPfpTy0SAeDFK0gsSuA+2ClJ2xYbLlAPonz2WtLarIalxHPE7q68LR069cl SiftdQXGzN5FlIp0z+6DfsMPTpol/2IQAeN52XkSKFH8X2F/3qvuzYOpxGknU47/pKqL eEVg== X-Gm-Message-State: AJIora+u5UL+aI3nxjCMm29Y9FU1WOhSqM3H+hiJSDtQB/asnYfyZ4Ct 4R1+SIOI94pl9n1t8oIKpTcvHQ== X-Google-Smtp-Source: AGRyM1vJ3ZxH45D8hUgK2tFT90WipVg22meqPE/QRLhl20LRmrNPtv60AoVVnzHUObi1UxrNlko/Gg== X-Received: by 2002:a05:600c:27d1:b0:3a1:7e0c:56bf with SMTP id l17-20020a05600c27d100b003a17e0c56bfmr3784642wmb.186.1656594026688; Thu, 30 Jun 2022 06:00:26 -0700 (PDT) Received: from srini-hackbase.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id o4-20020a5d6484000000b0020d02262664sm19273608wri.25.2022.06.30.06.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 06:00:25 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 1/2] ASoC: codecs: wsa881x: handle timeouts in resume path Date: Thu, 30 Jun 2022 14:00:22 +0100 Message-Id: <20220630130023.9308-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Cc: Pierre-Louis Bossart , alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, tiwai@suse.com, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 dc954b85a988..6c8b1db649b8 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -1173,11 +1173,17 @@ static int __maybe_unused wsa881x_runtime_resume(struct device *dev) struct sdw_slave *slave = dev_to_sdw_dev(dev); struct regmap *regmap = dev_get_regmap(dev, NULL); struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); + unsigned long time; gpiod_direction_output(wsa881x->sd_n, 1); - wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(WSA881X_PROBE_TIMEOUT)); + time = 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; + } regcache_cache_only(regmap, false); regcache_sync(regmap); From patchwork Thu Jun 30 13:00:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 586890 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 CA209C43334 for ; Thu, 30 Jun 2022 13:01:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A3B4016B5; Thu, 30 Jun 2022 15:01:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A3B4016B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1656594117; bh=ZG1ZNk494R1CUFcBKFQPHfnynDjXT13GbebSbFdb2WE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PTsWoABuozH2YxCAMO1cXhFlZtYAniJHWr9YrP1XlRElyFGIKHyKniMcnubqXksk6 lUhPsGd+ujwgkPut/TCAQgxPjo+ViEglvdtXvkMKzmd0Rbb48FI7GQOa0Rfdvrj0M1 xC5GDh4z2egDr/pPaxbwrRaaWRo6kIirPR3wJ/Zw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 09E14F804EB; Thu, 30 Jun 2022 15:00:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2453FF804D8; Thu, 30 Jun 2022 15:00:36 +0200 (CEST) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4D52F800F5 for ; Thu, 30 Jun 2022 15:00:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4D52F800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pd5SdccG" Received: by mail-wr1-x430.google.com with SMTP id cl1so3474864wrb.4 for ; Thu, 30 Jun 2022 06:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bzABi/fIb1/5+rkmhKsgJLpztE30/Fc5MNL46LXzMCc=; b=pd5SdccGVl8fDIHgsEq50W5KKB+B/zDoKkQ2eQ3o7PderfSIAUhs85dKlWE6ZnFsQq brEjiFes/oABy40kFwb6MHkYsUEtZnadZKYDg/XBOKOLgrDyERsV0YKD9yHJ+9DHj0D9 azzEfOiXYljcqCLAv9Pux2dt+9T9aVvPUff4z4WxNmy4nWFORochi7eWOZAn5fY1Yl9H XyPaP1hOK++tUU5RvL7zxlUeyzglAihehbJvmjku2RQIT/rEE3ZNzQVCogABOoQFsJt2 BGMbMwdDfGB3D4GLT8OMhr1zrKVp9cHVsn1qMV7SINf0uRZFfd1HVFEsm3H3GOUqiZVW mlzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bzABi/fIb1/5+rkmhKsgJLpztE30/Fc5MNL46LXzMCc=; b=jzivNSvXfkBguGvd7mq4IWEGCVDREEZCpPZt3CFu6tHsqHWocBkiAntOgFapGOFRDm h7bnB0O1j/D9Suz3Eenw/h8rFWoLcMm1u8q6G7agC3cic87KiLcmnduO2vMBQlNrqH80 sNMd+Vwp1zvS3N6wSYKA8T5AlHu6lvV0dzivz5DfHwh3vRQur6F1rTYJDNInOrUy953E XJ5q3Mn+1zAOh17j5bnUnd1hxq4sxZCgCGF30qyqy3R+fdbzqL9TXFK/n5BLxlRivFbg IlelO6jGsEBEGh9duMLXGazXgvjC1+YYBaE4PQLPsRnFP9+cBJ6KnOxF8ITeRGKb4oAO G8qg== X-Gm-Message-State: AJIora8tvRqb0cPYj14x0hCfOt5gna4ABReh1eBLXeJKn1IQL3RmPqbM AqkLo8+EzSjs1InwXrjqyv0Z/aO30D5mca4y X-Google-Smtp-Source: AGRyM1vENCHbsQi0PnAYac3E99zxWkQjJFZN5frPbYEF/+WF6yo+5/ej3mMLC1VDx4o9B+4Wt+NCuw== X-Received: by 2002:a5d:5967:0:b0:21b:903f:e095 with SMTP id e39-20020a5d5967000000b0021b903fe095mr8133140wri.162.1656594028050; Thu, 30 Jun 2022 06:00:28 -0700 (PDT) Received: from srini-hackbase.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id o4-20020a5d6484000000b0020d02262664sm19273608wri.25.2022.06.30.06.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 06:00:27 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 2/2] ASoC: codecs: wsa883x: handle timeouts in resume path Date: Thu, 30 Jun 2022 14:00:23 +0100 Message-Id: <20220630130023.9308-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220630130023.9308-1-srinivas.kandagatla@linaro.org> References: <20220630130023.9308-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: Pierre-Louis Bossart , alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, tiwai@suse.com, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wsa883x.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index e8f519e89213..40c7d64a9c41 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1455,6 +1455,7 @@ static int __maybe_unused wsa883x_runtime_resume(struct device *dev) struct sdw_slave *slave = dev_to_sdw_dev(dev); struct regmap *regmap = dev_get_regmap(dev, NULL); struct wsa883x_priv *wsa883x = dev_get_drvdata(dev); + unsigned long time; int ret; ret = regulator_enable(wsa883x->vdd); @@ -1465,8 +1466,14 @@ static int __maybe_unused wsa883x_runtime_resume(struct device *dev) gpiod_direction_output(wsa883x->sd_n, 1); - wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(WSA883X_PROBE_TIMEOUT)); + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(WSA883X_PROBE_TIMEOUT)); + if (!time) { + dev_err(dev, "Initialization not complete, timed out\n"); + gpiod_direction_output(wsa883x->sd_n, 0); + regulator_disable(wsa883x->vdd); + return -ETIMEDOUT; + } usleep_range(20000, 20010); regcache_cache_only(regmap, false);