Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3173352rwb; Fri, 9 Dec 2022 10:52:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lZR9uX9O+lUxKbgdYK/MD8vhAsY/gkTaZRQXLpCYnikt94QSYa6QC/l6eF9kyZ5VQvQ+t X-Received: by 2002:a17:907:c296:b0:7ae:566e:db92 with SMTP id tk22-20020a170907c29600b007ae566edb92mr8771530ejc.48.1670611933729; Fri, 09 Dec 2022 10:52:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670611933; cv=none; d=google.com; s=arc-20160816; b=go3eOEqhMNNOZrZnISFX1dpuFMwk2UQqrJqFhVGOhPqYvSySIZe3IdVjO0Rp7ty/0M OfvPmC90I4mwgbjTEPfX6m1+izi71PVPgf/6z2cdnRmF/DHnegDcmeUjE5fqLJjTt/TL WNFdZA/wHxyGgYb4JSFz0ZWiXRS1Je0vRTLue1mBaEKvK0GxRC6fzl5Ut0ZWN6dlXZ4X 4FpUnNhLcgiXkfpRifG4dbGMABZHkE8uc9DwGxv/Byw8Yavtu/iBgz+I04/YPqsWTRzg quyfgi+MBpgCoPFaK3fsBkGBpwUGKg8foGOaNpyOEgxaubVb1UCWbnehm5powocCraGm 8uhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4w6shm/Wpz6ggc4zMRhzb9FfoJ4MU+lSfUxwokG/Em0=; b=Fgeou9rdtU5MyhY8vG9vyerTqzQbe8PQs/glPcCaGNMT95+OhzJWQyJ4VOcI6IVHlE zpjD4feHMXZD6X3R75izOTBfZpq0zz1SR4qwxswtd+uRf2iryWivoIN0+2q6iJEShcUL ICxBtTJgngmLrLjLuuWMxUbnkZ2iKhh21fxDzv8wLT8KCxQH3PyIHpf/Y47YbO25qUkR Dbfcndyx/VfCFH9V+P7mN4Fj9mDmeCo3EqPkbmSAL0r2xp2Cx5y8MoF+QlGjotlCqoYG +fC09pXwhy9FuQ2bYL5KyuHORBtB1oEh/gEgfNm5fHF++mNyUdXamoK1gZHSHekh0pRQ qQCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DqcJe469; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa39-20020a17090786a700b007c07a807a78si425060ejc.215.2022.12.09.10.51.56; Fri, 09 Dec 2022 10:52:13 -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=@google.com header.s=20210112 header.b=DqcJe469; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiLIS1a (ORCPT + 74 others); Fri, 9 Dec 2022 13:27:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiLIS11 (ORCPT ); Fri, 9 Dec 2022 13:27:27 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D91DEE8 for ; Fri, 9 Dec 2022 10:27:27 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so8978787pje.5 for ; Fri, 09 Dec 2022 10:27:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4w6shm/Wpz6ggc4zMRhzb9FfoJ4MU+lSfUxwokG/Em0=; b=DqcJe4694wkG976PjUOU2TsLdZ6AqSNNqB4CDir8muiXDWFziOVnaq4bgef+IpjXW8 BYCQq5+CHK3zagU/kQNl2fkY6yAAgIpwkoAVkUIYm/XP0BCpkFNUmrSx6WUMKNIunWS/ 1ViUlrZGecXnoABDCfXZA+HP7XhWCtki3CYVZNe/URC5mvmJsTg1fmdWfpTdQb+s30jy iky6uaWQ1JeV7UkhbEB9sz0HKcP5gFKiIBEMvDIBl6xuabikBdYiLwVnjo5oCpMoS1lp pHALstRMOaJaOjvi7AyQNg38g3aS4UMkURCioktQVwm0X3dUqcYQyWVi54s1+DtPa0IZ ETeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4w6shm/Wpz6ggc4zMRhzb9FfoJ4MU+lSfUxwokG/Em0=; b=rf+Dk1ipBJlGiw5Pt+WOZsfypTlSUvg0AuQdGzaIAHfcnK0dAi6oNQHCqUqH91k1Ds siYsRkbfxDEJukYKo99lvIDHJZrtt/UfGQb8Psoy8f1w3fmdlKA9o+PI8psntydkwIew 48qcu290lzt7Ved0Zt2lAeCzUewAIj7/66NlhBw/J4LiwjJzxyRVU9gokJbbDjd/OpNO YEQVk/8e30mh7r4FKvqMQXCAzvUQ8oxwh7BeNNwz9fCKE+oju1izncjLE0bdIQSg/15z uN5c+6sT+mk5QaJfDBZoWLzJ64kNqvzxwT3Ga/qomVT2Y8fVostoa7dfWFnAnS8Ml717 S0VQ== X-Gm-Message-State: ANoB5pkOxJHF/uYN8VadEPmBpGATjr/4s6K4C1mHNEqipwnGZO20W69I 9QxBfvAzpkXvFV6Fup8k+osEgxVlQcGKaz6bLxYTyg== X-Received: by 2002:a17:90b:290:b0:219:2b00:8d23 with SMTP id az16-20020a17090b029000b002192b008d23mr57659625pjb.167.1670610446237; Fri, 09 Dec 2022 10:27:26 -0800 (PST) MIME-Version: 1.0 References: <20221209031053.8444-1-yc.hung@mediatek.com> In-Reply-To: <20221209031053.8444-1-yc.hung@mediatek.com> From: Curtis Malainey Date: Fri, 9 Dec 2022 10:27:14 -0800 Message-ID: Subject: Re: [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active To: YC Hung Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , Tzung-Bi Shih , AngeloGioacchino Del Regno , Trevor Wu , "Nicolas F . R . A . Prado" , Jiaxin Yu , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Curtis Malainey , whalechang@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, Dec 8, 2022 at 7:11 PM YC Hung wrote: > > In MT8195 SOF design, both DSP and audio driver would access audio > registers. Before DSP accesses audio registers, audio power and clock > should be enabled. DSP will hang up if DSP access audio register but > audio power and clock are disabled. Therefore, we add audio pm runtime > active checking before accessing audio registers in SOF BE's callback > hw_params function to avoid this situation. > > Signed-off-by: YC Hung Acked-by: Curtis Malainey > --- > sound/soc/mediatek/mt8195/mt8195-mt6359.c | 30 +++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c > index 61be66f47723..4682748d82be 100644 > --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c > +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c > @@ -633,6 +633,32 @@ static const struct snd_soc_ops mt8195_rt1011_etdm_ops = { > .hw_params = mt8195_rt1011_etdm_hw_params, > }; > > +static int mt8195_sof_be_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); > + struct snd_soc_component *cmpnt_afe = NULL; > + struct snd_soc_pcm_runtime *runtime; > + > + /* find afe component */ > + for_each_card_rtds(rtd->card, runtime) { > + cmpnt_afe = snd_soc_rtdcom_lookup(runtime, AFE_PCM_NAME); > + if (cmpnt_afe) > + break; > + } > + > + if (cmpnt_afe && !pm_runtime_active(cmpnt_afe->dev)) { > + dev_err(rtd->dev, "afe pm runtime is not active!!\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static const struct snd_soc_ops mt8195_sof_be_ops = { > + .hw_params = mt8195_sof_be_hw_params, > +}; > + > static int mt8195_rt1011_init(struct snd_soc_pcm_runtime *rtd) > { > struct snd_soc_card *card = rtd->card; > @@ -1272,24 +1298,28 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = { > .name = "AFE_SOF_DL2", > .no_pcm = 1, > .dpcm_playback = 1, > + .ops = &mt8195_sof_be_ops, > SND_SOC_DAILINK_REG(AFE_SOF_DL2), > }, > [DAI_LINK_SOF_DL3_BE] = { > .name = "AFE_SOF_DL3", > .no_pcm = 1, > .dpcm_playback = 1, > + .ops = &mt8195_sof_be_ops, > SND_SOC_DAILINK_REG(AFE_SOF_DL3), > }, > [DAI_LINK_SOF_UL4_BE] = { > .name = "AFE_SOF_UL4", > .no_pcm = 1, > .dpcm_capture = 1, > + .ops = &mt8195_sof_be_ops, > SND_SOC_DAILINK_REG(AFE_SOF_UL4), > }, > [DAI_LINK_SOF_UL5_BE] = { > .name = "AFE_SOF_UL5", > .no_pcm = 1, > .dpcm_capture = 1, > + .ops = &mt8195_sof_be_ops, > SND_SOC_DAILINK_REG(AFE_SOF_UL5), > }, > }; > -- > 2.18.0 >