Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1679401pxm; Thu, 24 Feb 2022 07:29:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT1DWJxoa3uNL3O0GBqoYwjT86X1552se5JNvQBdpHZt5xwqX+y3zxDhey4N2/T/MIGxYZ X-Received: by 2002:a17:906:3152:b0:6cf:7204:5cf0 with SMTP id e18-20020a170906315200b006cf72045cf0mr2779717eje.449.1645716593790; Thu, 24 Feb 2022 07:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645716593; cv=none; d=google.com; s=arc-20160816; b=Tohfw0UVoUSPxPtaoiDJhWj5iazt49otFYeyuIZ6v/C002TymH5vuMu8vQGTG4XCfm 923ZuOR+MGW++ptzPufedrP6wUuOahRpM6MxDvA3DPoWYbizm2Meec1uzaA8Z6D2uu42 y90mf2n0U1FAW7DNmoB6GpiR0dn2+ZvonkahvUZ37e5GFwaxeKe7qfr/qaO8/+9V+cCr qTvyQR/CHlPoq/HFoAZnbVtucWagICrUdgDlW2eqkBE52jCjtBjD8k4UwykBsdMnYhn3 yj7ZMCofmqQw5bSfhoJ2e28Hf4b+4GdBTNF36v7bnhWP73ALV3ZfEJ/Qcz+BMfmlp+r0 gt7w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vyVwZE5kS8xGdR91o+WjovvMprsI53ZLyaYZnmErV2U=; b=WDNOLltqxpmrVS7/O3hUkQeZ66m4kzFlHilaeLHMwtolJajW/oHmDoDH0JiOj5LtnP TNak2a5+unDuPys4WTUuGQitETGJh48OSoXi0WJhi7NU4guSos1iR4dLVjUCRVTs8OTZ dO+AVFpb+UpYY+KjgE3CpG4/iAn4SdMf3owP3ESY+xuxNGDsO30Dv2JC38ewDExe2spW 6cEAMn4hYm4WfhSC7hEnREgcgViRsxEnG1o5jUqlVhb+BvWspsmFoOnfMqydEi9sVKWK +rt1/EWkSpGZ8mTYzVdLnTXB5q09i5mFuhuJFHUBuhYPWGBBqKTJieP2PFYVk0ICuSsM eikg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FhYFTNt+; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8si1936704ejj.812.2022.02.24.07.29.28; Thu, 24 Feb 2022 07:29:53 -0800 (PST) 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=@linaro.org header.s=google header.b=FhYFTNt+; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234077AbiBXLTC (ORCPT + 99 others); Thu, 24 Feb 2022 06:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233972AbiBXLSL (ORCPT ); Thu, 24 Feb 2022 06:18:11 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11AB16E7C1 for ; Thu, 24 Feb 2022 03:17:41 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id d17so2426377wrc.9 for ; Thu, 24 Feb 2022 03:17:41 -0800 (PST) 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=vyVwZE5kS8xGdR91o+WjovvMprsI53ZLyaYZnmErV2U=; b=FhYFTNt+x3zszGAAc6gGVhzw88T2nJfziV8IMyz+t5pRZHT/uQUpG/qBROnyUaOInX t6ydRexMU9xeDqLPuLmfDwCcCcley4x4U48EGfc4N6WukdVvYf8DZlawzrDNKd8C7FFV piEKh1CH2rdUJ1/FKZ0wmHE4/5BGxIbZHJG5Ki926kOMial7fMtmRNM3mz5ZKagcqQjk tL4T4laIIAgpVqkFPZUZZNUePbs6aG+cQbu0t7oetR3A6Br0XbUtDfDTA3TY2Orv2o9P yyD0rt+BDpSTqiVwmhzn7HbDPMIxaJxxqu9Fsoa9qSLz8xyqDGQHvgI9lumtnZ6NGpm4 c+gw== 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=vyVwZE5kS8xGdR91o+WjovvMprsI53ZLyaYZnmErV2U=; b=mA/8HabuZqmrTzKncZSVMLxpgtaphQ0KC3d7UtmWNdcjM0gOSPW0PZPkCU9wY77bN7 3dzWZdUjCswWprPVj0xuiJVyQ+qwp1XpGh3/FdgfaNH1E1KGL+9YYM+bik1PkRLajj54 pZaZmXOns1IZQxrJymik8t/u4T+s7YM0Sxt5/GhlqyMogosyCHHuefR7jBePc3Kg3XJ1 fsLj+kRtoYaAykQ+3mjrDSLHtN4r9QrB6GbLwJo//6VNmdwyf2vGT38pzsN0AO/C0Yw6 TEiDDkSRXSfVaDxK+XR90pNDNA73+IVJQ/Ddp5Hmtrl3jwkjJwOWMHqHXpRE1tjcSl7F PzTw== X-Gm-Message-State: AOAM531qltpb7tzXfoajVIzfCPcZV8NQqdeUyUQeCyIbXopqf00b1QND fdVal3rKWjwfvEO7AP8sgHZvEg== X-Received: by 2002:a05:6000:2ad:b0:1ea:793a:3284 with SMTP id l13-20020a05600002ad00b001ea793a3284mr1835943wry.63.1645701460101; Thu, 24 Feb 2022 03:17:40 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id t4sm2245737wmj.10.2022.02.24.03.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:39 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, quic_srivasam@quicinc.com, Srinivas Kandagatla Subject: [PATCH v2 16/16] ASoC: codecs: wcd-mbhc: add runtime pm support Date: Thu, 24 Feb 2022 11:17:18 +0000 Message-Id: <20220224111718.6264-17-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220224111718.6264-1-srinivas.kandagatla@linaro.org> References: <20220224111718.6264-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 under low power state a SoundWire Wake IRQ could trigger MBHC interrupts so make sure that codec is not in suspended state when this happens. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd-mbhc-v2.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c index 7488a150a138..c53c2ef33e1a 100644 --- a/sound/soc/codecs/wcd-mbhc-v2.c +++ b/sound/soc/codecs/wcd-mbhc-v2.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -711,6 +712,16 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data) static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) { struct snd_soc_component *component = mbhc->component; + int ret; + + ret = pm_runtime_get_sync(component->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(component->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(component->dev); + return ret; + } mutex_lock(&mbhc->lock); @@ -751,6 +762,9 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) mutex_unlock(&mbhc->lock); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + return 0; } @@ -1078,10 +1092,19 @@ static void wcd_correct_swch_plug(struct work_struct *work) int output_mv, cross_conn, hs_threshold, try = 0, micbias_mv; bool is_spl_hs = false; bool is_pa_on; + int ret; mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch); component = mbhc->component; + ret = pm_runtime_get_sync(component->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(component->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(component->dev); + return; + } micbias_mv = wcd_mbhc_get_micbias(mbhc); hs_threshold = wcd_mbhc_adc_get_hs_thres(mbhc); @@ -1232,6 +1255,9 @@ static void wcd_correct_swch_plug(struct work_struct *work) if (mbhc->mbhc_cb->hph_pull_down_ctrl) mbhc->mbhc_cb->hph_pull_down_ctrl(component, true); + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); } static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data) -- 2.21.0