From patchwork Tue Nov 28 04:43:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 10078659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30DA3602BC for ; Tue, 28 Nov 2017 04:49:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0543229163 for ; Tue, 28 Nov 2017 04:49:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED62429169; Tue, 28 Nov 2017 04:49:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E8329163 for ; Tue, 28 Nov 2017 04:49:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AEAC8267630; Tue, 28 Nov 2017 05:43:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6A6DA267638; Tue, 28 Nov 2017 05:43:09 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0080.outbound.protection.outlook.com [104.47.42.80]) by alsa0.perex.cz (Postfix) with ESMTP id B91FD266F03 for ; Tue, 28 Nov 2017 05:43:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oaJFXKsaSvIHmWPtPySr9ZARpDYo6zKjqfrMS4SN5kw=; b=zpiQQjBSoq8UdajPXHBbAHqr+fYPMuOjOvQ+FXzz1wQDFwv9x7ASCZlrqe2m1Holki4PCGpM/IuGjSRoC/c/7QjEU5l6LgtDLTKSbLIFrYzCA3a+dVjnmy8Dy8SNbl5MHczq78yxjMQDBlgh+AA40RT96P/v2k1j2Aw6Xrp0fTQ= Received: from MWHPR12CA0029.namprd12.prod.outlook.com (10.172.49.15) by DM5PR1201MB0059.namprd12.prod.outlook.com (10.174.106.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Tue, 28 Nov 2017 04:43:00 +0000 Received: from DM3NAM03FT003.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by MWHPR12CA0029.outlook.office365.com (2603:10b6:301:2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.260.4 via Frontend Transport; Tue, 28 Nov 2017 04:42:59 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT003.mail.protection.outlook.com (10.152.82.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.239.4 via Frontend Transport; Tue, 28 Nov 2017 04:42:59 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 27 Nov 2017 22:42:58 -0600 Received: from SCYBEXDAG03.amd.com (10.34.11.13) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 27 Nov 2017 23:42:58 -0500 Received: from LinuxHost.amd.com (10.129.12.246) by SCYBEXDAG03.amd.com (10.34.11.13) with Microsoft SMTP Server id 14.3.361.1; Tue, 28 Nov 2017 12:42:53 +0800 From: Vijendar Mukunda To: , Date: Tue, 28 Nov 2017 10:13:44 +0530 Message-ID: <1511844224-32404-1-git-send-email-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(2980300002)(428002)(199003)(189002)(68736007)(47776003)(8676002)(4326008)(81156014)(81166006)(39060400002)(77096006)(189998001)(50226002)(356003)(2906002)(7696005)(53416004)(110136005)(97736004)(16586007)(316002)(305945005)(53936002)(51416003)(54906003)(5660300001)(72206003)(50466002)(48376002)(50986999)(101416001)(106466001)(478600001)(36756003)(86362001)(8936002)(6666003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0059; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT003; 1:CPUPwcDuYXGxzxK2V32tkGLGW+JN+6YLkP/hqqX+NStxsnxWADC9yp/OwzZa+Yc0qpTUAdIr1xxpg3A+lMjacEFG+AE1fjOMJWmv2giqU5gFRMxdBWEaDiwQD0sRlZIj X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6f6cecbd-8f16-4de9-3a39-08d5361a8085 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:DM5PR1201MB0059; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0059; 3:bY+BG6wvaU4LiMf/f+YSoX3MwHWvEPthfV3ZjYfkqgk9qPTU3sjbw2wjmbDIXqtchWWsmi1j/4osRYPmYcTIMW/48JTEnWjc6eGwIVSdPz7VzsaFJZ7LoLao4IcQxhxXtWIPauOhYnlvH2p4WFZfBUX0kY7n82sYeNn4QQDVLQIONcWO7n71f9a5b6zskp/gkON6ow5oT3E638bIT+M+VyY6wpPAA3xf0I8XUeKOxvEMbjorss4fUBaLvOddqL5D+r4CMl8lVUV7T6PmCyRKELSZ01uPY0R+bOGvx0nRFbG99YhAGLk9Btg2PNMIW5tZOOTw8RikWpUHaSFHF95udJNUTxPIKnI9K+WqYwz2qxc=; 25:mvcMY3RModAyaC6og/CIfKzdpLFGFQDY/RSlagWWHJV7eJELlTc9IMfw0u5UMwsrJRppndbgJA96dEiDGi3u16RNc6Hh+s609BsjK4QrOMxkUKNjk/DXWGSlgyZMcmyXdiNt4C08jJZJZeDK6I+Vpi7IORXE60ESu/+yr0/Kv1kRT4izEHuN3C5WC56VcmNRAHySfrfb3gK25K6Iby96RoSpbGD8xbNym4pKmyf8Ns0bbKGNFyRDjgBpYrSk+ROiH2C2N9yJDDeJvfQ7Z88YiSf55QPX5ys2f3pmghH7yeQurAk9JsGbY0NnLI0aIYuJfM2NDOfRNbUPHCvrIohUmA== X-MS-TrafficTypeDiagnostic: DM5PR1201MB0059: X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0059; 31:MLjdpvNF9+UiX0knzmVa/pyQWwdozxJeBwbdXfgSLkzEBleakUHdMyujxQ3DRQgBjcw0LukZ7dqSbi3tjCzz+tqX51JyAWpgKOXNB0gJi+4R3YN1eFrmTXXkUSjdx9c4GlOgQDjHUS+d1tQ/gwW/MlV2MiumifXbCACjSYG5ZX1YYgxxfdQ6dI6Y1QKcOaRHFD4x+MH4jKK/RuYFOVdYqmxecDxZdAmMUwMuc4GfWoY=; 20:Ec22A0uaEOthmbU9m1AY8HB36g0S+HHxkXGWZ9DLIPYfLmmADU5acMWCPntiXnNRGif9FNoX3uHbAAA5d84+K4QXmNvUQ14pneuNJJ1BfJhibK4RrERGh0HTELDTiwLnpyAwHVFC/PMRI/Tpk+xuSNZT6Y3D9NC6Tm93kxQE86oU59+j5l7Z0Opn1MeI/x5AElQ6tc703XvKhYuBf9Phih3lVu2UXdxQWc73x2FWskojUFWbALd0ahScc+1x5hJV/spYT36UIoBEwI4NGqzc7fKkRTa8tikNPk3tcLJ6tvF2x0goE9J2ZTBoJLhNb/HRiaCKjvkkagvy0IQvN+87pPmaK/oPfJ2GxLV3zTbqAHq+nxRkuQ8NIY5SJ75ZffaygZytHJpixNGFvnGw1m67+MhkcdG6KsSpLN9Xu8I0wVaP9G0ZvHjGDfpAVWWfe6goYKLQgQfdSCMLrSaitKoK/FEeDtaNFYDHRe0bvjvwPxzROpIXxvyxdpxFbgUkEEHb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93003095)(10201501046)(3231022)(6055026)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011); SRVR:DM5PR1201MB0059; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR1201MB0059; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0059; 4:N0muHW45LCZDIbxycuc2ovpg6mr25Tr9ry4d37qQkDXnZXFG+aFzlBnPuDhaYALLcfkB4Fg7ax5OnYyyaljbw0ll7OuUN92hJBdDuz0+ba9NRnoSSTtkrQP042d3LJsvI10Mg+rkrH7pQTgCfqbgc/MXCSpJ4gerWfkxCc0paGt9r6ziOLOCcRc1R17drVVETGLN9dYCuRNcZIYd45F6Jqw0SuZ2V6tVg/p71n/5Ne07nTvFWmt7N5tWSr/nrEPGCMFSvrvmbRMHYPBoY7WcrebazAsc+jxNx1U1vc1NeRPPze05fwg8zB02iEf5mqQ6 X-Forefront-PRVS: 0505147DDB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR1201MB0059; 23:kHR66Tr9natLT3/fhNiX60hAspBXKY1B0VRyJoX?= =?us-ascii?Q?21sjZA2OXsKHy7hWDlwqvs7NN0LEAhpszX5ayodazXgHt0ryOnpSMsocR79l?= =?us-ascii?Q?8ND1txEbAxwrGuvoSo+6MAGy6FNgO+C8mmj5RZb3X3Mcc3a5hmlhcQ//mZuW?= =?us-ascii?Q?W5NIh167WKJaGNlwKyYougATPDtdjnrAykAS7SH1WFmpQ57fjkWivZSWiYkf?= =?us-ascii?Q?2+6A9cZmayjZdJmJxRmFOrWLwLHbbIucVat0LJ4QgO20zU7D92ZefThYUAt7?= =?us-ascii?Q?yqkbRGtCZ3ZLvEN+vziWCa+OmS3VP7tdpku/xGNG/AP1HZ2P7xWdAtOX5BxV?= =?us-ascii?Q?DsT0p16evAWeD8rxF9NvacXCS0jUmUQJOw4LWGchpYlxDh2CA1UPmnDpzoz5?= =?us-ascii?Q?7IQcWbGZ1rzpzjhBj6x8bLGvZacY9omF3vZa3f8OTb6cyoKc5btolUhBqTq2?= =?us-ascii?Q?GplIeqe4Lxll72HvvFvzp60YZsYMMO3OtsIo5sD1ZW5wBKXWNCMa8qwQvZJT?= =?us-ascii?Q?foCoNJn/OMa24GvcWaW6JE1Fgv3SJLPCVvUREawmm1ZFQgTxNxBcelflKEC7?= =?us-ascii?Q?rQGsUK9kXiLKPbQevteYPipCr8qN05/8y1raj2F/IfCoRNhNPnt363j7YB97?= =?us-ascii?Q?dwhicbh/7PyHgbQ0PNNWWTO/mob7aEt102MzHUXemtIlSOttSjVhskKmz5NV?= =?us-ascii?Q?g0tbYjH7YcV3XZiiy/HRijnartm4W+krOKSr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7/1pnql/QVVxr6Ic46Iwz0sjUHshKT/rXX0LOxNR3mYuFvzr7PIbWyL1sJJh3sd4A3vEPsKpTB7GW/1Sp6fMREjkBHDsuYLF/bA0axzvxIT/FgTLdCzUkEr22rHkk9HyhSUpVoGgCmuJje6ySRH7Ogx5AekPZr9cKo3kFxzk75ZM7k2vKAd3/yprzTgnY/iJqnVYZ12gcAF9Qxc/Eih4GKcIWhxPKUrDJfnPsMlOzvidJApNoopoajBqR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0059; 20:BPrUlSi+h5/k/SdKH+uG/h+MFkQno45nIedHfzyzMMAantWlMoWNb6hqqNzVEZYp2NWbhA8Xkt1QF+mFd/wWvxk2wk/l6PE376O2Qap0hNrRw+2sa5ISpoR5xP+Kqf29qb1UGo9S8LHYpfBCTwHon2a/ELa0LDSRoWmPOv4GnOPvdepB5HLlPeYhn7V6MMfzaTsKKgXaollcZeWHCSJ6rAoMqPQgOsDd9GURsvEy6+sJgft6RNOE1A0mYgJ12Vmk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2017 04:42:59.3245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f6cecbd-8f16-4de9-3a39-08d5361a8085 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0059 Cc: tiwai@suse.de, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, Vijendar Mukunda , Alexander.Deucher@amd.com Subject: [alsa-devel] [PATCH] ASoC: amd: added error checks in dma driver X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP added additional error checks in acp dma driver Signed-off-by: Vijendar Mukunda --- sound/soc/amd/acp-pcm-dma.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index fb09578..71ab5b5 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -848,6 +848,9 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; + if (!rtd) + return -EINVAL; + buffersize = frames_to_bytes(runtime, runtime->buffer_size); bytescount = acp_get_byte_count(rtd->acp_mmio, substream->stream); @@ -873,6 +876,8 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; + if (!rtd) + return -EINVAL; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, PLAYBACK_START_DMA_DESCR_CH12, @@ -1082,7 +1087,11 @@ static int acp_audio_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, audio_drv_data); /* Initialize the ACP */ - acp_init(audio_drv_data->acp_mmio, audio_drv_data->asic_type); + status = acp_init(audio_drv_data->acp_mmio, audio_drv_data->asic_type); + if (status) { + dev_err(&pdev->dev, "ACP Init failed\n"); + return status; + } status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform); if (status != 0) { @@ -1099,9 +1108,14 @@ static int acp_audio_probe(struct platform_device *pdev) static int acp_audio_remove(struct platform_device *pdev) { + int status; struct audio_drv_data *adata = dev_get_drvdata(&pdev->dev); - acp_deinit(adata->acp_mmio); + status = acp_deinit(adata->acp_mmio); + if (status) { + dev_err(&pdev->dev, "ACP Deinit failed\n"); + return status; + } snd_soc_unregister_platform(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -1111,9 +1125,14 @@ static int acp_audio_remove(struct platform_device *pdev) static int acp_pcm_resume(struct device *dev) { u16 bank; + int status; struct audio_drv_data *adata = dev_get_drvdata(dev); - acp_init(adata->acp_mmio, adata->asic_type); + status = acp_init(adata->acp_mmio, adata->asic_type); + if (status) { + dev_err(dev, "ACP Init failed\n"); + return status; + } if (adata->play_stream && adata->play_stream->runtime) { /* For Stoney, Memory gating is disabled,i.e SRAM Banks @@ -1145,18 +1164,28 @@ static int acp_pcm_resume(struct device *dev) static int acp_pcm_runtime_suspend(struct device *dev) { + int status; struct audio_drv_data *adata = dev_get_drvdata(dev); - acp_deinit(adata->acp_mmio); + status = acp_deinit(adata->acp_mmio); + if (status) { + dev_err(dev, "ACP Deinit failed\n"); + return status; + } acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); return 0; } static int acp_pcm_runtime_resume(struct device *dev) { + int status; struct audio_drv_data *adata = dev_get_drvdata(dev); - acp_init(adata->acp_mmio, adata->asic_type); + status = acp_init(adata->acp_mmio, adata->asic_type); + if (status) { + dev_err(dev, "ACP Init failed\n"); + return status; + } acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); return 0; }