Received: by 10.192.165.148 with SMTP id m20csp4154750imm; Mon, 30 Apr 2018 12:48:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqnAtAvVgqUgGscr0vsZ32JIxLHnQV6ZhQgF6Ww7nL88SIfw2i1ls0XvX053d2Rdfzm1tnB X-Received: by 2002:a17:902:4483:: with SMTP id l3-v6mr13705734pld.282.1525117723975; Mon, 30 Apr 2018 12:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117723; cv=none; d=google.com; s=arc-20160816; b=QPTXFJH33YmRy/1Vw+X88agVq5tzjtWSKaYYHforHti6OvsBBTnMBlXBQpzZAaErj6 P+XRplpJzDrIyNXEPqZ4B090X1W3Uz/d9/um9UcucbwrO75Qx/4djWzQrTxFvqrhS6G7 npaAd6yvHi5kNQA7ZWp5EJkozXkIjJGi/tI6uSpDGLCMZqWZgzcpdx4PozVvvcEXYDWh kvf6k3CpkOKEed5DYl6QDWcWuENtgoIin5VaiLLnL08Xo0ddYqRqk4uZa5EYQu2YXiu3 V9wOvUNbO3WaoY8sRrDlnIfhXmfezcAS8D+yEEgLuBOAOhc++WKfsVEqhBAxt60ncBG9 x66A== 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=EEORpjBbA404ctVRJ/0C0YgG5deoIM3OCXU0ixSeQu0=; b=gpLndE7Cn9Mm4WdymdgRVtcN7r+QlXD8u6JdNbjgGNI9B/ky7wcUt8jXz7iZV/UXlz cj+OTxaf9Oamtt4P6fhmTvjXnG3ukaPXMragEPdjuV8Von0dblSCY8QTP9SoIG53Bq+z IJYNuiCYg2OuyqEQbAY8btZsx4zeXt9XisSxKpn8NkS1BCzy44yK+dFsvj0Qkp3B3zoZ T8eVJA69GWeZCJlusqfXVNKO2ZBlz7zfytmHi7hPJ9B9EqD66pCfyysayH88p5XRT1EQ 8/m+fkUaUAGiLxkBSURf3/N/Wgky7DdHl6Ia60cAwEeDYolISNthpblLGDKi7q6DB99L CB3w== 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 h22-v6si7870480plr.207.2018.04.30.12.48.29; Mon, 30 Apr 2018 12:48:43 -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 S1756257AbeD3T2R (ORCPT + 99 others); Mon, 30 Apr 2018 15:28:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:35758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756241AbeD3T2P (ORCPT ); Mon, 30 Apr 2018 15:28: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 55AC622E02; Mon, 30 Apr 2018 19:28:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55AC622E02 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.16 046/113] ALSA: pcm: Return negative delays from SNDRV_PCM_IOCTL_DELAY. Date: Mon, 30 Apr 2018 12:24:17 -0700 Message-Id: <20180430184016.993790918@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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 @@ -2687,7 +2687,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; @@ -2703,7 +2704,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, @@ -2911,11 +2914,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; @@ -3003,13 +3008,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; }