Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4422533pxb; Mon, 21 Feb 2022 21:07:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmJNcd0WEVI+Fp1jpQVnAe4akx6VDnxivvMrswTjZ2XZI+ozMHZw1tLKnEZudGOO4wt0xO X-Received: by 2002:a63:cc52:0:b0:372:7f35:cf84 with SMTP id q18-20020a63cc52000000b003727f35cf84mr18529336pgi.211.1645506441040; Mon, 21 Feb 2022 21:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506441; cv=none; d=google.com; s=arc-20160816; b=nM+T91WxXQ/BY5NQ/udi8UYvOggwLyEmMT68EP4qhb4ID0TkA/55aOSrf8THS677/L XacI0wBzcY7DhfVI/SLgujhBYULm/rbkITMtCarLwB/3pVDHkleRKs/miUZuUy4jMZCQ ehPdepLRwe1bQ50xWz5ZZYGcO6mEO+V60v8osqmye/h8cH9/TAW1Dron5tjERCvK8htY EV4rqj9T3t9ujF8+IJXfQLQTedlQZUAQiY6MISGPHa8AZhnKOAqFJc9+iJhMDf5AOAGm xHFGFQilt2XLkeyLmpjCpc4o0mnUiNNWuvWN9xBTXVug2VvrKX1LsShQ2hKEToIcOq+S T4sg== 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=mjGqD8WCKFrbLkxumANW5m3KmQcun3NyZbkV02Y3fnSOw0/Wm8q3X0NXZ05V+4ScTs GlkxMfCsXn2vT7ri0iT+IFhjiJ2y2ET+JCBygyYhGuFrDvAxR1xf/VailtLeR7fUrfma CXLdc5TFave8VEB0g37eDKJd4llulBajMwnfST09gLC772O2CBH6uPA9EWiEm2cUhL/7 ibCYZ8G2nurig/4DLEQT19sxIIJUkiz6WM7jKfkym9IlRW7h0CbtpdC2+00zeaALDpAa 0t4+2AKYsJcH0/phhIIwkJy4DdMrwhAc2mS5ktxn1tmxvQgtWWM9SNDREuFukuNhC+gv rrLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5M6rVpQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x2si5143147pgp.306.2022.02.21.21.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:07:21 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5M6rVpQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 183DDC24AA; Mon, 21 Feb 2022 20:40:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358621AbiBUNLk (ORCPT + 99 others); Mon, 21 Feb 2022 08:11:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358653AbiBUNL3 (ORCPT ); Mon, 21 Feb 2022 08:11:29 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 451271EECD for ; Mon, 21 Feb 2022 05:10:50 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id d27so27034423wrb.5 for ; Mon, 21 Feb 2022 05:10:50 -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=T5M6rVpQg5CiNr0ALeXidXgJ27NA+ORiCY2Lluwps+MNSbQ6BG7XRz9qUUmz9jpiAk lO8F5HA6p6nn2XwUZ2QXVPvwzILoFklTOwYzQ8dj7F5STNqv3ZWHXR6BK/iyTsyfx/q1 qtH7bL/pdBvtx40noEamhS+8PkOAm1+FOXNWMGzCUXt4ls3KcE8E6sEKlbKgoXHS2ygq fZFtH8gyBLWxsUoMTZ4g9ekdM4Lwxip+0iYdGeSZCqcdm867uR2YqICwSm9R/ih6nvvk E9h2iZT2/iZyOQjcSTxyVGT7WHaZaH6Bf7vvtdF/t0PBj4wTAFens0KXhPeOFwqL9/fB fz7g== 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=fz+1Zw0bMMxo1MCMr0FL2Wg4ylgmJ9ZPn/Q8WK+me2WDC3qAaLllLY3NJ5TwiS+Sw9 QGd+nyrK/W/sI8fzSaqhLVRFdQvtB+T+DIV53/xUuEDuhWeUaKL1TFIgQT8vRMcowP9f 7mUPaA9eZQeol82rZKkk7BiT41uaXK80CdimvJcqA0mGUH/qxPaUUXpBUgCa9mmrJ0c1 FPqJTxZb9j5iP4r/LobVtbCfh75+2nQmkp15QOVeJ1PdSMW8uGjQyA9W74ej2ejF+SzI CNQGN0Rjbl2fgakdWh3Ivs5deAnUYlhUuRaQUbDvji+nPcy8yjMRrlglUcbZTkgAlB6N wovA== X-Gm-Message-State: AOAM5325bCMiPDIdMIr2k4csVukecra06TCEjaS1Ky7/lS63ObTHnkvr cnuwITzzMwj8jukoKzE6Gwsj8Q== X-Received: by 2002:a5d:6488:0:b0:1ea:7bfa:41e1 with SMTP id o8-20020a5d6488000000b001ea7bfa41e1mr394408wri.563.1645449048801; Mon, 21 Feb 2022 05:10:48 -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 3sm49412801wrz.86.2022.02.21.05.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 05:10:48 -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 07/10] ASoC: codecs: wcd-mbhc: add runtime pm support Date: Mon, 21 Feb 2022 13:10:34 +0000 Message-Id: <20220221131037.8809-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220221131037.8809-1-srinivas.kandagatla@linaro.org> References: <20220221131037.8809-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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