From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C573D73EBD for ; Fri, 30 Jan 2026 05:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NeuzcnTqdAA1Zj6sZaA/TgsUA8C8RoXUmLnNpiVGoTI=; b=IODucSOIhrQwrl9KW3Fdx5lZ/K D4KaX0XR2Ny8866OLv+0ntftrcgyl20b3Kn6oWQEJYdHb5NCQJYhOZu/YZ2CVepEDzdNAnsNOIS+J YwvNm6/vDTdpkg7ZJy5WKHUBXiC8EaueNCBeSDL619s+ITdxF9M9FhLtqhQSHXQlbALDm/GeGjGyk mdXS1tWW2JNh2KOBNXaVUx5Vi4+MfPoKFcABYKhVK4dmKHBXFmJ1b0sEOrZYxvQ5l9fzKstdMXAaL TbYqkpbvISnf7shXJQNrdxT++HV5i0i9blyY1g5x7vAdsstyOZAt4YtLhH0v54GFiH2JXDd6v+E3j alIdd0fA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vlhIw-0000000145P-123x; Fri, 30 Jan 2026 05:44:26 +0000 Received: from mail-northeuropeazlp170120005.outbound.protection.outlook.com ([2a01:111:f403:c200::5] helo=DUZPR83CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vlhIr-0000000142x-3kNq for linux-arm-kernel@lists.infradead.org; Fri, 30 Jan 2026 05:44:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qoy1zy8+QZkD5zqasNjcVqoFNNwJERJ8tVazKJGPhxxMLDZoqmAaPY7gFWjWlU6zYkvengbEWBMcCO9wFNUOdPZHe/JHhgjcxnq5D9NlTBSDonDTZodQrqxX7u0L/mr9VBW1zo9SO5VSlNW1z+kbWe9EVVtwwIrfK+ij/frP2Cl0tBrITmhGT6FRn8/KLTZlI5q5m/aEnVfhX8dEuseopVLGP6+EXkh8bof5sd952t8c3BQhYmbHQgl1zJvGYY/GJLkb4aO6x2zcoNWFRm9ECj9yohdab6R2m1uCa9wOArwccvivza2ZQpJ1/tdJDSkYgHm3v2w1fw544qrP0kjysA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NeuzcnTqdAA1Zj6sZaA/TgsUA8C8RoXUmLnNpiVGoTI=; b=sb6b4pRmB6q7yYBqbFJAYJ2XMS97S61bCwnmOiNWHlC1ozYyUNk7RPoS2BqcCwAKj9jjy54U9TITWAh4p7eJRcivTAkIPZKV5aQ+uuOYLTG2KD5kLR60hkXSDnbRiNIsFjwkoBxxc7nG/PNKW2YEPI8WvHVjEQZmjuazvbrF7wFi31zivZkGiEKD9FgyYQMYHVILNprzpiW4weelDAwvhKjSdK/B+L8/0eBQqf1v+m3JszZEuStpyfQiRDDUDQtGUi2ESCwGVaKIRBbOQVG54s18G9nLT3sCcnwqF8hHlUUoAUr1Yc9pgH1HE7j+TFIZ+8xK0D6rsgzYPYViTw0JsQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NeuzcnTqdAA1Zj6sZaA/TgsUA8C8RoXUmLnNpiVGoTI=; b=T4KaK55Cmlmv1uJLcxKObz4In3fYBNk6FEaLvhnYD+S8xvGl5qI3R744KL+3PPHy+jFr3S4JYRZaseaarbMPymS46gA/l1qpuM9aSItK9cj+GX7mt5hHNd4UcyrLRQEOqBDqRC2kmsEox0pnpTZqSYizlAvrbAR8jAK6oaPoMy6G20ELLTbeRpNeuo2ahPbyl4jZ8iQJkTUMtichWk6Vc5ha+04NqRx4dYJyRnro2WjaoI5BIqLG97e0LZdUKMKCR7CYnWaUQR7nXcKU3gl1JFv8POH2YqHYG0pEXSJ3QEK8s+XgOZEMtnHpDfrUiLL4REs3wVsV4ttUSCBVA0wGDw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) by PAXPR04MB8174.eurprd04.prod.outlook.com (2603:10a6:102:1c4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.16; Fri, 30 Jan 2026 05:44:17 +0000 Received: from AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::bab2:d15c:fcf8:ef2b]) by AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::bab2:d15c:fcf8:ef2b%3]) with mapi id 15.20.9564.008; Fri, 30 Jan 2026 05:44:17 +0000 From: Shengjiu Wang To: lgirdwood@gmail.com, broonie@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, nicoleotsuka@gmail.com, perex@perex.cz, tiwai@suse.com, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 3/4] ASoC: fsl_asrc_m2m: Start ASRC before DMA device for M2M Date: Fri, 30 Jan 2026 13:43:29 +0800 Message-Id: <20260130054330.3462544-4-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20260130054330.3462544-1-shengjiu.wang@nxp.com> References: <20260130054330.3462544-1-shengjiu.wang@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI1PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:1f6::10) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|PAXPR04MB8174:EE_ X-MS-Office365-Filtering-Correlation-Id: d7f5c3b7-be9a-45be-4475-08de5fc29b66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|19092799006|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4WFQ1Qlu1SRf5yMWt5uExI44zZQ0s4vGyfFWwG95lxGePcaWXiw6AGe+JUni?= =?us-ascii?Q?8dVrafrTDvR/xK1GszSVIg5gYYhzuFFK4NMcGYl8Zv2sEYlOg0BTBm6LkiRw?= =?us-ascii?Q?jdWx/p0z2GXEWzRZFhRXw0sXUGqlO3JmFsJK5Z/1d3aYuYPfZLXkwCgIoKDf?= =?us-ascii?Q?ljNWotxRh0N5hRr8XJP6DR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q4P97K79IH?= =?us-ascii?Q?j77SopulXBAolgKfqcVlrdxbbSI8+zBBnLzjH0OCLLx3o90qIZmXIzwleT7r?= =?us-ascii?Q?nFo/SBM4Y3eP8n63ZuZ1HsLtk9Cc5lcCYE4idpBo3qoqcTQ6UiM3+B9qTPHM?= =?us-ascii?Q?d34egavjH3eU+iG6OJcJNvd1nmZTrwM5x3pTSbZ0DKu0+kRVC4HxCFUxdyse?= =?us-ascii?Q?mF/1gE8r7oQAudn6PMp/5BWH5JVALBbgpJuEA6hYhGQkWzAPGTT2fLP0oLKb?= =?us-ascii?Q?0KUZXGgYr8m2iQW7t9hKEPT3pmAIRL2hG/ninDwOnej41U0+znwH76wktOIC?= =?us-ascii?Q?SEMR8edLzln43VVrCZFFKNUW0e6GnqBSTUqLuzyh3BOaqTDDvctdMlwYDxKP?= =?us-ascii?Q?UT81GGMUajYaZbUuGXJNiptF0E+Z9CHfANJ/Vyo5CbIwklxJDB74A5AQBu9j?= =?us-ascii?Q?+nyGYqg6lFojT2mdlu3+YKWNJsAIjpLvBrkZzbxEPxUHutsU1er9qZGieFBW?= =?us-ascii?Q?bGkZj6Eg7iWGZfb2LmHXMwu2ihrJHOsbakKo3ulcAJ4Mv42RMQIwDxGT0rhD?= =?us-ascii?Q?tOIwPqOaxKIoK1KXXt4OeNHyRyxrtSSccWBZBxm0G+zJ?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB7044.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(19092799006)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sfRWWXGb/oZKAbQDhQgbtav++zRIVQJXr+Cq+xbKhqzKXfK3H9Cej2g2BUuL?= =?us-ascii?Q?DvNCLrPXtp9XW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GlZblsWOockjYen?= =?us-ascii?Q?C2hp+VISc6QL/Dj3WbPwIZQCOEMA2dl0e685muvhmyv6Kf1M78p5ge+V6WPA?= =?us-ascii?Q?ioRDaiiKWNP+CnBis05YcqYxZDh4gTni0ZdPV+PxVDKPM+3W90G3B1/DPw2a?= =?us-ascii?Q?Z/qC7+wqWoXVPhuh2PKoI4Yv021PHp+Lum4cWe5rW2ag3pfOBWp7QSYYPtZJ?= =?us-ascii?Q?naFEAKPO0BiFxcLEj7hv0+66F1rrrAfmGGh8Pt9wiY0KU3Twb3wxmUxf0KLq?= =?us-ascii?Q?XlBXtQWNVILHhSCJF+kWaCL9h5iJ57tkGj4n9CO/x4ZKPz0Wq/1pE+zgFA0U?= =?us-ascii?Q?EU5AOzg6fPFavMZnZqrjPDF1jbLFXLv8kDNTsvDSAfyOH7nW6eQVA2/uVg+y?= =?us-ascii?Q?BC9zUWbAxLQ0ffh3tnl7XSpp27v2G6pNvsK7Ka+tadGfmHZ+qfN0LocAQ8S1?= =?us-ascii?Q?ThgVButqns4/7lxOG3aKI3h/hbhdRLkDuLeQfqCZVQsBQWKpbVqMEbUn4I5m?= =?us-ascii?Q?lD9ONUL4o1OeFuNCOZKcdTYfqSt+dCjK1WkctFWH0PUDBTPz1NQWMcGEKohE?= =?us-ascii?Q?WP0n4xBoGVbTCq+NHyH/BilUm4JDRaoP3tevgsRrN6Gt8/H+JZVbT/dw9AXR?= =?us-ascii?Q?S+5k9mUHh0loXfyaglW9PSoCDA1i43DPP1ozVCGNDs+O6U5kpWUPurFs4Ixl?= =?us-ascii?Q?MoGkGma1O7DCowmrpZWfk5MaPpl9K7asOJm6w/s1c+B42yy+AtMJyKWfHMjo?= =?us-ascii?Q?CH4IAbm37si562dY6oWa6wRp6kS3C6whBm3ziWHw8EJ6zn0ptalIYlWvsuGi?= =?us-ascii?Q?3c28DceLtg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7f5c3b7-be9a-45be-4475-08de5fc29b66 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB7044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2026 05:44:17.0599 (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: 3zueoK9SBDg6/cNLNFjMHJu6gVrPrCAzfMUq9sVRVzd48YgIP77vk2FPHp/J7BSRAHO1VG22uXCzBEmOb7Z9kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8174 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260129_214422_079161_F675C3E1 X-CRM114-Status: GOOD ( 22.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a limitation on i.MX952 that dma request is not cleared at the end of conversion with dma slave mode. Which causes sample is dropped from the input fifo on the second time if dma is triggered before the client device and EDMA may copy wrong data from output fifo as the output fifo is not ready in the beginning. So need to trigger asrc before dma on i.MX952, and add delay to wait output data is generated then start the EDMA for output, otherwise the m2m function has noise issues. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_asrc.c | 25 +++++++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 2 ++ sound/soc/fsl/fsl_asrc_common.h | 4 ++++ sound/soc/fsl/fsl_asrc_m2m.c | 29 +++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 5846a2b1f73c..2374577c13f9 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -1084,6 +1084,28 @@ static unsigned int fsl_asrc_get_output_fifo_size(struct fsl_asrc_pair *pair) return val >> ASRFSTi_OUTPUT_FIFO_SHIFT; } +static bool fsl_asrc_m2m_output_ready(struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc = pair->asrc; + enum asrc_pair_index index = pair->index; + int retry = 1000; + u32 val; + + /* Check output fifo status if it exceeds the watermark. */ + do { + regmap_read(asrc->regmap, REG_ASRFST(index), &val); + val &= ASRFSTi_OUTPUT_FIFO_MASK; + val = val >> ASRFSTi_OUTPUT_FIFO_SHIFT; + } while (val < ASRC_M2M_OUTPUTFIFO_WML && --retry); + + if (!retry) { + pair_warn("output is not ready\n"); + return false; + } + + return true; +} + static int fsl_asrc_m2m_prepare(struct fsl_asrc_pair *pair) { struct fsl_asrc_pair_priv *pair_priv = pair->private; @@ -1281,6 +1303,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) asrc_priv->soc = of_device_get_match_data(&pdev->dev); asrc->use_edma = asrc_priv->soc->use_edma; + asrc->start_before_dma = asrc_priv->soc->start_before_dma; asrc->get_dma_channel = fsl_asrc_get_dma_channel; asrc->request_pair = fsl_asrc_request_pair; asrc->release_pair = fsl_asrc_release_pair; @@ -1295,6 +1318,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) asrc->m2m_get_maxburst = fsl_asrc_m2m_get_maxburst; asrc->m2m_pair_resume = fsl_asrc_m2m_pair_resume; asrc->m2m_get_cap = fsl_asrc_m2m_get_cap; + asrc->m2m_output_ready = fsl_asrc_m2m_output_ready; if (of_device_is_compatible(np, "fsl,imx35-asrc")) { asrc_priv->clk_map[IN] = input_clk_map_imx35; @@ -1565,6 +1589,7 @@ static const struct fsl_asrc_soc_data fsl_asrc_imx8qxp_data = { static const struct fsl_asrc_soc_data fsl_asrc_imx952_data = { .use_edma = true, .channel_bits = 4, + .start_before_dma = true, }; static const struct of_device_id fsl_asrc_ids[] = { diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 2f67b085de24..1be93148a879 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -446,10 +446,12 @@ struct dma_block { * * @use_edma: using edma as dma device or not * @channel_bits: width of ASRCNCR register for each pair + * @start_before_dma: start asrc before dma */ struct fsl_asrc_soc_data { bool use_edma; unsigned int channel_bits; + bool start_before_dma; }; /** diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h index 0cd595b0f629..c8a1a2b5915d 100644 --- a/sound/soc/fsl/fsl_asrc_common.h +++ b/sound/soc/fsl/fsl_asrc_common.h @@ -107,6 +107,7 @@ struct fsl_asrc_pair { * @asrc_rate: default sample rate for ASoC Back-Ends * @asrc_format: default sample format for ASoC Back-Ends * @use_edma: edma is used + * @start_before_dma: start asrc before dma * @get_dma_channel: function pointer * @request_pair: function pointer * @release_pair: function pointer @@ -116,6 +117,7 @@ struct fsl_asrc_pair { * @m2m_start: function pointer * @m2m_unprepare: function pointer * @m2m_stop: function pointer + * @m2m_output_ready: function pointer, check output fifo ready or not * @m2m_calc_out_len: function pointer * @m2m_get_maxburst: function pointer * @m2m_pair_suspend: function pointer @@ -143,6 +145,7 @@ struct fsl_asrc { int asrc_rate; snd_pcm_format_t asrc_format; bool use_edma; + bool start_before_dma; struct dma_chan *(*get_dma_channel)(struct fsl_asrc_pair *pair, bool dir); int (*request_pair)(int channels, struct fsl_asrc_pair *pair); @@ -154,6 +157,7 @@ struct fsl_asrc { int (*m2m_start)(struct fsl_asrc_pair *pair); int (*m2m_unprepare)(struct fsl_asrc_pair *pair); int (*m2m_stop)(struct fsl_asrc_pair *pair); + bool (*m2m_output_ready)(struct fsl_asrc_pair *pair); int (*m2m_calc_out_len)(struct fsl_asrc_pair *pair, int input_buffer_length); int (*m2m_get_maxburst)(u8 dir, struct fsl_asrc_pair *pair); diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c index f46881f71e43..296e13a16490 100644 --- a/sound/soc/fsl/fsl_asrc_m2m.c +++ b/sound/soc/fsl/fsl_asrc_m2m.c @@ -253,15 +253,28 @@ static int asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_task reinit_completion(&pair->complete[IN]); reinit_completion(&pair->complete[OUT]); - /* Submit DMA request */ - dmaengine_submit(pair->desc[IN]); - dma_async_issue_pending(pair->desc[IN]->chan); - if (out_dma_len > 0) { - dmaengine_submit(pair->desc[OUT]); - dma_async_issue_pending(pair->desc[OUT]->chan); - } + if (asrc->start_before_dma) { + asrc->m2m_start(pair); + /* Submit DMA request */ + dmaengine_submit(pair->desc[IN]); + dma_async_issue_pending(pair->desc[IN]->chan); + if (out_dma_len > 0) { + if (asrc->m2m_output_ready) + asrc->m2m_output_ready(pair); + dmaengine_submit(pair->desc[OUT]); + dma_async_issue_pending(pair->desc[OUT]->chan); + } + } else { + /* Submit DMA request */ + dmaengine_submit(pair->desc[IN]); + dma_async_issue_pending(pair->desc[IN]->chan); + if (out_dma_len > 0) { + dmaengine_submit(pair->desc[OUT]); + dma_async_issue_pending(pair->desc[OUT]->chan); + } - asrc->m2m_start(pair); + asrc->m2m_start(pair); + } if (!wait_for_completion_interruptible_timeout(&pair->complete[IN], 10 * HZ)) { dev_err(dev, "out DMA task timeout\n"); -- 2.34.1