Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp446327ybk; Fri, 15 May 2020 05:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM3yxVRedoNuA3/7t1uDEz2yhlq2eaw06E0Igz8ByBDYcKVOLuzXbGPFvGFl7R9HBoKEI1 X-Received: by 2002:a17:906:1659:: with SMTP id n25mr2420996ejd.122.1589544276167; Fri, 15 May 2020 05:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589544276; cv=none; d=google.com; s=arc-20160816; b=EbOj0Xrk6tfzd2km5HbHtdzUpPuXMukkZp4mgiNTtcayenx2s+REYriUl5wcfkrJ3a NF0bIgBSHe3OLV728/AJ84HeRY1J08Iiv+EQF3toPEMC+hm3K4YGIFUihhR83UtSlou6 a4KVrNle2ZS+lPwWSKjkRV6hKKIJwnrJp/QgGM0wyJ/AzUMsS7syjUg1Ex66WeTNMoRT BApqSojriCykSah3hN/HpPG8Ni9paCJGwoyCdVLXieSJARgOkNY9ZjYkFfDNTIk08DVN ErIMT/V2McgYgVbplx5LEjYYfPH3xr7WfHautW149m6QFueGWz7dE+N6NTQXw1sO1jZY 9UmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=BSPQw7ZsQTM9qcuNnNNGa3TUk61bcBxmr+5Zb7SXb3k=; b=bJDv1/M5fS9qrCfLJwrOUlQeobaufcyV1ImmzO2lyIRia4YuXRwDGMCP2ZPWbC1A2R J3gDl6un3rzCy5Dor84xLVzIBz4NuJb1FkB3u+ILcT5Q2JmKeh/O1lHAbB3Ojbvp+QB2 o+GnAjzig1xCkykUqwB19kbrs4l8MidvKDTi3pM3m33F5joHAbNe1Q8u03Uwk2Um5027 8D+DDTnnpiv6onvRfVEIOp5fpJDPNGLSZDsxyJPoDZLPGI4Vwg6M+aCBh2H1VNZ3YtVl qDUWEBiHmeGEJulX+VE4IXxBaZiXGvmrjxJ5lGIojkxhVo5URAlGltuJpuqeCD0PpGSk D7yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=H1CM5bvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si985070edv.392.2020.05.15.05.04.12; Fri, 15 May 2020 05:04:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=H1CM5bvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726213AbgEOMCL (ORCPT + 99 others); Fri, 15 May 2020 08:02:11 -0400 Received: from mail1.perex.cz ([77.48.224.245]:45048 "EHLO mail1.perex.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgEOMCL (ORCPT ); Fri, 15 May 2020 08:02:11 -0400 Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id 17599A004B; Fri, 15 May 2020 14:02:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz 17599A004B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1589544129; bh=BSPQw7ZsQTM9qcuNnNNGa3TUk61bcBxmr+5Zb7SXb3k=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=H1CM5bvnktpNfAz3IAga9bNh/b2OcwZBtSlsVek+Ha8mJPsdnpDNGE801xj1Pdu+g IIFKpDBjbeD8swsnCxKfR7+K++XN9kzm18xEUl/OtM9U4rM03tPINQBhjvFPCNHzwO 17LkqcYiTTVRKQWLO+74MYTVT/6QMdTSUP5JXt0U= Received: from p50.perex-int.cz (unknown [192.168.100.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Fri, 15 May 2020 14:01:57 +0200 (CEST) Subject: Re: [PATCH] ALSA: pcm: fix incorrect hw_base increase To: Takashi Iwai Cc: "Lu, Brent" , Greg Kroah-Hartman , "alsa-devel@alsa-project.org" , Takashi Iwai , Baolin Wang , Arnd Bergmann , Richard Fontana , Thomas Gleixner , paulhsia , "linux-kernel@vger.kernel.org" References: <1589515779-20987-1-git-send-email-brent.lu@intel.com> <20200515070446.GA1226131@kroah.com> From: Jaroslav Kysela Message-ID: <6f98358d-99f1-3b54-ae1a-5e938d383c32@perex.cz> Date: Fri, 15 May 2020 14:01:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne 15. 05. 20 v 12:39 Takashi Iwai napsal(a): > On Fri, 15 May 2020 11:30:54 +0200, > Jaroslav Kysela wrote: >> >> Dne 15. 05. 20 v 11:04 Lu, Brent napsal(a): >>>> >>>> Is this a bugfix needed for older kernels as well? When did this issue show >>>> up? >>>> >>>> thanks, >>>> >>>> greg k-h >>> >>> It happens when DMA stop moving data from host to DSP/DAI for a long time >>> (> half of buffer time). I know host driver should do something about it. But if >>> not, the HWSYNC will keep increasing the hw_base and hw_ptr and confuses >>> user space program. >> >> I'm afraid, but with this code, you turn off the hw_ptr jiffies >> code. It would be better to fix the driver in this case (return the >> updated / estimated DMA pointer, increase DMA buffer size etc.). This >> "lag" is unacceptable. > > The problem is obviously in the driver's side and it's best to be > addressed there. But, I think it's still worth to apply this change. > > The hw_ptr jiffies check is performed basically in two places: one is > snd_pcm_period_elapsed() call from ISR, and another is with the > no_period_wakeup flag. In both cases, it calculates the diff of > jiffies from the previous update, and corrects the hw_ptr_base if that > exceeds the threshold. > > And the bug here is that the "previous" jiffies is kept as long as the > hwptr itself is updated. What we need is the correction of the base > when it really has processed the period size; i.e. hwptr got the same > value (with no_period_wakeup) and yet the jiffies diff is big. For > this check, it's correct to update hw_ptr_jiffies at each call no > matter whether hwptr moved or not; we need to evaluate from the > previous update, after all. > > But I might overlook something. Jaroslav, could you check it again? > The jiffies check code is your black magic :) I tried to imagine a negative impact for this hw_ptr_jiffies update when the DMA position is not updated from the driver and I haven't found any so far. Let's apply this and we'll see in future :-) And yes, the patch description should be improved (DMA ptr is not updated / streaming is inactive). Reviewed-by: Jaroslav Kysela > > > thanks, > > Takashi > -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.