Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6830251rwn; Tue, 13 Sep 2022 09:32:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ogka9iNv8UgoJN4V4nxrMznNqetF/JYaiS2o51SeF+UwZT0OVO1ox021HLFP8xfoBEN6Q X-Received: by 2002:a63:1051:0:b0:434:b4ff:11e9 with SMTP id 17-20020a631051000000b00434b4ff11e9mr28471007pgq.377.1663086725806; Tue, 13 Sep 2022 09:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086725; cv=none; d=google.com; s=arc-20160816; b=Z/zpmrU2ddBkGWX/qRv7U6+Y3FKqGILK8Gc/3FlEPMGui1+qVmRVfW9gq/TIW3DPi4 F8GdIFRdOTIOddRzeCpqGtdXEw5ZRjYxTTEyB9Ys8V0NqhrAM4kqCZzTjW9pTrA9/57q q78aAo0a3e4CdqK1/bjX/ZpOXo4mkpGy5sT0pSsUwa6eXgPvYk49eviuBarUM8tr4a7h xx3PKwiye7Ix5InRH/ogYHeS2p6s4dryIyT+58nTDKpUsTguglO770kr+QDGgcPEnc3V moyEraSMudoLUXlKKnLI2ZH8aeLLraArJAouUafzbf7noS3NjDEaGbzu/btYlbINSCMH 7psw== 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=owcJt1tTD/22hZvLfh08UnwyT4tF5SduHN+1/WRZ8YU=; b=CgNKApO+IXpjLsWctCxUbyqfxpKDlz7fCElTbEo0FjGlbBYsqVXadynm90uCgevKRX xmmu+cLpFWU1FPZhvAO64YoUzohKS/vvE3kAMvqgkEYlFCT9AsuCH+77PdXE15FwOvZ/ a7H6WRX43aJgzCDBbwc3J0JVOz+4Q68Fl0C347lSlUAPWkrOnrHXzLdOeN4LZbMO3sNS fsx6J5M22FCuIt3XwthX6m/4vkJVPutejdWBDT2yc6VNf6UBNdWR07k0jfNK+QFGSbJ0 P6Ly7BODoQppbShRRJ/3Aofu4RAexphBEB0zxEHIck2I813cOT8TckQ8llOn/iH25Zzv L6aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dHN2k/4G"; 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 t17-20020a056a0021d100b0052f9293affcsi12445876pfj.335.2022.09.13.09.31.47; Tue, 13 Sep 2022 09:32:05 -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="dHN2k/4G"; 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 S234939AbiIMOyb (ORCPT + 99 others); Tue, 13 Sep 2022 10:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234491AbiIMOu2 (ORCPT ); Tue, 13 Sep 2022 10:50:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB38726AD; Tue, 13 Sep 2022 07:26:11 -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 C32C0614D0; Tue, 13 Sep 2022 14:24:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37A7C433D6; Tue, 13 Sep 2022 14:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079043; bh=8PuaP/incUVIAeBANDpRL8XFoyJ5zftOBkXkgOQ5REs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHN2k/4GcygoLHvEATDN/GwOELRwxg0MkccwfEf3FEohNVJ1znnvnEJ7wq3IPU3jp nnFVUa2nosM9UinEsxUjL6TwaWC1NT3AdQGhHQih1mi9e237nY7rZdF2l6mIfwieLH ljU9aGzAbiXfCBzitoXLEtPkJrghNf2osxkb0i9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pattara Teerapong , Takashi Iwai Subject: [PATCH 5.10 25/79] ALSA: aloop: Fix random zeros in capture data when using jiffies timer Date: Tue, 13 Sep 2022 16:04:30 +0200 Message-Id: <20220913140351.513272951@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140350.291927556@linuxfoundation.org> References: <20220913140350.291927556@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 @@ -606,17 +606,18 @@ static unsigned int loopback_jiffies_tim 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; }