Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1415231pxb; Mon, 22 Feb 2021 00:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxd+1E31+wCiVsrjo6+dmumSqWOvOA/0emSQwreiareQMxRoKQR126S8pulvIEwYevUvLNw X-Received: by 2002:a17:907:760a:: with SMTP id jx10mr10973609ejc.212.1613984184978; Mon, 22 Feb 2021 00:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613984184; cv=none; d=google.com; s=arc-20160816; b=0iLOPy0hqOuVBv0pOelGs0xBcWHrYPQH+WBAHZZg4MS9xwiRbjR1ea8Y9RTR5N/YrZ BPnoZenpQpLSw/s2aQf4/Elkw1OaL0zygVloU8ladHHdTJh+CtTjx1W/l2Gm/7ESQjBm 1nUfUSUyktrU+tMMlHH4PBSl2UiRriwDusRnDGo9xs5v5HQmWZTxuMMfNtrb5NuT3Btp qkeA6OZAkhnHzBD8L+xunBgXH8/hTk/B6uDkHWgN20L0sRA3fStXx7ZhzaZ9/UO1zq0W 4b6Ep+FCY+j2JJOOtt9nFZqHNiZVQjoigSlEc8Rz29t9Us2JSREV5N9Z/wzvA5YlUvFy Pzbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=1MuNmXaTEXE4zNPT2BloMLCEovjOn+tg7yg/fEdl0ZU=; b=HGIzAUXXXntARMW//r0DYSB5WLmTETHsZqJDePEHV4XWQY5Gnh/ZlzCHOoszfzcte7 Uxp8wwLccn1pXGq7kcXYgazi7Yrkho/mpulDe3tg3+uWrTTJZ4TcxjYrz7j2nvJR6Vbe 9M943pKYcLCpr3d16hfrZt2xSwuol44PVumf6CQFGn1enJhux37DKvpdjeDfImWFizKA DJh00QM/+0qUFrk7KJRsKvSW+7yQTJG1/Vx9x0EiSCBB5vOZ2zkRh+oySGVMPnoGQJhe yp0g4Y5waJ8fChOvRpgpWrPNsoDQUz2tTv7ofWlhLtfHuv0xD4gxKOQeD76BESPreUiY 73hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si10605703ejc.15.2021.02.22.00.56.01; Mon, 22 Feb 2021 00:56:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbhBVIxT (ORCPT + 99 others); Mon, 22 Feb 2021 03:53:19 -0500 Received: from inva021.nxp.com ([92.121.34.21]:43198 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbhBVIxS (ORCPT ); Mon, 22 Feb 2021 03:53:18 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id ABE4B20032D; Mon, 22 Feb 2021 09:52:30 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 5B90E20028F; Mon, 22 Feb 2021 09:52:25 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A070F40281; Mon, 22 Feb 2021 09:52:18 +0100 (CET) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: fsl_sai: Add pm qos cpu latency support Date: Mon, 22 Feb 2021 16:40:20 +0800 Message-Id: <1613983220-5373-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On SoCs such as i.MX7ULP, cpuidle has some levels which may disable system/bus clocks, so need to add pm_qos to prevent cpuidle from entering low level idles and make sure system/bus clocks are enabled when sai is active. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_sai.c | 12 ++++++++++++ sound/soc/fsl/fsl_sai.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 5e65b456d3e2..a22679dea578 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1177,6 +1178,7 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .fifo_depth = 32, .reg_offset = 0, .mclk0_is_mclk1 = false, + .flags = 0, }; static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { @@ -1185,6 +1187,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .fifo_depth = 32, .reg_offset = 0, .mclk0_is_mclk1 = true, + .flags = 0, }; static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { @@ -1193,6 +1196,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { .fifo_depth = 16, .reg_offset = 8, .mclk0_is_mclk1 = false, + .flags = PMQOS_CPU_LATENCY, }; static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { @@ -1201,6 +1205,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { .fifo_depth = 128, .reg_offset = 8, .mclk0_is_mclk1 = false, + .flags = 0, }; static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { @@ -1209,6 +1214,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { .fifo_depth = 64, .reg_offset = 0, .mclk0_is_mclk1 = false, + .flags = 0, }; static const struct of_device_id fsl_sai_ids[] = { @@ -1235,6 +1241,9 @@ static int fsl_sai_runtime_suspend(struct device *dev) clk_disable_unprepare(sai->bus_clk); + if (sai->soc_data->flags & PMQOS_CPU_LATENCY) + cpu_latency_qos_remove_request(&sai->pm_qos_req); + regcache_cache_only(sai->regmap, true); return 0; @@ -1264,6 +1273,9 @@ static int fsl_sai_runtime_resume(struct device *dev) goto disable_tx_clk; } + if (sai->soc_data->flags & PMQOS_CPU_LATENCY) + cpu_latency_qos_add_request(&sai->pm_qos_req, 0); + regcache_cache_only(sai->regmap, false); regcache_mark_dirty(sai->regmap); regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), FSL_SAI_CSR_SR); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index ff2619f1b214..bc60030967dd 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -216,12 +216,15 @@ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6 +#define PMQOS_CPU_LATENCY BIT(0) + struct fsl_sai_soc_data { bool use_imx_pcm; bool use_edma; bool mclk0_is_mclk1; unsigned int fifo_depth; unsigned int reg_offset; + unsigned int flags; }; /** @@ -273,6 +276,7 @@ struct fsl_sai { struct snd_dmaengine_dai_dma_data dma_params_tx; struct fsl_sai_verid verid; struct fsl_sai_param param; + struct pm_qos_request pm_qos_req; }; #define TX 1 -- 2.27.0