Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 AEB1321B9C0 for ; Wed, 8 Oct 2025 12:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759925864; cv=none; b=VGRi6P4QQ1S28HLCgj3pZ4nVGBCLFwXnyMv2wGKA5U5aXive11bKPyszUKLaoWvDbzNuy7rSlqcWM29v37Haq3tUhdITVUpnS5bpaJFvgeHwWn6b55C+Acnq7l/TU8RndE9TVL4F6NjaLs6UNZGKUht8jN37zW/Af5/7oBrJ+pI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759925864; c=relaxed/simple; bh=EzncALwEe2a+QshpNOni8NWDjShAJzEJ7z8PNQnp0Ms=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gQtOSRrpOp/njfKrSc3zwOQR6VMUOezIZZUIjLuISzI6bilgpzEy0QwuP0F7CNuLwNJoWwDCnWO51uPqqQVTxFgJKN2K2SgYfOaE8sqZYT6i/k41DRDpX2qbcV6LnMqtaBuKirjpOF+Kqq3njm3ktMZGIb+AuNOtr44vPtJRaB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Icgycpf4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=l6Lx18U6; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=TxIVBXk3; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=wvFTqYft; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Icgycpf4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="l6Lx18U6"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TxIVBXk3"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wvFTqYft" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E92121F79F; Wed, 8 Oct 2025 12:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1759925861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5wObbyiJlGh5lzZbXgep/HCNowXb5U4wB4EHGf4feMs=; b=Icgycpf4a2Sdm0+4fMOwVsSgiG7wbeO4mW4+YtGIXzFw9r0Mr/pRQeC3hRp/tXusPSw7wX 0h1sHH8m/H0pglqSn7hzCcG7unNe3vHvKGEMUjAP8GRLlo+KPX1H/Yjz0N/9TuEQ/VTysz 6a0TF+DOnIGvdeQ8Tb1N/pCmeFZnbkM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1759925861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5wObbyiJlGh5lzZbXgep/HCNowXb5U4wB4EHGf4feMs=; b=l6Lx18U6rmfbJqHOLgte8dOMEPXTlPvyTJx6aK4aTysglXa4cn7rD4X3HpholOJHlta8fm lbfQpdUEn1hmv5Cg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=TxIVBXk3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wvFTqYft DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1759925860; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5wObbyiJlGh5lzZbXgep/HCNowXb5U4wB4EHGf4feMs=; b=TxIVBXk3Jcsd9aHVpmoVe0cl/6JOerRrdJ+j2kOSZDLxKBfK/IgmmeIaDlqSFo+6zKVZL1 NoPuBomA2R0XCcdoYUD7lJh48b0yPIy0+GpR87Mmtg5dnoDtPajSbjevtgYlGdtBVxXAqY QCvmSn3uE+8jPR5rJoCRwHczaT2jX3I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1759925860; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5wObbyiJlGh5lzZbXgep/HCNowXb5U4wB4EHGf4feMs=; b=wvFTqYftMbj9mOHigH58NQO8avnq0iNhCu84ll8hj78Wdoyu/5BzGzhPNIefhHex4rnCob wSsPpvveJqsATdAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A5E8713A3D; Wed, 8 Oct 2025 12:17:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UpZQJ2RW5mhKOQAAD6G6ig (envelope-from ); Wed, 08 Oct 2025 12:17:40 +0000 From: Thomas Zimmermann To: airlied@redhat.com, kraxel@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch Cc: virtualization@lists.linux.dev, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH] drm/cirrus-qemu: Use vblank timer Date: Wed, 8 Oct 2025 14:14:36 +0200 Message-ID: <20251008121450.227997-1-tzimmermann@suse.de> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: E92121F79F X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[redhat.com,linux.intel.com,kernel.org,gmail.com,ffwll.ch]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -3.01 Use a vblank timer to simulate the vblank interrupt. The DRM vblank helpers provide an implementation on top of Linux' hrtimer. Cirrus-qemu enables and disables the timer as part of the CRTC. The atomic_flush callback sets up the event. Like vblank interrupts, the vblank timer fires at the rate of the display refresh. Most userspace limits its page flip rate according to the DRM vblank event. Cirrus-qemu' virtual hardware does not provide vblank interrupts, so DRM sends each event ASAP. With the fast access times of virtual display memory, the event rate is much higher than the display mode's refresh rate; creating the next page flip almost immediately. This leads to excessive CPU overhead from even small display updates, such as moving the mouse pointer. This problem affects cirrus-qemu and all other virtual displays. See [1] for a discussion in the context of hypervdrm. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/dri-devel/SN6PR02MB415702B00D6D52B0EE962C98D46CA@SN6PR02MB4157.namprd02.prod.outlook.com/ # [1] --- drivers/gpu/drm/tiny/cirrus-qemu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/tiny/cirrus-qemu.c b/drivers/gpu/drm/tiny/cirrus-qemu.c index 97a93adc5669..f728fa48ac88 100644 --- a/drivers/gpu/drm/tiny/cirrus-qemu.c +++ b/drivers/gpu/drm/tiny/cirrus-qemu.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #define DRIVER_NAME "cirrus-qemu" #define DRIVER_DESC "qemu cirrus vga" @@ -404,11 +406,15 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc, #endif drm_dev_exit(idx); + + drm_crtc_vblank_on(crtc); } static const struct drm_crtc_helper_funcs cirrus_crtc_helper_funcs = { .atomic_check = cirrus_crtc_helper_atomic_check, + .atomic_flush = drm_crtc_vblank_atomic_flush, .atomic_enable = cirrus_crtc_helper_atomic_enable, + .atomic_disable = drm_crtc_vblank_atomic_disable, }; static const struct drm_crtc_funcs cirrus_crtc_funcs = { @@ -418,6 +424,7 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = { .page_flip = drm_atomic_helper_page_flip, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + DRM_CRTC_VBLANK_TIMER_FUNCS, }; static const struct drm_encoder_funcs cirrus_encoder_funcs = { @@ -493,6 +500,10 @@ static int cirrus_pipe_init(struct cirrus_device *cirrus) if (ret) return ret; + ret = drm_vblank_init(dev, 1); + if (ret) + return ret; + return 0; } -- 2.51.0