From patchwork Fri Aug 14 20:35:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 2988 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 4AA591C3E1C for ; Fri, 14 Aug 2026 22:36:10 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=redhat.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-25177-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-25177-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 8E944301BC32 for ; Fri, 14 Aug 2026 20:36:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 357C73DB338; Fri, 14 Aug 2026 20:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H7UP/L3A" X-Original-To: linux-sunxi@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ED0F3DA7C0 for ; Fri, 14 Aug 2026 20:36:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786739765; cv=none; b=teRmRtKK535K96bQMyZTyjy/gaeEbliKdgtKxIP8ZcXbzF6E9fEUP8t5RsCQfVa8ygv78eQA5pxZn4ONaUGnWfC3TEIsQNnTRcaMCygMG/cRi47FqESHg4jko27JisnZvIUSeXp6dtaYxXIx0he3sqmwMd30QLj398Gv6/k3MGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786739765; c=relaxed/simple; bh=L6cGAtA9z1lEA32tpQrcrf/dbswezRI4TiPZATe6Y6k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=Hah35JY9+n4HL1XSPzzbsURcttcLDVoNUSFpBFa9lHhDdnE3W5+JZnkdQ77Jj+SbnTiEaP+kJ29vSHKC9k6nzl+zybIZKWEzUlz3Y09aeamHcJhGpscAJPccsNEKwJ2CaQcUf15lsCYbkZo3LMA0Vh8UobJ10AIMUaRBqSLyl8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H7UP/L3A; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786739762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y8HxtGS/+pDsEWZq9YYRCPV84sZrTTgU1WrgrxJbu3s=; b=H7UP/L3ARE0/bTVvirc3xmDHx/wKHGmB/WFp4XiMVEMg+fuKs+uW+ieuTt9abMah/4EBdC y8R9ArTJsEmzVzNImxgj0IyI3iUwBGgagRww3ktlfDlvlZcOMGZq7rVY7wzK1uxF1+3v6q 73o+68/ALx7yBsDx5lz5yhPxMLfeomY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-OoJM1A43PeiGF1bcosKBrg-1; Fri, 14 Aug 2026 16:35:57 -0400 X-MC-Unique: OoJM1A43PeiGF1bcosKBrg-1 X-Mimecast-MFC-AGG-ID: OoJM1A43PeiGF1bcosKBrg_1786739754 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC0B919560B5; Fri, 14 Aug 2026 20:35:53 +0000 (UTC) Received: from GoldenWind.lan (unknown [10.22.64.233]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 12FBC197751A; Fri, 14 Aug 2026 20:35:49 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, nouveau@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-sunxi@lists.linux.dev, asahi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, intel-gfx@lists.freedesktop.org, linux-aspeed@lists.ozlabs.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-mips@vger.kernel.org, amd-gfx@lists.freedesktop.org, spice-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, imx@lists.linux.dev Subject: [PATCH 1/5] drm/vblank: Add drm_device.has_hw_vblank Date: Fri, 14 Aug 2026 16:35:29 -0400 Message-ID: <20260814203542.1405135-2-lyude@redhat.com> In-Reply-To: <20260814203542.1405135-1-lyude@redhat.com> References: <20260814203542.1405135-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-MFC-PROC-ID: R1ZeBp-kMd6HvMpVT4F7L-u0cecjt-6cYTqxhSAlMbY_1786739754 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-2.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; MID_CONTAINS_FROM(1.00)[]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; PRECEDENCE_BULK(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; RCPT_COUNT_TWELVE(0.00)[23]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo]; R_DKIM_ALLOW(0.00)[redhat.com:s=mimecast20190719]; TAGGED_FROM(0.00)[bounces-25177-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; DMARC_POLICY_ALLOW(0.00)[redhat.com,quarantine]; DKIM_TRACE(0.00)[redhat.com:+]; TO_DN_NONE(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[lyude@redhat.com,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: 4AA591C3E1C X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Currently the way we check if a driver supports hardware vblanks or not is actually funny and cursed! Likely because it predates KMS. As it turns out, we only check dev->num_crtcs to see if we have vblank support. Why? Because it doesn't actually represent the number of CRTCs on the device, unless drm_vblank_init() has been called - which sets dev->num_crtcs. And as it turns out, this is the second place we keep track of the number of CRTCs we have. Let's clean this up by starting with adding a variable specifically for tracking whether drm_vblank_init() has been called or not. Signed-off-by: Lyude Paul --- drivers/gpu/drm/drm_vblank.c | 3 ++- include/drm/drm_device.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index f90fb2d13e423..d317148af8cb3 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -557,6 +557,7 @@ int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs) if (!dev->vblank) return -ENOMEM; + dev->has_hw_vblank = true; dev->num_crtcs = num_crtcs; for (i = 0; i < num_crtcs; i++) { @@ -600,7 +601,7 @@ EXPORT_SYMBOL(drm_vblank_init); */ bool drm_dev_has_vblank(const struct drm_device *dev) { - return dev->num_crtcs != 0; + return dev->has_hw_vblank; } EXPORT_SYMBOL(drm_dev_has_vblank); diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h index 768a8dae83c52..2df08c756afd3 100644 --- a/include/drm/drm_device.h +++ b/include/drm/drm_device.h @@ -287,6 +287,13 @@ struct drm_device { */ struct drm_vblank_crtc *vblank; + /** + * @has_hw_vblank: + * + * Has the driver called drm_vblank_init() to setup hardware vblank support? + */ + bool has_hw_vblank; + /** * @vblank_time_lock: *