Received: by 10.192.165.148 with SMTP id m20csp4174211imm; Mon, 30 Apr 2018 13:11:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqaImrHXcffQqo3LDnFw9Fj+znkJYwQGomeYFHYNvM5VyQleAIWebR1DG4+7Rq3keoOAuwh X-Received: by 2002:a63:6584:: with SMTP id z126-v6mr3347121pgb.168.1525119092948; Mon, 30 Apr 2018 13:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119092; cv=none; d=google.com; s=arc-20160816; b=fha7bhy49xuGoI6+7lDtkk5cuMsH6fECwri86QD3hu9j0LoaJ8z/bppqiomWTFSNJS vQU4uHVRfsoHm4JgI0tR5h7lz0hv7TeDF0GlipNDzVl9CwhA1V+ozt7IgG1tRcw4/2Ni o3/gx5+ZYRmagGT5CF5qnztSp9l3epytC6OaxGpPh/dp3HQOpMS8Fg8+v5nkcBXWIE1w VnBTMJwYZM04/dLcS/PTLr9qmwHB9Qt1BbYYPX+39Waoth5NWBhSXvUfysR6PfmwCFj8 6ZMvgXKeR1ALMhoFlQSnnmsNMP+XWfXhvayAWZIBETloH2DVJ3kfnjf5zGkBg1YSEB16 70zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=V5XRDg4yJryQhM9joMsG4dEhM7BttmM9TxqqJ8Ftruc=; b=C0qYDI0GH8jlHM43NuHO+23QnLOWlwX8e6/HSK8hd2a6RXi21H9o9w0JEuP2lV+Puc 4QKh0fw1ba0ahMAYvdPtAbxdjlTQ9K9+8EDhFWmj4SyqbCW5Ni7n/ScaAvpN/ReiI9fE 9s2pMUKtib4PQlrTN4Y+vyi+Xspg2Jnl1DuyEH6zaAI9P1AKtRxW80DzZ4v2iDy+tgxP eqkpo72N3Lf4dmfDVdJ0ecVDUTZulqpRu2+VLjfAxUSJK8CJusrvC4OQmWohT1LrPjXx H5TZKFbZ8JoeIIvMD0eiU8ajeiFxueSwF/bxVg3nbmlyLgzVAnhK/iRknF9EvjIjALih +jJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k70-v6si6652725pgd.22.2018.04.30.13.11.18; Mon, 30 Apr 2018 13:11:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932189AbeD3ULA (ORCPT + 99 others); Mon, 30 Apr 2018 16:11:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:33526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932152AbeD3T1P (ORCPT ); Mon, 30 Apr 2018 15:27:15 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E31222DCB; Mon, 30 Apr 2018 19:27:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E31222DCB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffery Miller , Takashi Iwai Subject: [PATCH 4.14 42/91] ALSA: pcm: Return negative delays from SNDRV_PCM_IOCTL_DELAY. Date: Mon, 30 Apr 2018 12:24:24 -0700 Message-Id: <20180430184006.379687812@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeffery Miller commit 912e4c332037e7ed063c164985c36fb2b549ea3a upstream. The commit c2c86a97175f ("ALSA: pcm: Remove set_fs() in PCM core code") changed SNDRV_PCM_IOCTL_DELAY to return an inconsistent error instead of a negative delay. Originally the call would succeed and return the negative delay. The Chromium OS Audio Server (CRAS) gets confused and hangs when the error is returned instead of the negative delay. Help CRAS avoid the issue by rolling back the behavior to return a negative delay instead of an error. Fixes: c2c86a97175f ("ALSA: pcm: Remove set_fs() in PCM core code") Signed-off-by: Jeffery Miller Cc: # v4.13+ Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_compat.c | 7 ++++--- sound/core/pcm_native.c | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -27,10 +27,11 @@ static int snd_pcm_ioctl_delay_compat(st s32 __user *src) { snd_pcm_sframes_t delay; + int err; - delay = snd_pcm_delay(substream); - if (delay < 0) - return delay; + err = snd_pcm_delay(substream, &delay); + if (err) + return err; if (put_user(delay, src)) return -EFAULT; return 0; --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2689,7 +2689,8 @@ static int snd_pcm_hwsync(struct snd_pcm return err; } -static snd_pcm_sframes_t snd_pcm_delay(struct snd_pcm_substream *substream) +static int snd_pcm_delay(struct snd_pcm_substream *substream, + snd_pcm_sframes_t *delay) { struct snd_pcm_runtime *runtime = substream->runtime; int err; @@ -2705,7 +2706,9 @@ static snd_pcm_sframes_t snd_pcm_delay(s n += runtime->delay; } snd_pcm_stream_unlock_irq(substream); - return err < 0 ? err : n; + if (!err) + *delay = n; + return err; } static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, @@ -2913,11 +2916,13 @@ static int snd_pcm_common_ioctl(struct f return snd_pcm_hwsync(substream); case SNDRV_PCM_IOCTL_DELAY: { - snd_pcm_sframes_t delay = snd_pcm_delay(substream); + snd_pcm_sframes_t delay; snd_pcm_sframes_t __user *res = arg; + int err; - if (delay < 0) - return delay; + err = snd_pcm_delay(substream, &delay); + if (err) + return err; if (put_user(delay, res)) return -EFAULT; return 0; @@ -3005,13 +3010,7 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_ case SNDRV_PCM_IOCTL_DROP: return snd_pcm_drop(substream); case SNDRV_PCM_IOCTL_DELAY: - { - result = snd_pcm_delay(substream); - if (result < 0) - return result; - *frames = result; - return 0; - } + return snd_pcm_delay(substream, frames); default: return -EINVAL; }