From nobody Sun Feb 8 09:12:24 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 2376F33032B for ; Tue, 23 Dec 2025 11:32:24 +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=1766489547; cv=none; b=TBpd0ZBqwYC/0nAB8fB7rKKWDTPED7l52NrTHfZg9cTRRgikUt1ojWq8iDad7oOxVMQgrN+3ux4+8UQfBVQPuebEV4c//fUxfsEW80BU7MxhcXiiMScD4yl4mewLLvKmGwNvsOJu4Gg3hqgHTmyF8DdU7NQJk4+ZLSS0/KPVHHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766489547; c=relaxed/simple; bh=y4CN9EfH3SCGQwEdoS9dq9ykH4aroCjbpQAZ5ZFoGa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WN5g2vEYspQM544c94Im4JC5H21hQwyC6ttTOFqpY7+X0TgyXqAoKY9ObysD3o0470Td7EhwQxMuBj1gBwFFECZHffWLjW/Vzn81itp9XnWeqy5ctsPLM/3OZpw7gq5r2nk8kc+pxnumEdKycXF3DplxmQyJbFw8bs3YbB2zn00= 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=f+er6LpI; 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="f+er6LpI" Received: from aerhardt-tuxedo.fritz.box (p57b9501c.dip0.t-ipconnect.de [87.185.80.28]) (Authenticated sender: a.erhardt@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPSA id 7A84F2FC021D; Tue, 23 Dec 2025 12:32:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1766489536; 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=f+er6LpIMar7t7I9tXI5C4WsMcvoZRGlOtKOlLY8Sg2/t4vHn08ysVsrPNQvkyvjSiohsZ mefm+0hKH6aJbY1URMSxVpejHp55Vx7v/rW1imQpzLcTgMMZ6CHmtS3ggvcHkN8UCHWOJF dcJBRS2+ooH6EbGrgWMdkWKTDXvKHnI= 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: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Aaron Erhardt Subject: [RFC PATCH 1/1] drm: ensure that vblank diff is never negative Date: Tue, 23 Dec 2025 12:22:46 +0100 Message-ID: <20251223112246.3026909-2-aer@tuxedocomputers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223112246.3026909-1-aer@tuxedocomputers.com> References: <20251223112246.3026909-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