From patchwork Tue Nov 16 15:21:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12622683 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 764CBC433EF for ; Tue, 16 Nov 2021 15:23:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B43961A64 for ; Tue, 16 Nov 2021 15:23:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7B43961A64 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E592A16A4; Tue, 16 Nov 2021 16:22:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E592A16A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637076228; bh=Vs+N7sq0do7XwpQFHAdVtHzWPm5XXnHcF4wX/An59Rw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rKvPG0T10W/oJ1FuzPDCs6LNEqSVtlgTvdEJModN/diP/A/MZ3TjkTIcwgTSAd9DH 5prH48F4Xjr28EsH8W3iiyfzYBB3LEuGVf3XoHAQG/9oeTB5M0jTg/4FO7gV9lL94q WotVEnawlcxKEELvDzmA770D1IEgYJsZOEny5fFw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D5AA7F804C3; Tue, 16 Nov 2021 16:22:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 23999F804BC; Tue, 16 Nov 2021 16:22:11 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0613.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::613]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1752DF80134 for ; Tue, 16 Nov 2021 16:22:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1752DF80134 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="Hf1qQgBq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PpxqxfR8QESpGOdnNkO6aOv86apio0ul58q4rEPh0MxDWPfrCUfGDHIcHuvKKyGhgd+SigsL35BNQZ0MqW3R7ayNNJj9o77HMaVVqJGo5P1RR2qSFtrDR5VZZqnbzEwqvDB2PDqB8MIE2A5zFiI0qg/JzY03BWPdIFWM7C/6ExCr5bjujLoRF3pea//N01UayIuTpaskfR8W7wLM7rtiDuun7xmt45LpDgxNJ2Pb/sp2hG1WzQsKhI9HiqNWH2ecenLR8ULZPfyhmo11wYpGr6v6+2MTuZU0H7hhIVvxFoewK9B8a0N/edEA8pOtLHxVIOkd/pjqk7NZYyaAuTNrKQ== 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=3konaJtcz55x7aht3QkCtIItCsufv6S9UWsCUk5a8T4=; b=ABKR/+3JzvkUGL9ChDTM/sLD7MIjr0RF78pUOIQAS41NX5OEaXc2oNlgAhTs0qhJCR3IeRgwWg1IUiSj26J8e6z/YDLGyusmdoCrxHW6UGhHMBgQI5/0dOxdYfJRnxWLFUSee12GN6mQNTntoXZ8V43brx3QeFkSvAVH2C++V0VSWdhKbvnKqeHXygiCjyBupmpBIeQ6QIMn5WA+nCLaZyiovrp+ZgOXVDiJYoP0KzM1yEPcoWCi5LdMOhjpaTw0NWXHlRYxQhLxsc3kQIRsx7TH5wqoFHTYfp6h1avdqS5sr9aVLDWJzmB3i2Cn11QgB6RlnLDhPcoZmwzdvCpQIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3konaJtcz55x7aht3QkCtIItCsufv6S9UWsCUk5a8T4=; b=Hf1qQgBqxvhbmiuDRu92vf5UvNbKtJqJ6+t5KJRn1ByV6S4PRdEKglTKkZ6IFE4quiz5Kfd3qj6/cIcK5CJeYnWMT6sq5b3CVKJMeOB8s9vv20duy1SPxoqYvC4EdyFCIloIH8Shmy2oB29nCpZ9hHGxFsMJoUIr/2Er2Yo4WsM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB6880.eurprd04.prod.outlook.com (2603:10a6:803:130::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 15:22:00 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Tue, 16 Nov 2021 15:22:00 +0000 From: Daniel Baluta To: broonie@kernel.org, peter.ujfalusi@linux.intel.com Subject: [PATCH 1/4] ASoC: SOF: utils: Add generic function to get the reply for a tx message Date: Tue, 16 Nov 2021 17:21:34 +0200 Message-Id: <20211116152137.52129-2-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> References: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:1e69:ee6:2dad:c9e7) by AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:21:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 622d9ce3-ca6c-464e-9adf-08d9a914d612 X-MS-TrafficTypeDiagnostic: VI1PR04MB6880: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kfp6f+hF94wquAsB75fAKk6s/XC6eMLLycufOldsAbpDxHdFQ3oLnBayLyPQ6E45gMOgjl0dRbAQHcz5c27jPtGz1N8SRfRdsZJRrNAn3ppkRvdlAtOKZpN++c+JJvDBhDWo4ES8ITpJyyEgWbgNqjcMCmBsnbj1iEAljRqoq7/DRWUOhvVfpxI19++rDKJo4o2jaWCMFqM3CxFCVe/IYFIDb1vtyd4pDrpw1PYuVo/J6sYesd01r1YCtYfnnGHrcKVi96pP5a9UvLELXCGellRZRRcDUEHDFNLSekNeMsp7kKS+WuHlaHdZod6Ii9xWRebO49q14oi4/n1hwl0XCkk+Epfy6WrL0HK2fpLRX+p/Vylrg4r4PgMXqdv+xdQw9Tm/Ni1vFo5SDZ4kvHMnIsbCW9zrxotfp8qj3ef1VXEUL9RR+4H7G1WAsixH7crFbOGyLRQv213beV5zE+s3Qf7Bw22BwnekmsAQw2qusbA6FtzUgy7fpwlMM2gTpvsXVCk+9d0roFS6ZvX7OwevNqAcFVWg/VUygdAmKEDeiyyGbOm4+f017noZ9XjXFGJysZ60aekLzu7i2A7j6T9zQBS9MhEO/N/yIrIA39GuQtIWZO0/poFVI0mTmhxo8W2t2WSwTNHl0bY4ACiKYfIZerVRWXlevD8TFg8+N2KeFg5t+lMGR+nHHr5VW8Z3cHRJT9KNVzfzeoUF90XFIkptHXAwKl9fdhTAqwsRdsSBLj8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(4326008)(8676002)(6666004)(38100700002)(5660300002)(8936002)(2616005)(52116002)(2906002)(86362001)(15650500001)(6512007)(316002)(66556008)(186003)(1076003)(508600001)(66476007)(54906003)(66946007)(6486002)(7416002)(44832011)(83380400001)(6506007)(41533002)(15583001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wr1Xp2ieUOguyqAnm/9NcIE1gh4xoCmg00qtckpmC0xLpS21pHXXtofpIj6MQ17l8dmnKy4lnB4P4WLegfxQcLOPTjS++evUbG+fgokpVdHvI/JlmNcPx6Oa7IsIw8aKyzmHdb1NKPlQEvUE/aXKuem58aVJmpZwEDz4jVp3sMkhVyGCrposewiHzYMQqSeP3hT/3gP3Y08p9zHmfPL2HlPAfyviUS7uFT+jPxK9LUD3dXX0nvN4VeJYXhvVud7T91xExvZtyM54Z7U1BKQKiPCnXCetdiHqVqQhmaWdi8tu3eWfBm//jTnLSuGhccquyIW2mCeXZ+XvqMfIOHuOyGSBIkbyF+IR0TshKMmBK7y9nbFESYVxHAedCEl89zqyhx/SP5JrKJsC1cBu3z6xrOnkMsgpLzen1QacShumjMRvoB4w8zgo2IxVlBw65lhCStvRxRit23MzOkRSRS8Gb3jlHqON327fxAffcoqdJsbowG6I6FOo3ppgct+lnVKqqBdtCipRg7yRrDB98Eh3JkF/01XFIQDGsQKGhLx6R0w/jD4DRcwp4Je2W1OkMKtSoElEuxOH+HQvL8hTuohnqpn8chwFoYfSvp6McQZsJ2F+gN6rdwdu3qt/VsoSm3ykyxGSZ2IXPvqZi8vmGkJGnIrskEJppVTKdkV0Oibn2N85zGk8bI/DaZ9oQ6Bnvf+TVQrpbAwI++fyER2Wa1UFyveFrJn/Dgmvj6cGTnJVqwtmNLK1TO+FY6WBDQKY7hP+rvIp5bpCYAAhTApK0+g95HYbuc4NCTvD7KzAreOXiyG4s1e05Xx/Sx33ucthYTQot+G8NYXNmsdsuB3RLgEnIsjKNwhVeXWaPl7YYyPuA2z/AhcvWQ2qkzVFnHxpXKRPbmaoGJqaMOxReUxsVsD1Pju8CkaRoGRbAyF0upcPG/sEaTS5SlT8nSEI36Dun9KShKyhhaG1OTQSoVU8KhcXfOdPNCCHlaT5xYnY3qxlM8HgK59yqXdGjyguJKbO7PP8KrFYXi0g6kraT5SJ/ccsMSTRomnuxHiXH+vGa7aBXMA/8G7keeOysJQJvX5e3oM5ZCe8ibvgybApAfA/hV4w8EigrLrN7dk5Pqb+hZtkSSmahFMiDjvUaiPNma0noklgaFyCy5dTZBItySbSE00PHm4zeSPFLLsgAndw8dBFYGN+p96f0RgkLj1W0P3LChMG/s+Z+Elt8FF8P5io5YNrmU0mY++ieBvBAAcCZa/VxP3htESqV93DrcKYHdgd7xoZgYeLXSIYDkrqlnHj+G27GxEVrcf8Crx9JPOrsIPHDhls3NEsQlKTOX0R7cx0KSmyQPJ8nULxhroeBgpGoEvNIzzjN4ZiNK48GTqb7NQOnpKlRE2bIYjpD5O+Db89kV7w+Pp9gkiahutjOHCSkUEGQAX8T0nAqvmbc0sWC2DV8JY0y7FLMf8zMEPUy47tCsyRfQ215tzmWh14JTWox+GJXIiCniAEj0qB4E+lUCzDAwoZTHlS4NqP7EoqcBxQWs3wfVY7ayup1iWQ8q4gScW3w2CEnB73XHV+NOy7KtVfhENJqaokgjDl6iEdmks0Y/QWuLx/C5KSC7tAvYXJmZQ/ZT/pm53Fvw86YCBm01RJNt9gcZ0+LtP1obh7giOhIfXH1+QdrstxXnQCMv+J6ua2z34F9PiD6Gbz5RFQjVqvyGI= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 622d9ce3-ca6c-464e-9adf-08d9a914d612 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:22:00.7488 (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: KKeTjgi7x8oEOq7SHX6vz33lwGonsDD0vWLqfXbLzOpW05r3i3dm/WdT2kKjtfTzp7FgUCyhBjf0FHrj6A0jAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6880 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, Rander Wang , linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, daniel.baluta@nxp.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Peter Ujfalusi The code to get the reply for a tx is identical in all but one place: imx8_get_reply(), imx8m_get_reply(), atom_get_reply(), bdw_get_reply(). hda_dsp_ipc_get_reply() have additional check in place for PROBES and special handling of PM messages. Add a generic implementation to the core which can be used as drop in replacement. The reply size check is changed to be able to handle cases when the reply size is not know beforehand (this is the case for PROBES and DEBUG_MEM_USAGE for example). Signed-off-by: Peter Ujfalusi Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- sound/soc/sof/ipc.c | 61 ++++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 6 ++++ 2 files changed, 67 insertions(+) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index a4036d0b3d3a..6771b444065d 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -394,6 +394,67 @@ int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header, } EXPORT_SYMBOL(sof_ipc_tx_message_no_pm); +/* Generic helper function to retrieve the reply */ +void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev) +{ + struct snd_sof_ipc_msg *msg = sdev->msg; + struct sof_ipc_reply reply; + int ret = 0; + + /* + * Sometimes, there is unexpected reply ipc arriving. The reply + * ipc belongs to none of the ipcs sent from driver. + * In this case, the driver must ignore the ipc. + */ + if (!msg) { + dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); + return; + } + + /* get the generic reply */ + snd_sof_dsp_mailbox_read(sdev, sdev->host_box.offset, &reply, + sizeof(reply)); + + if (reply.error < 0) { + memcpy(msg->reply_data, &reply, sizeof(reply)); + ret = reply.error; + } else if (!reply.hdr.size) { + /* Reply should always be >= sizeof(struct sof_ipc_reply) */ + if (msg->reply_size) + dev_err(sdev->dev, + "empty reply received, expected %zu bytes\n", + msg->reply_size); + else + dev_err(sdev->dev, "empty reply received\n"); + + ret = -EINVAL; + } else if (msg->reply_size > 0) { + if (reply.hdr.size == msg->reply_size) { + ret = 0; + } else if (reply.hdr.size < msg->reply_size) { + dev_dbg(sdev->dev, + "reply size (%u) is less than expected (%zu)\n", + reply.hdr.size, msg->reply_size); + + msg->reply_size = reply.hdr.size; + ret = 0; + } else { + dev_err(sdev->dev, + "reply size (%u) exceeds the buffer size (%zu)\n", + reply.hdr.size, msg->reply_size); + ret = -EINVAL; + } + + /* get the full message if reply.hdr.size <= msg->reply_size */ + if (!ret) + snd_sof_dsp_mailbox_read(sdev, sdev->host_box.offset, + msg->reply_data, msg->reply_size); + } + + msg->reply_error = ret; +} +EXPORT_SYMBOL(snd_sof_ipc_get_reply); + /* handle reply message from DSP */ void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id) { diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index ba341b1bda0c..2c97ffa98e3e 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -515,6 +515,7 @@ void snd_sof_fw_unload(struct snd_sof_dev *sdev); */ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev); void snd_sof_ipc_free(struct snd_sof_dev *sdev); +void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev); void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id); void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev); int snd_sof_ipc_stream_pcm_params(struct snd_sof_dev *sdev, @@ -527,6 +528,11 @@ int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header, void *msg_data, size_t msg_bytes, void *reply_data, size_t reply_bytes); int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev); +static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_id) +{ + snd_sof_ipc_get_reply(sdev); + snd_sof_ipc_reply(sdev, msg_id); +} /* * Trace/debug From patchwork Tue Nov 16 15:21:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12622687 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 082A6C433EF for ; Tue, 16 Nov 2021 15:24:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18B8861BFB for ; Tue, 16 Nov 2021 15:24:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 18B8861BFB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7180516C2; Tue, 16 Nov 2021 16:23:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7180516C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637076262; bh=xYfVZylMS1kJOqJESZx349Jvxdes3uKwGEmuwznAoro=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=a07hTCj0DuYDQsD1FCAJRYztzf8NWvt7+CjMw46zMN8AItC8aXhnnyTQBb3EaZYaI P/ucJ3o8V/RxSkHQDrVsTF2r4gU5aO+fga7YJ34pA1HCsfA1EJkX8kxzmpqORrDIRd yL4tEeogv7lku76SSv26YpCgkmMXR7fWJS75ZIhI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 008A4F804FA; Tue, 16 Nov 2021 16:22:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2889F804FB; Tue, 16 Nov 2021 16:22:18 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0613.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::613]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4E8AAF80272 for ; Tue, 16 Nov 2021 16:22:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4E8AAF80272 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="arxXVUG7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEkgF4l8uEpKouRPcbMiyI2KPaAMOdRf2zb3tmq0QMhLqyrCzaUoubkbZkvFoJ+dkHx0F3O8PJDgbaz2g5NVpGBRjhaHxUI+VUPCVlaxZGvDxVWiQUDQbnHGuf6WOX2htQe4SRTEdRgqmaTAC8OVHdxwPvRPhXMFSc5GI9mURnrzTBDauHxcJMFD6h+Ip1MqIKvPNO3TeNQl6taKZU3NA/dH2zfOtezw8krszXJtZK9BBpmaO4jIfGpOuStCQoaiCfRX0Y7Bbin05PVyRuY9aFom2dkRbTD1L/GF7gDQes2LJKlBIVEHUUnPY0cKbPA4wdbbwNH4IQbsbGuByVbm3w== 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=BCZouXwTxARtL61XltXgJV4Uy2gLPG6QyAVTnp5xgiM=; b=Aj0VWvHgm969h2JGcB4fnHd7OBUEBIREoVYtza2PReBzXQ+PMARQAjIpUjGpHZf/t2i8XTnTULTSHq4mfIfeAw9rJquSyKPngR93eeikx1plcLQ/unnO3N7z2vaBbSg//IBV15O/0lELQK2H/T8hwDHe9UqGl/EY2F/wVyPyDJ0GQWdfGLx+4yzwHL44HSaDcHoeu/mGk90Oye3K3/QiTfOYx3K1crtf8MmCtpHdJ7w/1lVJDhuObziZEaiVQ0HgWLLI9gqKbaJ6349y+R6dcMJYtftVijzpdJgzY7tJiLfpfA50N2g/1iVU61ozttpYuXwikKt0w7HNI1Lwkk4qPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BCZouXwTxARtL61XltXgJV4Uy2gLPG6QyAVTnp5xgiM=; b=arxXVUG7g7mg+lbPT/AUl9ygI9srypS8ykDR3cAro17nCHNjCAKuoncONTMQnd6dUbyyh3RBtIJtKKkl+nZQskr5D6IwmnHizrkmLRfEgl9r12C8EW7WubouNVH9EIk0oRZhwalWRwC/u9CVevE5GtzWQslD37qkfGEoAMlq5FY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB6880.eurprd04.prod.outlook.com (2603:10a6:803:130::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 15:22:02 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Tue, 16 Nov 2021 15:22:02 +0000 From: Daniel Baluta To: broonie@kernel.org, peter.ujfalusi@linux.intel.com Subject: [PATCH 2/4] ASoC: SOF: imx: Use the generic helper to get the reply Date: Tue, 16 Nov 2021 17:21:35 +0200 Message-Id: <20211116152137.52129-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> References: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:1e69:ee6:2dad:c9e7) by AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:22:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0404410-d5f6-47ac-1bc0-08d9a914d6df X-MS-TrafficTypeDiagnostic: VI1PR04MB6880: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:632; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9QO/LwXGfQmfn/fOfYKgQVRNwF2nyL+qVkVHMkZXdUtIEPItNNUNxIOLXB46mkTx9PQRT7jbSDgD3PgcsuLGGSQla4yDpV2AeUQE/gqQ+N8+YaS1hkGYSuEc1XJ3lIci+iAgNIzzoVe/QVJGMe/tlSMXK+hKcYv67VSCDgzr3IgFjeIRR+6pyNKfkcj6eJx5lTWwFCItDnSAL7YiASHTzmsTkWRpQkPmMiYnMyd0WfVldE9mjbra1XbbhJk9qIcYRyWdu759I+cBdshjnkXH7ktaCqwheJ6XaILdK+oVqHpnPBKKT/jlYyz+F8wDdWziX2pk02+Yo1dc2KGqCs5AqBbHvbMPGzGLgN9+Zy3TUAXZ78msr/CH92SDJIifgxS8fWrZpLfnryYzMiVQEufmQbJqAcZ10G8IcfmoawCXbR/GkXqt5d66qzNkbzmoOjhkp7KFN4DjGvhGgN4ajBIFPuqXs+qBvf5xsXJ8Zp+saGwplT4Iu/Kr8qzwYeXGo22aIxBHd0uO5He05C+YGc0V35ErMzl1yCo1uq1HFISM3hVNbottYqQ2yCNnemvkVX37uR6d/aRexXqMIvdflK+XNOWwpaO6Au9jhhWhQXQ7eUNf+R/FsVIYjrvv0v2tA6PhnnGuXGU824942TVGe3twpJJ0m4LRuM7IAdUU9cZx3YADJcL2ulvJ9KVHn2UwIiUXKpyY7lM7JbXqI/mKNmiCxdiJNFpOE5MjXdVgrX4NKBo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(4326008)(8676002)(6666004)(38100700002)(5660300002)(8936002)(2616005)(52116002)(2906002)(86362001)(6512007)(316002)(66556008)(186003)(1076003)(508600001)(66476007)(54906003)(66946007)(6486002)(7416002)(44832011)(83380400001)(6506007)(41533002)(15583001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LcVBJe+1ogOCG10hAqTXBLwiwpshQr6A/aEpw2B1fiGaxVj2EqdELcUEhq5fGNR0gzVGdDK4Np5xOoOClsvvHKGDBZls1NR/ZEciTFKyQNdB2HfMvzcnD+24w2TUo70ppGrT5y5+Q+hITxvbBbESbMJnk3EMhEgw+u8dIo7pm6hnB9afGmHlAvaLCEVzGdBFZiGLh4SJ4zWKtFl0EmXqQA9TzysM1mrmPp/gj1SDLfRoE7qgBgf7K7j2ACKJ/lkfhUtgoQmwL6OedFTqgk/JYm8EZnz4ialgNmtAySZD2bzIiIv8whK957NwLn4juEszrtgzS+X0QiTEDvURys+pkJnsbqnNe1JBBHu4fn7cz6Doa9I8Ri5c7z4woJ/stoO2v6qCCI6lfdn+UVhO1NxErhx9uMk07LcCfrS+5b8lzSRWlp++rnkAIZHYr2rOQshdaqDaKChMghbxktHw1d2W+GYY+73EuQKKX8YDIfoRsUvabsQF4DYMYU1iSBnIX+7Jder8GJOJjEmTJJax0T5olV8LTYWN9WjVYk24T81EW0tqnYCSIIidCJzboIImgnx2Kfc9S4BI5iA8ZqOH8d0wy6/sGD0FIpURj7ziX94D+C8OqQStAC1gJW1VU5KKM5tTCyApX3jqq3PmaVomfbXlEUe/F2gXiBcNp6kMLSV9g28Wf9IXQlSzaBIM4Ip1XynKf8Hqgsatre+9qtfKr47uQwZZWaMRnhZpy7Y849ppR6Zzcf2oKKIem3ZtRU3LFersjGsxH4jkDOAqAxQnVl4DXH2PF/ox+nRWRdjSdYUj3fy4USF+3csxtSCUFJJF+B5mMSv4hn9eTZvh4qmEqDakInTPtW2QaapLwvjrKZp7ftXsGY8H3z4YRmLx/rTWIaP7pjAfIiIh/+Cj+dedWpsAhHbVrtc90KIzeRGXTHWZA3b3GvY5PEY4MVtYlQAbcXb3haJ2NUd7AQ/7ygG9Rjnan/ez1/O88oo2wc2NX04uqFK1V6RnaHfmV3soliS2I9IF18/Mw3bDCAPfgg6afi6YQFHim3HYw1PosG4wFrLRe/4knxuiMxXRw6vCpuZzj7cPOGWLLpUADzs+x02/Y+XC+oKjYzTP9AMOTHL/Qs4mE07EGfM54/Ec52ZCUWvYBRuEBnQ4AxEBwD6dIhylxCWDPNPnRTi9iQNAqMlsWxE6F2MDZXcfC87gKc0HvjOiE/7OH/x8fdIvvneq2vMwubhp8PSihxIYKYvLmyqsxtcgRIfRn7ybVeKV0SM8S+s1vOLwgbt6d/JOZWT9XgUM8vyqZW9FT91kNwNnRi4cnzuw2REj/QT9eSsf3+i98IDgqm7u6/qYwwhP/wwaYVtzSlLCwt2YAxKIYsaLtb5KGdut8anKm0yQ2Cv4n0IzuS9COd/LVsTmbDVLd3gzTtPIlF0WuAdu0PBavf53fPnUaHnFlqIV84FK4ICaNQ2KKDV/PbV+bfzm4dCiHPrT9VyJllwWOoqCQyh6zSZrSaBWgjmFcgMytPzDvVF+2TqOfCD5STeHy+htjbv4qAc+YAo0XFDdt7OwcHOTyw61g0ofuDMKKOIHuO8wH3HUXvT6YjRJ4xFSuwyscF4NWOmYnWotYeLlTCmj7GiPlBosB/TEAZ82zUbMXYiLrHK1xYhZ3ztnpampB6D02aKowIslaCiEgL9+Fl8GwrXogIfWtQLlPTgHdNg= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0404410-d5f6-47ac-1bc0-08d9a914d6df X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:22:02.0590 (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: BmvZlCVtaKoJS6A6PZedvA8h8iEZUjiHvNixRZEGZAa2jDxOQfZsEvGCQcuU7huTLx5qfJVWcB6sL1D0o1zlxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6880 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, Rander Wang , linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, daniel.baluta@nxp.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Peter Ujfalusi Make use of the generic snd_sof_ipc_process_reply() from the core instead the local implementation. snd_sof_ipc_process_reply() handles the reply retrieving and the ipc reply Signed-off-by: Peter Ujfalusi Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- sound/soc/sof/imx/imx8.c | 37 +------------------------------------ sound/soc/sof/imx/imx8m.c | 37 +------------------------------------ 2 files changed, 2 insertions(+), 72 deletions(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index dd59a74480d6..0aeb44d0acc7 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -59,40 +59,6 @@ struct imx8_priv { }; -static void imx8_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply has correct size? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - static int imx8_get_mailbox_offset(struct snd_sof_dev *sdev) { return MBOX_OFFSET; @@ -109,8 +75,7 @@ static void imx8_dsp_handle_reply(struct imx_dsp_ipc *ipc) unsigned long flags; spin_lock_irqsave(&priv->sdev->ipc_lock, flags); - imx8_get_reply(priv->sdev); - snd_sof_ipc_reply(priv->sdev, 0); + snd_sof_ipc_process_reply(priv->sdev, 0); spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); } diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index e4618980cf8b..f454a5d0a87e 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -32,40 +32,6 @@ struct imx8m_priv { struct platform_device *ipc_dev; }; -static void imx8m_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply has correct size? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - static int imx8m_get_mailbox_offset(struct snd_sof_dev *sdev) { return MBOX_OFFSET; @@ -82,8 +48,7 @@ static void imx8m_dsp_handle_reply(struct imx_dsp_ipc *ipc) unsigned long flags; spin_lock_irqsave(&priv->sdev->ipc_lock, flags); - imx8m_get_reply(priv->sdev); - snd_sof_ipc_reply(priv->sdev, 0); + snd_sof_ipc_process_reply(priv->sdev, 0); spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); } From patchwork Tue Nov 16 15:21:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12622685 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18217C433F5 for ; Tue, 16 Nov 2021 15:24:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DE0361B3F for ; Tue, 16 Nov 2021 15:24:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DE0361B3F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E51AC16BF; Tue, 16 Nov 2021 16:23:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E51AC16BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637076242; bh=ZWUgoaBGfAxBCDa5uGD/+zQx9uQq5wHONW6X/9HvXDg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e5FDemDUb7LvCSGW2uP/3w6mdXZmMXaxTNkG7eCm4dhlGHgQKmGYGh6u9pVRlJ+nL ixnvRkvcQzYTfxBorIeE2ETu10efrJL7yt7xctrcwXfQkIA74aPfU9DXF0OTOIi3yJ rsZRYjUbA2gx3NWuCJvZWqQvldK0Rtxgwy7UrkFs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5D700F804F1; Tue, 16 Nov 2021 16:22:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0BD44F804F1; Tue, 16 Nov 2021 16:22:18 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 30827F8026D for ; Tue, 16 Nov 2021 16:22:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30827F8026D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="Js3I3KhA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ATEuHU2BCUJn0MdlfT+DOU1OlQZasWwGXh6UJL6lnq8fV+Hla77THVJZ5sN2Mf/tGbn+uPjuNPVE6i0exx0jGFh6rAN6OfPQRFq3NSlOAHfEWBinIZ9V33Cj4eFV3A+809LDi2hF7geXwk76wVIBPzPmgCxgaVD914DuDboSElUqDH2aVaezDZRnQV8Ah0WcLW3YV7rBuiXQtt+gmmxNRHMRGdYLkYm3lePdNszipA5dxPgKc9kfJaY0wfSwHHLXECkbXCUJnlkXg5Fyl9wi6YzhohfvVcW2zTGT7jufh2cblvbZz+PtX27vcArzVXI5jr4dZIFz2EAimE+GWW3CjQ== 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=+8EdpM2FkAotA9cnSb7oIgkVptpvsQJimq0z3jigbx0=; b=avFcWnDoCwPGXFXL00zQG6vaJtvtvwUU714Y3BSGetQxf4epz87kn8HbkkVmKZMlu/sj5PulkIsLcOk6lWSwHlysLny0O4vqo/024o9MbfNxq5XV7Lr3c91wy2eHyt70IS3uPF6lsxKImJ8zsNusI57lYGhR3VfeMA6GWGs8gG48ABZvJU1N1bBmecCvU4CmxEAXXcGHYMblA7T2SOBY4oyvAVtmGmi8b/Bcdjmd+3vPI1s+aEMs+xLsYryN1cH7oU5uHum6RlFqfKMsOiicg7bcWA3K9Ho7iOAkN0NwpKwXD3t5dFqb8EjdsDO1oeeRUUfm7MB7Yu8FJ/i96pCEXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+8EdpM2FkAotA9cnSb7oIgkVptpvsQJimq0z3jigbx0=; b=Js3I3KhAzl0HmYCphiLBwt7uxwxhckUdbEXYhlSW8TCcj7+eqORdQHfoNrrLBXHzsl7Dcno2YhTMadoBbg41hOE4bxsuKnlEQH8/QLy2zqNeGsdurTgzZToGbIrWIvpcdCFIGvwzE7g3JGQcb0sHPriyFAD2jDgkVkokTkwaHhQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB7213.eurprd04.prod.outlook.com (2603:10a6:800:1b3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 15:22:03 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Tue, 16 Nov 2021 15:22:03 +0000 From: Daniel Baluta To: broonie@kernel.org, peter.ujfalusi@linux.intel.com Subject: [PATCH 3/4] ASoC: SOF: intel: Use the generic helper to get the reply Date: Tue, 16 Nov 2021 17:21:36 +0200 Message-Id: <20211116152137.52129-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> References: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:1e69:ee6:2dad:c9e7) by AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:22:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 016eb0bf-0719-4e4f-9819-08d9a914d7ad X-MS-TrafficTypeDiagnostic: VE1PR04MB7213: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 39wUnKqRYR/zbM+WICSdGelFeZLJ84uFg26Bwf7U3Zm3gltXIpXzmo5Dgt2Z14TRQkRwtGiRS4ERlneXSX9sK9IhNghVFPDHvjHZvNZknMgGIgzup5QJ4LAClboE9f/hNgrlK6SepSuOsEGZpYkoUVK2IlgclhQuwMeLLHk48psQtrhNxTHJBDlr47LePCTSX3j7GAo1HPVFybHyuo69vkgOuHWAib+vZ8Jn29qFhRp+SwLui8LKI8dtBMjTFbQYyRQ5rMAFIT663OZcg+ztflY3/mGgyNwlDBRBg6vLB9j885aUkTBX6q3yGjmdRcMy0nAUEVAVufim+6lm5JzlCccfefzjpC6gkdhQrwAtf5xkrEK7/CtDgRci9M+fhP4kcd/ubm2Ena8uCSTcNUqjP9YjpPswswyyR0haDRLLI4AhVIGsgbJy2QtfBVQP8x3ECNJO1ozt0+9BMOK/NKLRlIfuw2TVLHnnkCxJGta8bkd97yCiLzXz1yupKX6oh1jNObfJSrkyJOhDQmGnLxhbsyO/iNZ+1gDarJhe5/1Ui+noTpsv8Ui4c6ArQLiWppsTR0m3vNacDPLrl16feh7VpwX0wRxZZgdhnL0m9lRt7aDR/Xk2Mzykxl3hibeqf2Tl+bs6SDFTKzQP3BnCHbrzP8OafbRcpLzwZE/Bv3oA3s32FJmO70EcCxz0Jvv3wB//V7iZLQGoCnLQzs9SOFECg0S5T9X2wZcFWZiYg3sBY7k= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(86362001)(54906003)(6666004)(44832011)(2616005)(66476007)(66556008)(66946007)(8676002)(8936002)(38100700002)(186003)(316002)(83380400001)(1076003)(508600001)(6486002)(5660300002)(52116002)(4326008)(2906002)(6512007)(7416002)(6506007)(41533002)(15583001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yWObRaPbjRzqudGS89SLd+Ak9KUgAmgaRYqJi866S5mfIudUgiOTbCXIisu/w5eEsHWZi9yyG6GaCGC1UWQRO9QdkzFmO7ZaoJJOApRMHJBkgL8+m9bkYT0qUGxDt26swfysHZHMm1Cos5w58Gjsk45Xx6PKI17i8JF53ZCv0cJmkCsSjIOdvjxEbqsRDiNwX8G2vqBFqJROS4kmSs3fkOYTst/7RiOySPcDeq8ugARxbRMXfzygfFVyTPXCDohhpVCNsOHd0Gkkv5FN1cGDXXQfeKu/L49nJiSuDGsMQ++Hpkg3HNdheGKt0KVfi/yQpR3dxFJdCMcGz2xakqC1A17yp4am9y+SVsA2rVK8p1a53yNEn9vj5E+P271k/7pfEWtzA1GhEUCtF66PXAd02KMYOmzYhSy5+kBu2BnkgR5JQwmfuz0qwUar4jARBUmN0P9m7wXvA5P2KuIePwogHiUuhYLpU833TpnTalyTf9+2t/cu4eb+J9hewQBhIHvBPqGgMWtEo2B1AvQruNADaQ0YSleu6YzCRphGrs0s8ThHWVVpn+n+cxEMHW4Wd3IKZBrb5Bn8Y5ckwACpbLUi3oMPcElbu/ZmXIGJIFIfVVk8BSB2/OX4YxjH5IZNFXb5KpurybCuczsYQ/h7+nOolY6xoJEMHHxU2Gs8dTId0pModQvkfVkiF3gCMnRf+wf12zPEN0UvY3SOiRTDIZf3VOij9IItL1j6PTSRns84BH9tR6m8Ub1kZiCsp121z1sdlSO+/lISRNJVDJa/JaeskjEmRjVxKiPRHChnhyZBfScBa3EJzVPqwqsjWwLy1+bll7Rya2SkwUXtASdwLPG/7EAhhgXkePz2jcJdeoyQBZ6HRE98lJN0Pq7Nskpff24oeq2x+S5nQOzwNPM+2dTKCT1jchZKToNcYDNa2nl1a2sarJ1FwfOdQO7r2VdX0tX3bFHYN4SgtBGr+fvQCtQ2PLr+f1xjprdYeubNrxBRlppfzHj27YTInRrJxnE+BqpbO8zJfCe5Xy5kNFbbUgGz9/TleCGUnXpANmB11O5jgbqIX6wdZEfYkdTf/yvyZ41grzVERHajfYwzY8kIT8D6HRehuG3XuljXg2Ig2RVUu+WGez1JvIuhLb1FmCJclFgExGw8NLc/JdMhMu+iTHtGGkTceMkEKVc9gkEjgUg4WKIB/NbZ3xAiEaGfQN2P4AM/PiWh3YReEHFJ7/L0WykRa+I3SVCnDOJfOO1qBMpsgzYjIferqchsiUFu6OsOcRxGD3FFN4hc2eJJ69jPTJsSoiEh+qkyT07FzW9hMjHF1TX5gNdlEEv1BHTWpYNhosCuwvEonXn0wTUIuOo+rwH87qAfl7f51mOnwmW7wfrll65RketzmwyIgwElTX15KC0/nzs17pTTB1Ox6AWUPTOb1mRLtX3EpxC6eSSVvNACKsRf0A9q/CMAEuyx4Yg1iO0QulgImEvHBZeBmRT5yVsAxCqZ1WTaN9r3uMK5OpHQw29UyLJk+0uMsYlZv2f1B6HJzHEA/iDSyNChoAK5Jli2u2hm9lnfPXGYJwKi/4BDCl4rm7HqBgf4utciewSS34WnAZ2MvABjoIyYgDyYG+9T0fpXU8d5nryuW6gftZzRu+dbEUAtzQjLOIHkH/eoIdic2VTTQBddUSCB3ceINL0lE38RuDgX1sMgQJJ8B6sk/85xQD8rGitzk1fNaoKkQiNz X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 016eb0bf-0719-4e4f-9819-08d9a914d7ad X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:22:03.4153 (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: a4kTggUeN0cASJMWKLRDQKa6dUAKmCuSGAL8jXjyZfWUhYDpT2gje2ZWGR0eiy9mRKBaToSBqWF6ULBQ+ynlBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7213 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, Rander Wang , linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, daniel.baluta@nxp.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Peter Ujfalusi Make use of the generic snd_sof_ipc_process_reply() from the core instead the local implementation. snd_sof_ipc_process_reply() handles the reply retrieving and the ipc reply Signed-off-by: Peter Ujfalusi Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- sound/soc/sof/intel/atom.c | 43 +---------------------------------- sound/soc/sof/intel/bdw.c | 43 +---------------------------------- sound/soc/sof/intel/hda-ipc.c | 29 ++--------------------- 3 files changed, 4 insertions(+), 111 deletions(-) diff --git a/sound/soc/sof/intel/atom.c b/sound/soc/sof/intel/atom.c index 74c630bb9847..cdc96a7df493 100644 --- a/sound/soc/sof/intel/atom.c +++ b/sound/soc/sof/intel/atom.c @@ -27,7 +27,6 @@ static void atom_host_done(struct snd_sof_dev *sdev); static void atom_dsp_done(struct snd_sof_dev *sdev); -static void atom_get_reply(struct snd_sof_dev *sdev); /* * Debug @@ -154,8 +153,7 @@ irqreturn_t atom_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - atom_get_reply(sdev); - snd_sof_ipc_reply(sdev, ipcx); + snd_sof_ipc_process_reply(sdev, ipcx); atom_dsp_done(sdev); @@ -195,45 +193,6 @@ int atom_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) } EXPORT_SYMBOL_NS(atom_send_msg, SND_SOC_SOF_INTEL_ATOM_HIFI_EP); -static void atom_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - /* - * Sometimes, there is unexpected reply ipc arriving. The reply - * ipc belongs to none of the ipcs sent from driver. - * In this case, the driver must ignore the ipc. - */ - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply correct size ? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - int atom_get_mailbox_offset(struct snd_sof_dev *sdev) { return MBOX_OFFSET; diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 2c09a523288e..156006bed017 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -75,7 +75,6 @@ static const struct snd_sof_debugfs_map bdw_debugfs[] = { static void bdw_host_done(struct snd_sof_dev *sdev); static void bdw_dsp_done(struct snd_sof_dev *sdev); -static void bdw_get_reply(struct snd_sof_dev *sdev); /* * DSP Control. @@ -326,8 +325,7 @@ static irqreturn_t bdw_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - bdw_get_reply(sdev); - snd_sof_ipc_reply(sdev, ipcx); + snd_sof_ipc_process_reply(sdev, ipcx); bdw_dsp_done(sdev); @@ -372,45 +370,6 @@ static int bdw_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) return 0; } -static void bdw_get_reply(struct snd_sof_dev *sdev) -{ - struct snd_sof_ipc_msg *msg = sdev->msg; - struct sof_ipc_reply reply; - int ret = 0; - - /* - * Sometimes, there is unexpected reply ipc arriving. The reply - * ipc belongs to none of the ipcs sent from driver. - * In this case, the driver must ignore the ipc. - */ - if (!msg) { - dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); - return; - } - - /* get reply */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply)); - - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; - } else { - /* reply correct size ? */ - if (reply.hdr.size != msg->reply_size) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); - } - - msg->reply_error = ret; -} - static int bdw_get_mailbox_offset(struct snd_sof_dev *sdev) { return MBOX_OFFSET; diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c index 11f20a5a62df..2019087a84ce 100644 --- a/sound/soc/sof/intel/hda-ipc.c +++ b/sound/soc/sof/intel/hda-ipc.c @@ -70,7 +70,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev) struct snd_sof_ipc_msg *msg = sdev->msg; struct sof_ipc_reply reply; struct sof_ipc_cmd_hdr *hdr; - int ret = 0; /* * Sometimes, there is unexpected reply ipc arriving. The reply @@ -94,35 +93,11 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev) reply.hdr.cmd = SOF_IPC_GLB_REPLY; reply.hdr.size = sizeof(reply); memcpy(msg->reply_data, &reply, sizeof(reply)); - goto out; - } - - /* get IPC reply from DSP in the mailbox */ - sof_mailbox_read(sdev, sdev->host_box.offset, &reply, - sizeof(reply)); - if (reply.error < 0) { - memcpy(msg->reply_data, &reply, sizeof(reply)); - ret = reply.error; + msg->reply_error = 0; } else { - /* reply correct size ? */ - if (reply.hdr.size != msg->reply_size && - /* getter payload is never known upfront */ - ((reply.hdr.cmd & SOF_GLB_TYPE_MASK) != SOF_IPC_GLB_PROBE)) { - dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n", - msg->reply_size, reply.hdr.size); - ret = -EINVAL; - } - - /* read the message */ - if (msg->reply_size > 0) - sof_mailbox_read(sdev, sdev->host_box.offset, - msg->reply_data, msg->reply_size); + snd_sof_ipc_get_reply(sdev); } - -out: - msg->reply_error = ret; - } /* IPC handler thread */ From patchwork Tue Nov 16 15:21:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12622689 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A302C433F5 for ; Tue, 16 Nov 2021 15:24:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B606061BF9 for ; Tue, 16 Nov 2021 15:24:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B606061BF9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1478B169A; Tue, 16 Nov 2021 16:23:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1478B169A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637076285; bh=R3TCTJ/XHELNVQADjItewi3qgAfiuoilhf1wJ+la7qo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ulYNv1MjhuOrqOlv24PrVQEjHHceUy9AsVnv8S1QzATuDiitDq/GIz7CvN+jkNBhU ecniN1lGka3zePVMpasfQSCzOOhZPHzr1opZOYk2jrbA2feFzq1ov0mqK6YNSGrbaX 8AASZaNyRaY8TXdXXI0FrLUVMtEoXGQmWWL/xZwI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A6747F80506; Tue, 16 Nov 2021 16:22:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E577DF804F3; Tue, 16 Nov 2021 16:22:18 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6C7D5F80423 for ; Tue, 16 Nov 2021 16:22:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6C7D5F80423 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="RU7WhU0s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YTWCBxVeuN0Blez+5F65mQaBAh92UIw+qhuVKm9HZHYpHPYkCaYE+73zeaOif5KsiP/DZLx02yShg46WHUQ7p5LiCe3oahEJvDMosiquopzImb6XzYUxS6u00wMQx4qYLfpb9YPxS0OBxIVlS4ws46nvritpb1AOBXy2bmNGKc6GsYIP6aeVrx5nsMwXJKu52+l+bZNTuWJ8375l8D4poNf0370oLnn/RobOQcGtUBajBCF4oZWXrFEos7AcwrNb2F+KBdr8/81Oz6JLA0Og5+nS/aMcdXWSR2M966+bBVnPfoWDDrB6C/GA27GayQBPZLrlj6VMY9vwa/jDdqqJuQ== 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=tvv/0YJKWYkflLH+1wJtCCao9SKMDhETORHXs0z0yfI=; b=Xu/qsl/RQBbCW8HaA0CJFKYr0ITG8dyUwo14SVk+QOUIag/2S2y8jG/9wEZYwzjIS3xY6rqApmjIVYjlX0P6xZeKp4BuaWPHZmj3moEfUbUEDouwwVlwchfMNpRUq261Jyt8jI/4k28WH8R3BJdEVKRtnpAI7F1cw5RSnwdCFeOfO9fm0dPZFZUzoJcPRqdWbj7V2bBQhVScJJikCx21SKkLDS2ahSDVgp5C8rK7v8J02QwEeRSj0HKeTA2VWkLpDeJo38k18TljeNfftUbpGorvHm5Q9MtpBwDB6ZyTfdkyhgM1FzWbU1OEVIGI1lj6F4nx2bLhmLUXkUZqDKRY2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tvv/0YJKWYkflLH+1wJtCCao9SKMDhETORHXs0z0yfI=; b=RU7WhU0sCylX985BARuiNBxsxhgmFFqktt5kipr6WvBrY+j78gY5BEJYG6Izbr0Z44OFyKkGOeGp5rBPZ1+Lu8tD9YOkVhbDOK8eeJeyHGttB9dIlIB7jKh+J22TBSp7kJVZwnhhe4Ke4yaaRMAnSp9SJ7WzPoUrRj9j3GxAT8Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB7213.eurprd04.prod.outlook.com (2603:10a6:800:1b3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 15:22:05 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Tue, 16 Nov 2021 15:22:05 +0000 From: Daniel Baluta To: broonie@kernel.org, peter.ujfalusi@linux.intel.com Subject: [PATCH 4/4] ASoC: SOF: debug: Add support for IPC message injection Date: Tue, 16 Nov 2021 17:21:37 +0200 Message-Id: <20211116152137.52129-5-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> References: <20211116152137.52129-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:1e69:ee6:2dad:c9e7) by AM4PR0302CA0013.eurprd03.prod.outlook.com (2603:10a6:205:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:22:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb3c13db-7e3b-4023-fd73-08d9a914d88e X-MS-TrafficTypeDiagnostic: VE1PR04MB7213: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:576; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qioCDHpL2+UMpyH5C8nC0SvIMt9pWqcxZ87AFnSpX1QuzHIitpZwp/W3Lq2RW3/3Z/uox70iZKrj0hiYnOVfTSjrq+XBt2At5bndGNCKCoEJroG/wP70WEHVPwTEzDZpz7qL1t3UbrnXn7oRTIudbLi4aQn6kp9QrEV07vpj5xCC6fRRyfoi1x47RpnhwSJDkB7LRzVifk08RerfBDnEnFKwqHx8u0mSVNP5nL/BXl6a6cLroEFw9i8GbBOdMnyR9q9ZbYwRw3OvHs5r7mmQV2abMrm06mHHkjfGowoduilqWGCOSV3wHui4gvyHAb4EFTXsrBxx1IG55XnTCainBmWE1H2PdsFFYyOQh1nEwavUzr8wQRCQ/jQHPYshuKjUALHyF+PIisOD3yuy38SW2xNvH06f/DOa2lbStG8SrU1qX/hKBDGGQPpPJTw+M8jNrowsjVJP8az9Ag6gsuYV1A+5Sph103KOGFKG5q8BQDPfi9KoyYNY+QwiA9Y4QgY7WpeFTcAjyfloqLGUxP0ig5mAUt/VsclOMysoPfi6Nzgz4vLHyO1muoVnB1i31fieirgrtzn8DsCTV7PeiJo+aurlYF/7FiKpMrbGDUdmpwQ9Mg7+sJ6hQl823RC7CxhakM9Vv1N4a3+fnsoGlpTBpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(86362001)(54906003)(15650500001)(6666004)(44832011)(2616005)(66476007)(66556008)(66946007)(8676002)(8936002)(38100700002)(186003)(316002)(83380400001)(1076003)(508600001)(6486002)(5660300002)(52116002)(4326008)(2906002)(6512007)(7416002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3GzETrlWWQ/x+j5OgVWdXdoo1UtQ64PDsHPE0N9qjShUN7vS8T3t24nBTWPBQBtgkaZ693zDsdYiDHz6uCYoVuvDVmLUI1K0ecsmbSbYyyIa3FguyAfrmjFD3ibQnFYk0AdkhU1TeR8HLnVfBre9qbp1F1st6w7/QjQfKO12AMLgtG9UIaiGVEteZ0jgbyVkYcbPX5z5XfjwiYUlrdsUKX3MP6YhVYdHsXobvaifnXVfCZPvnGilTLk1oHycmsE5jpUCbb0iSoa1275In/g5kb/3kMlowGNwG57nw1PYe//ypd4Hb7b/lBvKmsd6Q/b4a3ebBDmgVpEFAQ2cVnnoqcalSMnspmt9L/0Ms7UVFcbBbLxuJpJRrDk+G+ygvEYBCHFiQZSnZbTaItn/ZB67Tx18EtPr5a5NtD7UPN+RP0cw6mf3HOeeqPP+I7sztz2QOK0kOV1lbkHF9NU1biud41iVl+Je75OSIdciwojiQ8pvY9k1uVFvnyGsyJ8HwGNtEzjeMw5FHkJxRrOwPrfUOEXEKzhz69SLA7ZbdEBShL2udNmee46hD6hOvAGwQQAwtzF59MVTU29e3mhC9xLWK0l/y/TmjM97ALWQaa0/mquCJ6c+PlZuxe/p+UG532Q2IhVptKdzoiLwFVFqKnHl4FOCq4lyCIeM2BP+A0vTaW44640aJy6UqxfgW4tpf0XAdi7A5DmLv7Lomn8Ixe6gwgScm3b6kn3ctFYhMSRyY61lC9UazrAyugZgYBFy3y21/wp1gz5XF0ulz6o876Y0Bybtd05mFlT7h5CrpSMgnSTFu+S8pN0Q/vrRzYmxl09l7vIdDfchNz/C3iFRLZixDJ4s2yt+fepfFCV3z675DtgGeVRkXg5D7UB3vgNfd5/M9++FMDWItE0ySNu7gvn3M6iB4wfw8ybu2EC4yzKLABa+BTE0TucovPuUs2GDyBT/Fl0cSuse0QCZzlKT7hJvjc+TmDrzlSdbN+det28QAk7ckNWCz/xhk7fV95bU2S+EUW0dGET6wdUgMijaBj9OEQymdHlWnlUWB9k5cSoLEfQQ7aNu7WQd9mVMZKjs4A8Hzb63Vx22RUvtz9j4Hat3+uvIGLN63fWgubhb6aLy98wI7D606tMVVmgg6+NbUCgmA8Z/iNsDeXWmA6+MZXZOIijYmEPPA3BDkQE5E/Ku58aRChmMWxzB0+cMhlBa3M9WMGXeUL3VefJDyccUONFHaSP1MTAssJNN8F5jLB7swpVNdUrHmeZ7jX6sDE8GuufOLYOgyHqTI/Qz64e8c4h7HVB5Iz+UfMAGxbidwthZoc4r9WfEqM7BUZgyquBZjxcLBuLsCbqXzpYol6hRGd8KbmRqD26FhGhTiEQw5HivdEc7yLCQrgKmt5fhHQaw6p0qWaFx18+QBKUQ3L+9rZDanx08kdueIethC5dEgR+nGXluQJKYUmSnIsgpWyxRR2ia+1/wXuY7xZLrB1Er8TmRqvpl5IZsERLL3D5wSSebANo6iiwq7OHGCzErq0aYRJ/TLmoA6HLO81CMjmAoUfApn+gu+bh9lWMR1ReHuF+hwPoS5Owb8oiKgh40Fbjb26uO1M8woARCcSJP/bZMt9Qr4MA8QN1uwEHqkSZ0RX8qVcZYMDcRRz55St64bQMZLFySfSEnVIMC/5JGdqIJyviXwAAmCosqI10dMMar6Uj2DL2IsYpri8CLZhncQ8YVi3GM X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb3c13db-7e3b-4023-fd73-08d9a914d88e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:22:04.9164 (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: lSCCyrA3xlAfyoiwvV3hEFUaicMOBgkAEyNEh7De8FPOAr2hTfffLmCHrVbG7ZyuEtg7kAKBBI0iBwUVYz+NhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7213 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, Rander Wang , linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, daniel.baluta@nxp.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Peter Ujfalusi In order to stress test the firmware's ability to handle (mis)crafted IPC messages this patch adds a debugfs interface where a binary file (message) can be written and the message is sent to the firmware as it is. Read on the same file will return the reply from the firmware if it is available as a binary. Signed-off-by: Peter Ujfalusi Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- sound/soc/sof/Kconfig | 8 +++ sound/soc/sof/debug.c | 107 +++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 4 ++ 3 files changed, 119 insertions(+) diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index b6fa659179b6..89eea5558190 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -194,6 +194,14 @@ config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST Say Y if you want to enable IPC flood test. If unsure, select "N". +config SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR + bool "SOF enable IPC message injector" + help + This option enables the IPC message injector which can be used to send + crafted IPC messages to the DSP to test its robustness. + Say Y if you want to enable the IPC message injector. + If unsure, select "N". + config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT bool "SOF retain DSP context on any FW exceptions" help diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index dc1df5fb7b4c..2f8b5ac9b78a 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -336,6 +336,104 @@ static int sof_debug_ipc_flood_test(struct snd_sof_dev *sdev, } #endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR) +static ssize_t msg_inject_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct snd_sof_dfsentry *dfse = file->private_data; + struct sof_ipc_reply *rhdr = dfse->msg_inject_rx; + + if (!rhdr->hdr.size || !count || *ppos) + return 0; + + if (count > rhdr->hdr.size) + count = rhdr->hdr.size; + + if (copy_to_user(buffer, dfse->msg_inject_rx, count)) + return -EFAULT; + + *ppos += count; + return count; +} + +static ssize_t msg_inject_write(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) +{ + struct snd_sof_dfsentry *dfse = file->private_data; + struct snd_sof_dev *sdev = dfse->sdev; + struct sof_ipc_cmd_hdr *hdr = dfse->msg_inject_tx; + size_t size; + int ret, err; + + if (*ppos) + return 0; + + size = simple_write_to_buffer(dfse->msg_inject_tx, SOF_IPC_MSG_MAX_SIZE, + ppos, buffer, count); + if (size != count) + return size > 0 ? -EFAULT : size; + + ret = pm_runtime_get_sync(sdev->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(sdev->dev, "%s: DSP resume failed: %d\n", + __func__, ret); + pm_runtime_put_noidle(sdev->dev); + goto out; + } + + /* send the message */ + memset(dfse->msg_inject_rx, 0, SOF_IPC_MSG_MAX_SIZE); + ret = sof_ipc_tx_message(sdev->ipc, hdr->cmd, dfse->msg_inject_tx, count, + dfse->msg_inject_rx, SOF_IPC_MSG_MAX_SIZE); + + pm_runtime_mark_last_busy(sdev->dev); + err = pm_runtime_put_autosuspend(sdev->dev); + if (err < 0) + dev_err_ratelimited(sdev->dev, "%s: DSP idle failed: %d\n", + __func__, err); + + /* return size if test is successful */ + if (ret >= 0) + ret = size; + +out: + return ret; +} + +static const struct file_operations msg_inject_fops = { + .open = simple_open, + .read = msg_inject_read, + .write = msg_inject_write, + .llseek = default_llseek, +}; + +static int snd_sof_debugfs_msg_inject_item(struct snd_sof_dev *sdev, + const char *name, mode_t mode, + const struct file_operations *fops) +{ + struct snd_sof_dfsentry *dfse; + + dfse = devm_kzalloc(sdev->dev, sizeof(*dfse), GFP_KERNEL); + if (!dfse) + return -ENOMEM; + + /* pre allocate the tx and rx buffers */ + dfse->msg_inject_tx = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL); + dfse->msg_inject_rx = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL); + if (!dfse->msg_inject_tx || !dfse->msg_inject_rx) + return -ENOMEM; + + dfse->type = SOF_DFSENTRY_TYPE_BUF; + dfse->sdev = sdev; + + debugfs_create_file(name, mode, sdev->debugfs_root, dfse, fops); + /* add to dfsentry list */ + list_add(&dfse->list, &sdev->dfsentry_list); + + return 0; +} +#endif + static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { @@ -812,6 +910,15 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev) return err; #endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR) + err = snd_sof_debugfs_msg_inject_item(sdev, "ipc_msg_inject", 0644, + &msg_inject_fops); + + /* errors are only due to memory allocation, not debugfs */ + if (err < 0) + return err; +#endif + return 0; } EXPORT_SYMBOL_GPL(snd_sof_dbg_init); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 2c97ffa98e3e..9a8af76b2f8b 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -325,6 +325,10 @@ struct snd_sof_dfsentry { enum sof_debugfs_access_type access_type; #if ENABLE_DEBUGFS_CACHEBUF char *cache_buf; /* buffer to cache the contents of debugfs memory */ +#endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR) + void *msg_inject_tx; + void *msg_inject_rx; #endif struct snd_sof_dev *sdev; struct list_head list; /* list in sdev dfsentry list */