From patchwork Mon Jun 8 09:38:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 6563771 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1D0A3C0020 for ; Mon, 8 Jun 2015 09:38:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4746120525 for ; Mon, 8 Jun 2015 09:38:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E5897204AE for ; Mon, 8 Jun 2015 09:38:47 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D2EC9260692; Mon, 8 Jun 2015 11:38:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5DDA12604EA; Mon, 8 Jun 2015 11:38:38 +0200 (CEST) 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 C47EB260515; Mon, 8 Jun 2015 11:38:35 +0200 (CEST) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0111.outbound.protection.outlook.com [65.55.169.111]) by alsa0.perex.cz (Postfix) with ESMTP id 4B4312604E1 for ; Mon, 8 Jun 2015 11:38:28 +0200 (CEST) Received: from CO2PR03CA0035.namprd03.prod.outlook.com (10.141.194.162) by BY2PR03MB285.namprd03.prod.outlook.com (10.242.37.16) with Microsoft SMTP Server (TLS) id 15.1.190.9; Mon, 8 Jun 2015 09:38:25 +0000 Received: from BY2FFO11FD011.protection.gbl (2a01:111:f400:7c0c::199) by CO2PR03CA0035.outlook.office365.com (2a01:111:e400:1414::34) with Microsoft SMTP Server (TLS) id 15.1.184.17 via Frontend Transport; Mon, 8 Jun 2015 09:38:25 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; alsa-project.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD011.mail.protection.outlook.com (10.1.14.129) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Mon, 8 Jun 2015 09:38:23 +0000 Received: from audiosh1.ap.freescale.net (audiosh1.ap.freescale.net [10.192.241.212]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t589cJci014651; Mon, 8 Jun 2015 02:38:21 -0700 From: Shengjiu Wang To: , Date: Mon, 8 Jun 2015 17:38:11 +0800 Message-ID: <1433756291-22999-1-git-send-email-shengjiu.wang@freescale.com> X-Mailer: git-send-email 1.7.9.5 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD011; 1:JIZUnvme6G1BzHkuoGfztANA62CiSUsIgXfh1BQIFBGiD5JLhxKof7hGXllbykAumCyGR9sDSilTPwVrfCsYjEubHBlm73O4TJF6I8dISpHcOboeebLPlXEtzYXiUHqRZtKNQR9b8sgotsJbXpTlSkZMIl35tz2hflUWOwcHyCCJt9+h9lQT+S1aOi42zGZpAPf11vOT6k15wGnfP1Yc/xp+avvDrschTBYFyfKhDlzBlKzJZwN7UaRk9IuSH8w7++C88UaGk6Mh7cZgoZwXbUZw92BNlsXKTvckh5MP4hkj9rNUDWuDTjYJkzgd6tlq X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(33646002)(50226001)(77096005)(229853001)(48376002)(106466001)(104016003)(5001770100001)(5001960100002)(87936001)(50466002)(46102003)(6806004)(36756003)(85426001)(19580405001)(62966003)(77156002)(50986999)(189998001)(19580395003)(86362001)(92566002)(47776003)(105606002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB285; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB285; 2:AvUwGN902+CF3gSTpjJcMJCTX009n9RX4PTL7JOXGtQfP0Muj9+M4YELpeJzCLTK; 2:JAysrRvEaVyxfBVjgnkX48M5KKMG9bBdJC5lKy9fQUdZjh4OxcWxXFL8bp0gjgPK56a57u/9amkgvVgpptcigwqR+Z5TUuLDN9ch15nFcw2cOpoPXoxw72gwlHCBrgAJV+U6yqVW0Dpb0xJc59XDLlNSCiHjBE0KdeJVjLzeSpXq4ZcTsJm8cTDMmFg/wOniGyJl41V1sOV2B6F9/CPJ0ukSAql7/jQdVaszzE3NGZw=; 6:SqgtSYWktV3w0LKKvbAYvab7OTFMxe0M6G5p4hbZ/CKoOH3NUSjNYDhlvivVjeWQGGzvIH1oRLY4c5JrtOiv9RkWHoA9lhgGoeNCAwebIFhQHUQkhY8v0sCBFIE/imzg9cS4SkeEq0ZFxswrjLihRldp9/m/Z2TypxPM8ywsz2poTfNB0Temom87/Q/yMvfXeW0d4b0/8FUGsxzpeDQSIQVaCF/jAxiFwzFwkml1fT8k5UbAc0AclhiL6cyVp3X0nAR2pvSwVDRCINJPVNoJAaOner3x0FCCGmnJUsqSqPewvggOjOMn9Cks5zPJBJ6xWoDH0MAAsmqx1O2cFNNMeQ==; 3:NY64EVnJdU8KchExC5lueOkgpsp5J8EfaR8OczTnsBsZJBfF9XcrJk4R/24UqdMfB2ze7arVl3T/KwqHTj5ngXX32PXcDW5JOYkKHn04G5+Scvcg3n6Dp+5SFjzpLGorVws/vdDCbbf/KxTolv71x5c+661niupjgl77+QOkJItfmuAnEmKbDe6lm0voIVN8bz2yOzUyu5/d8Z1uO/ltc36vN41rAcarxFSrPsYxJNQsM+AB/aYJCnWCdaePqJD8EwQSjnQi3sqYLSpKSKU1b1m148qYq7N+QmD/xbQj3+psLBD9Bk6UxpfTz196PD09 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB285; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(520003)(5005006)(3002001); SRVR:BY2PR03MB285; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB285; X-Forefront-PRVS: 060166847D X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB285; 9:1yI9wA2zhoiNnMc0Clwt5EQuf9cqhJwFdvoxo3JlKppSKQuyRfYLG839hKncb97DDullHw2n7Etox2CBpoda1JQocC5S1vxnJqgZ/4X0qKTK54k3cXL8y0Z2sSznlEgcCviFIod4vUwY3BpCeZYk/f6zH3VkIkvb7vOrUAc0NQ7Y2vQGUylhz6wj/2BiCBJpYdneLgRyU4wJLD1fYYvUmIAfuQEA+ZiLpwheIkvTEWG5bo9egMG4MIgTqoFIRm/ns3ZIRs4L+NkfZiM9vkRcwzYOGN3MG9+/2cL8KS/20//Mk2bS0xST8P+bDRlXIkAN901s104QV1VJeMfcyebA23DU+UcYK8DTlXPNLpVKYU6pq/QQGNma5I7c++zz3brVUTRXh+NMxu7E1mOjZqUicQPZo7jX9DA7SZem7lOaGTW/5sXCDQYR3HUFT+T9EGFGqwXJFOhB70StdBVznKQ0nW2MztPryZ1jlrHO5PZ9Yn6qPxkLnhlHFzCd4C1HGqawcsB2kZbNufd/LEh24NNapYSWyHyKg5K/2nUYBs8zQawWxj90QEY9skWxvf0O/3+5YLSMgCKP/OUq5tSK0EEjaSmUx4+u9yRM0BIBq7LQfC6efg4yaE21IwM38PST4kdfXzjDCRC24exLFN1uDPtNISMQwsW1s4Oc9+KDWoeIGkf5qQnkEuQP664UUOmjOG5Vc0fdpl53F6XVHjj5cwlXT/OBTQNzsuAtrPSa0CTuPVgVBWVSvSCOhSGu/PeSfbjQ8hlxLnk4vDkdfA87fhQHDoN0xvm8gTnwOqhizT5Z2EQ=; 3:iU7nLczScSfs5+C4zpudi8+hy8HoLv0swIvMfxa/rIr/eyF8pZg7BL7siDd2cHt+PpSWU2XO2WKQogRXx0x4N0tFIHr/1vYFexs0036TPrtkPvWHs4MW4G48Dyd+AsJ82BaCXuiDCiY2cFcwm1qvWw== X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB285; 10:afVaWraSgN2egeZ7HA4KVfMD1zricX5coDSekRnbZQ6R7YSqNX1OE0Tf1q8nmWvLoKFHefXU+lNwQwlFK+QgWHOxUWAfEv/75Ws4jH0E5CQ=; 6:8Gubdvz5J/1K78jLkKz6Xb4TVzfCT/5L47lZt2UdbrsB7GfGGMDAqi0g4YbWGA+g X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2015 09:38:23.9712 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB285 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] PCM: snd_pcm_dmix_drain() maybe blocked after suspend and resume 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 After suspend and resume, the alsa driver is stopped. But if alsa-lib run into snd_pcm_dmix_drain(), it need to wait avail >= pcm->stop_threshold, otherwise, it will not exit the loop, so finally it is blocked at poll() of snd_pcm_wait_nocheck(pcm, -1). This patch is to add state check after snd_pcm_wait_nocheck(pcm, -1), if the state is SND_PCM_STATE_SUSPENDED, then return error. Signed-off-by: Shengjiu Wang --- src/pcm/pcm_dmix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index babde6a..0cc318e 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -647,6 +647,12 @@ static int snd_pcm_dmix_drain(snd_pcm_t *pcm) if (dmix->state == SND_PCM_STATE_DRAINING) { snd_pcm_dmix_sync_area(pcm); snd_pcm_wait_nocheck(pcm, -1); + switch (snd_pcm_state(pcm)) { + case SND_PCM_STATE_SUSPENDED: + return -ESTRPIPE; + default: + break; + } snd_pcm_direct_clear_timer_queue(dmix); /* force poll to wait */ } } while (dmix->state == SND_PCM_STATE_DRAINING);