From patchwork Fri Jun 28 09:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13715893 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EC7015443B; Fri, 28 Jun 2024 09:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719567869; cv=fail; b=CYeEVNF3GA7Q8Xo/Na+cB5PD275NQwpzjKtddUK5J+acp61e83sng0qEA66VEwCBL5/t02v3Nyng2RTM1AuYgwAsaHwV0HCUiTGR0Ma3qMFHRGeSMXII794wpL8kEQuIFb+dLGuZ0L5jcy3DjZNHs3HcM/iNHPVZhJXgQAgkZWI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719567869; c=relaxed/simple; bh=mO1yvHTc3NKf8j77zNlIQV0mpQ8DhtbhBhLeaPmCUCU=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=lWTQUIf5bgy7aw+hJyNlu21BKuyEeHqhCdhuOXl13r2c3VyAdJobvO+/K/nfXVtaUhiOLPR01EWcKsxRKZ6JkMfKFWGrQ9e38VXuKg3cvwAdIzJxb44NaYL6aLnqhZEq0gf7X1uYgGo1ZoV1p9dC8mGV5q14qqI+3x7O0V/fkME= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=HKd9Xynk; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HKd9Xynk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c4SjnD0lMUKYwOavDtP79N7NUynHuP8UMKmsGd02bPcVMzQy4mEHn0bYE7tN2MUEivdLpjvSjreP1Ga20cfP7D5kXIOJfDI9cZZZ5n9t2xpGgwMatx6X0NPcLvs/hxWRy5i5udxPNepRyp24LlME5Yj4l7jyonwFmADXDa3Ikawk5aSpLI6Utw6WJcmatT5an+laVIBCo3eQdNvCZZfrDz7YNnRg4gltrbAkgeTwHraTp5Xayo9YhXbK3vOfMInUAHmr8HqPaIaWfUZfzwbo0YxeBIUA4IE/d26AzA9YgF2JZnKBehcsfmV3A7YC9+WYNk0524KCG+ifFf+q8howtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uAs2Y1hllEPnEtkbRstwmGKu0em8iRigETu7W2hnzl4=; b=gDgMB2hHDL2Ywib9OAgf6ydQRNjAUX2O/gSaNsafrOzTIjxtqFBhx/DW9NXd7DMeOnx2MC9mDouxxOqMF1CmspnSNZXr0y9j2epdmO1RXl5B60p8mSOaaEZXM93N6zcYQXtPqlIdDjuMQ0yxu8cRbnXJxw/sQ2Wxqqm/YPmmet0z9aM8Q/uoPGdgr+mOCGS8vkzJHbjgQRgWeLcHT5BuZXCiKt74/deuIc2jmZstKX/yv5vPLusIfTrLltZ4fnW+rJW5ELSfjh6C4M41rTK/okMjAe0aD8+6pPwds3xO8j8w8Xb++/PnPWAySBJQZLLZ6PaapI5m3d5wKMVYxcencQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uAs2Y1hllEPnEtkbRstwmGKu0em8iRigETu7W2hnzl4=; b=HKd9XynkrB8AWJZC2M0xZcc4xreve6yX4Jpe0Vbbm3XhvWR0ZLTFW2W1Nxrh14HjoIyumrFE2WoZxH+PDIGN/CoGVd3b5cUw4T1QexM9g0ENBkrXDgcUZaUzzzgqxVdzGBnrpjL6QL8qag89Gbae7arUd2iA1P634xRMpEGF54o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by PA1PR04MB10170.eurprd04.prod.outlook.com (2603:10a6:102:463::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.26; Fri, 28 Jun 2024 09:44:22 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc%7]) with mapi id 15.20.7698.025; Fri, 28 Jun 2024 09:44:22 +0000 From: Chancel Liu To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Chancel Liu Subject: [PATCH] ASoC: fsl_xcvr: Improve suspend/resume flow in fsl_xcvr_trigger() Date: Fri, 28 Jun 2024 18:43:54 +0900 Message-ID: <20240628094354.780720-1-chancel.liu@nxp.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: SG2PR04CA0203.apcprd04.prod.outlook.com (2603:1096:4:187::22) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|PA1PR04MB10170:EE_ X-MS-Office365-Filtering-Correlation-Id: 005cc989-b24f-4ffa-c8b8-08dc9756e3bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: EwC/dHQF6wHd+qZsjYNvy6oejPX4psruiFYuVNdiMw/k4M1dTijb5rNaNfNY7n3cMAe+LqAuKe+2EG2+ZNftwCcfCefTCcVXhPSpDoDgIRLpIOtDOzVh8mHbGkPaJi/Et4z5UejKGBFBnW6/53KXj8AnBrBdG601rqTN+sWSvDFFH/d8CY99ynRLQ5WEiQtKRtpRR4/ECLTrrSvMeFDinXRa7L7F+IYixPYcvdmX6czl9x/lOMXHcoLW6npuJHDvejJ31rZh7WJbO5bfuccXDAdIdLK0XhgbXLOGEXZ48AFQ/9FMrSJLKJ26jCOQtzFLXIrw+rLuDFhGh7dcfyb2EefNpHjiv3mIMqEJxpW3WmMAhSFanvF03UKx9y+8SsDAKaTz6Hvd1NKB4OWdMn7wWYb3amFR1oTAQdMmCH9ERLqcIsauYTD8Dzwa8W1+jSrft4qvtNXo7yeJ0YqrdeqC3FglQT3gn8S2RcgbJzT1t2E/HU7U2N8GXGnobO311ogd/MN0zy6L3RCfy/e9VMLxX/tNjIrYEE59EJl1Bfkn+8G6uurjk6/qcxK+Y9WFjihtMpIQljspvUKvnegjS6kNqP7QuNGWwMd0rdKEmKREGbLb0QOil03lK010CgL0jwaDr0qQAoB877Kj2TcShJ1luADfW2JpgQSll2HjDma4C7PY84D4WhJzW3W/IBxDR8+7epfKwwB9TsZls6GjuGhdU7aaA0YfaVF/8G7PvMGbQt7HZsIhaJazUhaxMxSqyNqRkPibUU9EGUDbbJPZIE4UACgZa2P24W+LaWHYHVGkje1K6Jzc3bP92IX4h0sYJF2efT6GtMJzOa2UlJZhk0ViJZRjhPPWyW8s5u1MS7Mhu/NRjmmDnweXe64Ol9RN41IGXVBVK0ySxaGzRQjsYxQnTHyqUBSQ16/Qlw1e3iWWgNtRVRWhj/HcG18NI8N+dEzn6GWEGAuloR5GrucGK9MtberuRZ10hWukYXk8PtRaDqPRoT2dG41Qq6+lMndXABIemid1r4g2OZO4T+nRf0z9ERY9qd4bmjrEYT7V7aNSRKWDgc0ONID5q7x5arar1+18lbeum2nhWhQ5+EfAc/YPq1dkDUiarTomc5WHE3n3qHXFsctwNumSkKh1fyWgVKyInQ0Di9AmotYr0xNCYqW1T1OL3Tts7oFS8dKi3zY+vIPJ86pRc6lXchheLeOZscUF4HOIq32ajfKJqVDQMg0VUStHoZv5YqsapNYrWoyQrMnsP+KLhR9UYolRzAbfyAqkg3tHrUK+gLLPYqycwv9gDL3IFqFhrEjFE/DGi7x5kx4XD1a/hfZj0iD57wltJlYpLTZZ4a6UPjP7KVGMBQk83DP2b9TfZY/p9wNSZnTFjnrjApf5ZrVKcpdXoSNUggKXz9kYWU4+XMsO6RuZMg5EUUg3920oLGX6VDnCEwtqj7A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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KEChBs2CIm8A5bE+atWMmTgGdoM3N+KA2UScAxzg2SgUXtpFhxY0IOxtBldZefpjngnAecw8Kk1ttCuITTWMhlRwzRhYsrhYmIc2MBTff6BNRPf3pVGMnhRcUjYoTeF13aHfxRQdUieZoYW9ZGPIEKnnIwp5zotCg2sb37/Z2uNqIFdr5hYRzYtKpOqV7guW5H/2gaC63dp39u5ZIvyYlGueTZxINSsX085L29jMiyF3mXUjZaEtxv5a20i9RWpUDP82zbvUiz2e46j2K8RKyXb6nGuDOAVs3Dq4uHDg+Ehofy9B5nLHqIx546LuWCOu7rP81+K7gdqN2A+xjy0F0POLMUfTvnBogTUQ0t+gp2rTAvMv0k1NkZtXYTEfsnREYXNCTu+so4Ozjynrv5917Rjxqd9h1h5n7ERsGGto5SOIqNayAiugdt+zLtlVNvQ53kIlj9lpp/1GyJt1R3N94Wssy6V5L2DBG438se22zWafl9VAgLBEKX9Si8A5nUxFs2tMdF+IJoXaqGwhtgP+S+4ZGl1 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 005cc989-b24f-4ffa-c8b8-08dc9756e3bc X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2024 09:44:22.5045 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0dW6Hh6dR7kzN549E15zs6Z6I+3QsxlxG/AcHGsOzE9zOqS4A9rTKS5wKmJBGVlR5V7sNTHiHTd98pDbPAjPlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10170 In the current flow all interrupts are disabled in runtime suspend phase. However interrupts enablement only exists in fsl_xcvr_prepare(). After resume fsl_xcvr_prepare() may not be called so it will cause all interrupts still disabled even if resume from suspend. Interrupts should be explictily enabled after resume. Also, DPATH reset setting only exists in fsl_xcvr_prepare(). After resume from suspend DPATH should be reset otherwise there'll be channel swap issue. Signed-off-by: Chancel Liu Acked-by: Shengjiu Wang --- sound/soc/fsl/fsl_xcvr.c | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c index 337da46a2f90..bf9a4e90978e 100644 --- a/sound/soc/fsl/fsl_xcvr.c +++ b/sound/soc/fsl/fsl_xcvr.c @@ -529,16 +529,6 @@ static int fsl_xcvr_prepare(struct snd_pcm_substream *substream, break; } - ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_IER0, - FSL_XCVR_IRQ_EARC_ALL, FSL_XCVR_IRQ_EARC_ALL); - if (ret < 0) { - dev_err(dai->dev, "Error while setting IER0: %d\n", ret); - return ret; - } - - /* set DPATH RESET */ - m_ctl |= FSL_XCVR_EXT_CTRL_DPTH_RESET(tx); - v_ctl |= FSL_XCVR_EXT_CTRL_DPTH_RESET(tx); ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, m_ctl, v_ctl); if (ret < 0) { dev_err(dai->dev, "Error while setting EXT_CTRL: %d\n", ret); @@ -679,6 +669,15 @@ static int fsl_xcvr_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + /* set DPATH RESET */ + ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, + FSL_XCVR_EXT_CTRL_DPTH_RESET(tx), + FSL_XCVR_EXT_CTRL_DPTH_RESET(tx)); + if (ret < 0) { + dev_err(dai->dev, "Failed to set DPATH RESET: %d\n", ret); + return ret; + } + if (tx) { switch (xcvr->mode) { case FSL_XCVR_MODE_EARC: @@ -711,6 +710,13 @@ static int fsl_xcvr_trigger(struct snd_pcm_substream *substream, int cmd, return ret; } + ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_IER0, + FSL_XCVR_IRQ_EARC_ALL, FSL_XCVR_IRQ_EARC_ALL); + if (ret < 0) { + dev_err(dai->dev, "Error while setting IER0: %d\n", ret); + return ret; + } + /* clear DPATH RESET */ ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, FSL_XCVR_EXT_CTRL_DPTH_RESET(tx), @@ -733,6 +739,13 @@ static int fsl_xcvr_trigger(struct snd_pcm_substream *substream, int cmd, return ret; } + ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_IER0, + FSL_XCVR_IRQ_EARC_ALL, 0); + if (ret < 0) { + dev_err(dai->dev, "Failed to clear IER0: %d\n", ret); + return ret; + } + if (tx) { switch (xcvr->mode) { case FSL_XCVR_MODE_SPDIF: @@ -1411,16 +1424,6 @@ static int fsl_xcvr_runtime_suspend(struct device *dev) struct fsl_xcvr *xcvr = dev_get_drvdata(dev); int ret; - /* - * Clear interrupts, when streams starts or resumes after - * suspend, interrupts are enabled in prepare(), so no need - * to enable interrupts in resume(). - */ - ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_IER0, - FSL_XCVR_IRQ_EARC_ALL, 0); - if (ret < 0) - dev_err(dev, "Failed to clear IER0: %d\n", ret); - if (!xcvr->soc_data->spdif_only) { /* Assert M0+ reset */ ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL,