From nobody Sun Feb 8 04:38:42 2026 Received: from mail.tuxedocomputers.com (mail.tuxedocomputers.com [157.90.84.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 151882DFA25 for ; Thu, 8 Jan 2026 16:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=157.90.84.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767891123; cv=none; b=Gbic0XpfnmlB0ta7E2e3+4C5x1/TXw2FTFfPnI6wdm5hVxeGNl9HJCuY7vFkXogOEF8jqgCz7wm726uTcKNGnDVifGcSL1it4YuY+9Q4+D6ZG98WHCANGx5n5NPIZszFzI5/k71PfwxBniFFFUIgq5hcBHak+FLtZ3q5BP1AnZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767891123; c=relaxed/simple; bh=y4CN9EfH3SCGQwEdoS9dq9ykH4aroCjbpQAZ5ZFoGa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kaABEHqju9y3jziW8QNXdbkFHFJ9yaQWxeWWOFtU+tCo6j1tYgbCYpCaNEum4Aq9ASpwo3wmQpvT3SOMPSWy2fx2L1Pm+YdQ/cMblrRc7f4NPhYYd3KVKZFTuBH4t2gNpdniC/ny7+MO+MXNRwnl3eijMaHyj9yK5S0akMG6dYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com; spf=pass smtp.mailfrom=tuxedocomputers.com; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b=somT5Me4; arc=none smtp.client-ip=157.90.84.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b="somT5Me4" Received: from aerhardt-tuxedo.buero.augsburg.tuxedo.de (business-24-134-105-141.pool2.vodafone-ip.de [24.134.105.141]) (Authenticated sender: a.erhardt@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPSA id 4ED042FC004A; Thu, 8 Jan 2026 17:51:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1767891117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9zIefKkZMzxo7MD02YKy4yO08bQ/1V31nPzenPtLvac=; b=somT5Me4utwc5C4kKGD15Znawh/YuJYCResyw7SZAHFfgJ5ZDVy0exZwRM5zOe51n1SLc1 Tyqajuf9lPw7cNAzx2mtSNLPXQlsqpxYYZVdFplz0iSn+4s4pxE4Ii2pplwhsydtcw9jmz ii644c10srauSIZPfZSvn6e5Rm4TXq4= Authentication-Results: mail.tuxedocomputers.com; auth=pass smtp.auth=a.erhardt@tuxedocomputers.com smtp.mailfrom=aer@tuxedocomputers.com From: Aaron Erhardt To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Aaron Erhardt , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [RESEND RFC PATCH 1/1] drm: ensure that vblank diff is never negative Date: Thu, 8 Jan 2026 17:51:39 +0100 Message-ID: <20260108165139.1381835-2-aer@tuxedocomputers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108165139.1381835-1-aer@tuxedocomputers.com> References: <20260108165139.1381835-1-aer@tuxedocomputers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Handle cases, where drivers report incorrect timestamps and negative time differences are calculated. If the negative difference is large enough, negative missed vblanks are reported, but stored in an unsigned integer which can causes freezes. This patch prevents this case. This fix has been verified to fix problems with the i915 driver on modern Intel CPUs (e.g. Intel Core Ultra 7 155H). Signed-off-by: Aaron Erhardt --- drivers/gpu/drm/drm_vblank.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 94e45ed6869d..1022b6d61e4e 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1563,7 +1563,14 @@ static void drm_vblank_restore(struct drm_device *de= v, unsigned int pipe) } while (cur_vblank !=3D __get_vblank_counter(dev, pipe) && --count > 0); =20 diff_ns =3D ktime_to_ns(ktime_sub(t_vblank, vblank->time)); - if (framedur_ns) + + /* + * Make sure no bogus diffs result from negative differences + * when incorrect timestamps are reported by a driver. + */ + if (drm_WARN_ON_ONCE(dev, t_vblank < vblank->time)) + diff =3D 0; + else if (framedur_ns) diff =3D DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns); =20 =20 --=20 2.43.0