Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp359215pxb; Wed, 6 Oct 2021 06:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynS3YlXMSiAIBW6YV0sWsuOLTQ0Y/rR/IaoaM40hdys/Rl33Ohgk+8CXTJ3IKW6DzjEde0 X-Received: by 2002:a05:6402:d52:: with SMTP id ec18mr19407150edb.67.1633527274604; Wed, 06 Oct 2021 06:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633527274; cv=none; d=google.com; s=arc-20160816; b=u84K9+/GWSI8RfsYQ+IeZXkmQnh5biY+HSXMZYq1JM9MFW/tWxjzEWqRSM9xlpNKPT LhpKvdEOzEyMRiof3aV+os/5uoiw9d2aP6TVvfCST8fcGNQ6TN23ae8PV37BfNXKgVj/ oUsV1LF+SspkJbh3ZyGJhVn02aL0Zt0+hn7CZPwtiNS//K+BEytjILlRMYR+Eac8ccAO V9BVksX3GqFKB7wfzHqpM7SWN6XQcuNXQWfb8GyvX2gcMq8zXW32YMYclPsdZqvsc4l8 et3kfqUV5zZ7HTGpnPl9Ii9HGOjSpBDjRPpnIRgw0swejP4x5Paq9ru7keBKHSTh0IQR Y5Aw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OXoFA5/T1q/Asa8jH0TXn1g6+gBRv7CfUzgca0lrxB4=; b=Wi2PI1s+lrggTo3CybGF75RDer4SzqrYXuMACWx+3Qw5PrJSn2Xdq9BbaRH/MLNEEM 7URC0i/gmoWXb55pBrPjhwRm7jEB33waLBp0EaLAgufMhQTqiIftlDqUl/mBpZvywWZ4 mN7vnT5+dmYsxlosrTXDoLzWvv3ley/PWalMeLV5Tbigv+ZHWRdzwDb4BbG+LUCuBvaV h/0sT8jD6MaQIPXHhXqa8BbQrkFE6SHhcKURlB0FM/MePuNGdik+HBkHmJjaqCYOjmkt ix2OmcrSKu0nRSZTqyplGDl9hpXVbooWHqcuZKl90QHagUGqvnRtNuSImtC198Tnsq/6 Shgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nNld3sJI; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si25729003ejh.227.2021.10.06.06.34.09; Wed, 06 Oct 2021 06:34:34 -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=@kernel.org header.s=k20201202 header.b=nNld3sJI; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238749AbhJFNcf (ORCPT + 99 others); Wed, 6 Oct 2021 09:32:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:49154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238847AbhJFNc2 (ORCPT ); Wed, 6 Oct 2021 09:32:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91DD460E9C; Wed, 6 Oct 2021 13:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633527036; bh=3bZ0l2e9fq6OQbxRWcrK/pEDNJzTx0y2BSzq7eI+KEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nNld3sJIUXGyRvGzUAx41o8O6FBZyvnwk3d+TTaRE4pPNKjlilRevs2TXWtPRFPT2 +98Ixwh+hzuSNNNAFSLolrcKZBJsD0m/QXe7bIL1OQWyKvgHp1TCnJU9vLL25H6EFj 5o8HOas3ahEfeYMS85qoUqH+M4wNI49TDMFSDDwY9N2jjUkmiUsFkQH9+Ad/4Y4D0A RseYFIrsPqAyENcz2auM1oxfqo2PbXeX2OpOdBoFNs5jRYXSZQ1+P+Bnx4EfJr2Kic JA7lnJMROVRBjou/hoSlnyN1IFyKYeqT30oGFjxe3fTrl4mOQxSDIgEXMaKfyfunL5 NUtVvC0n7J+Vg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Gleixner , alsa-devel@alsa-project.org, Takashi Iwai , Jaroslav Kysela , Takashi Iwai , Sasha Levin Subject: [PATCH MANUALSEL 5.14 9/9] ALSA: pcsp: Make hrtimer forwarding more robust Date: Wed, 6 Oct 2021 09:30:21 -0400 Message-Id: <20211006133021.271905-9-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006133021.271905-1-sashal@kernel.org> References: <20211006133021.271905-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit f2ff7147c6834f244b8ce636b12e71a3bd044629 ] 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 Link: https://lore.kernel.org/r/20210923153339.623208460@linutronix.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/drivers/pcsp/pcsp_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index ed40d0f7432c..773db4bf0876 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -143,7 +143,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) 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; } -- 2.33.0