Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6772269rwn; Tue, 13 Sep 2022 08:49:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WTEaKdKsfgKjFuW1igeqI8NIDc7aGG2Hd/i2I1gHwhJxUr7miiWvKBq5R0hEUUjdP/tMn X-Received: by 2002:a17:907:2723:b0:77c:8beb:643b with SMTP id d3-20020a170907272300b0077c8beb643bmr8696477ejl.86.1663084186296; Tue, 13 Sep 2022 08:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663084186; cv=none; d=google.com; s=arc-20160816; b=VrHJeNUbLKT7RlV/Fz5ELJxdDy0go4x7Be11Lmy8YPTXoxwQAQ91YCZFvbkL2f4XMQ LR/vjinkpDJcCma5wP21u7a+Sc28RHW+BpvhtHRqjDAo7obSv8Ofm701BfyPUaZI2rk7 3x9vEyPK1VcIdiUsrUC++hPuCVxTMpC4JlgEKKQRu7/Ru3YhURuaqDi3mBD63vC9btab Aya4eSCjtwjgwQFe8prc/1+AWUeCVuHWTqbUPaMKcUoh3eSqK5ibTt4FoNPeQTZiEyL2 UhwPjp3BR/xebRCbpZkGG1ECb0VJ7xiStlBk+3I6+KrYGXQgyDecylQyCUofFXW+evSF qTFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dhmdV2VmCe4YvekZfZOMhJSaSG/QBVkzlel/E+vRYrw=; b=rVUMLe4Z1LFYPb3vFehhlncdhtbRLxoQDYGv0dxCzS0s9n5CoVjj4+hIEciCTvymWl FW0VHVgfnN7mppi5PyWl15Trw2x6UBpHni20Qo1sgcvqlv3QpxG4yKUfLbihYKQnhq/6 EW3onP3iFoYYuaWVjU3Mn2ubhjJoVAEqBxg3uOf8EpVS93SZUku9aLOdqmMvUIcvLmBO HAaShTEMzABnFzNdfyVHSMu5/8vJnLMTV+vGpduLgeyfp8iEOS6ibDvrrynwptV3UhMm yzt6lXyHi56O2pg0pMqhd+g1lgIM+iMGOazUWwWxoVZmE7uceA8H1Vr0uWxVVzpZYuTi otCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RBuQVhVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs16-20020a0564020c5000b0044e6731ad3esi868594edb.400.2022.09.13.08.49.19; Tue, 13 Sep 2022 08:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RBuQVhVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233831AbiIMPW7 (ORCPT + 99 others); Tue, 13 Sep 2022 11:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235899AbiIMPWR (ORCPT ); Tue, 13 Sep 2022 11:22:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A56D7C1CD; Tue, 13 Sep 2022 07:36:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3FC89614C0; Tue, 13 Sep 2022 14:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50318C433B5; Tue, 13 Sep 2022 14:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079711; bh=c+8isZ6YTFjQhAE68z6WOk1AgkqlsJDOpn1OWpRm7yg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBuQVhVxt5cI0/Vw2sIypmb2xpvKCM8n4Dof1BXIZwd00S/eptn8Pga4eyuyu4+H4 5Kl/0J4mukJ92YZvhZry+jYmNOPzkKehcq9rcVj82W5qu01LwEqXPEJHyVC/ojsqyp DImCPvokHwsb8JSz4EgaO282u5+0SOpSK5aG/XEk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pattara Teerapong , Takashi Iwai Subject: [PATCH 4.14 45/61] ALSA: aloop: Fix random zeros in capture data when using jiffies timer Date: Tue, 13 Sep 2022 16:07:47 +0200 Message-Id: <20220913140348.726635924@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140346.422813036@linuxfoundation.org> References: <20220913140346.422813036@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pattara Teerapong commit 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 upstream. In loopback_jiffies_timer_pos_update(), we are getting jiffies twice. First time for playback, second time for capture. Jiffies can be updated between these two calls and if the capture jiffies is larger, extra zeros will be filled in the capture buffer. Change to get jiffies once and use it for both playback and capture. Signed-off-by: Pattara Teerapong Cc: Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/drivers/aloop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -477,17 +477,18 @@ static unsigned int loopback_pos_update( cable->streams[SNDRV_PCM_STREAM_PLAYBACK]; struct loopback_pcm *dpcm_capt = cable->streams[SNDRV_PCM_STREAM_CAPTURE]; - unsigned long delta_play = 0, delta_capt = 0; + unsigned long delta_play = 0, delta_capt = 0, cur_jiffies; unsigned int running, count1, count2; + cur_jiffies = jiffies; running = cable->running ^ cable->pause; if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { - delta_play = jiffies - dpcm_play->last_jiffies; + delta_play = cur_jiffies - dpcm_play->last_jiffies; dpcm_play->last_jiffies += delta_play; } if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) { - delta_capt = jiffies - dpcm_capt->last_jiffies; + delta_capt = cur_jiffies - dpcm_capt->last_jiffies; dpcm_capt->last_jiffies += delta_capt; }