From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66AAEC433EF for ; Thu, 23 Sep 2021 16:04:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5026360E9C for ; Thu, 23 Sep 2021 16:04:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242463AbhIWQGM (ORCPT ); Thu, 23 Sep 2021 12:06:12 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35450 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242373AbhIWQF6 (ORCPT ); Thu, 23 Sep 2021 12:05:58 -0400 Message-ID: <20210923153339.623208460@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1632413066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O+eQk8u/ka3YLY7XRsH/AdQMs3q0/TK+//yr5k43qZM=; b=hxjpN/fiZbguPl9Ugg65t8iJZTEsptDGMcYbmqKyyQqUZErlcTJjInhjJrseUFfLcOoDSp G2niHC+tL3UzXtQuTpwFxOXt2Q6neXbVG3aOc6vPVXtNw/Ro1yajganewAkrbSNHcu0gGn FjIkTH9axPhfftmx2JEXzLQrQ+70wHAxyuXYnUlIdCozG0KEURa4sT4ibF2yLNCb846Eu7 wiqsA4UCpBWn29ZfrG1C7eNrOG3mFAlq6VMcX/avs/F48lcrmkdykByrTj9Z0g7WhjP8c+ 5m/SfPlXJ/rtnoyQ+d6y5e+A7YRZACPydJnqJ5bJMh8LlGOfvLZ69J5OYO+8Aw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1632413066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O+eQk8u/ka3YLY7XRsH/AdQMs3q0/TK+//yr5k43qZM=; b=/pakvF5tifiIv5hz720qFG+huSlyRoYiz+DD/cB0haV8bNXI1S1moBtwGCqa0PZkpLn5UW lRfXFWWZtlU8b/DA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , alsa-devel@alsa-project.org, Takashi Iwai , Jaroslav Kysela Subject: [patch 04/11] ALSA: pcsp: Make hrtimer forwarding more robust References: <20210923153311.225307347@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Thu, 23 Sep 2021 18:04:25 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hrtimer callback pcsp_do_timer() prepares rearming of the timer with hrtimer_forward(). hrtimer_forward() is intended to provide a mechanism to forward the expiry time of the hrtimer by a multiple of the period argument so that the expiry time greater than the time provided in the 'now' argument. pcsp_do_timer() invokes hrtimer_forward() with the current timer expiry time as 'now' argument. That's providing a periodic timer expiry, but is not really robust when the timer callback is delayed so that the resulting new expiry time is already in the past which causes the callback to be invoked immediately again. If the timer is delayed then the back to back invocation is not really making it better than skipping the missed periods. Sound is distorted in any case. Use hrtimer_forward_now() which ensures that the next expiry is in the future. This prevents hogging the CPU in the timer expiry code and allows later on to remove hrtimer_forward() from the public interfaces. Signed-off-by: Thomas Gleixner Cc: alsa-devel@alsa-project.org Cc: Takashi Iwai Cc: Jaroslav Kysela --- sound/drivers/pcsp/pcsp_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -143,7 +143,7 @@ enum hrtimer_restart pcsp_do_timer(struc if (pointer_update) pcsp_pointer_update(chip); - hrtimer_forward(handle, hrtimer_get_expires(handle), ns_to_ktime(ns)); + hrtimer_forward_now(handle, ns_to_ktime(ns)); return HRTIMER_RESTART; }