Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp290516ybb; Tue, 7 Apr 2020 23:08:42 -0700 (PDT) X-Google-Smtp-Source: APiQypISBgCpuBnC20PSjC6H9dnOd+5mX7JhLQLCPt/ppu/+QHBQuyuj6t568+Iqy8cM8EqLjXCN X-Received: by 2002:a54:4882:: with SMTP id r2mr1332075oic.137.1586326122455; Tue, 07 Apr 2020 23:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586326122; cv=none; d=google.com; s=arc-20160816; b=wZNwqQ965qTVbThTeUhcqPeDWAUq7HPC/mx46scu39fgl4HJ61VpDvYsceL7C4jv6H ermWXL4bevC9uYng4Kx64qpxLtv/9liSUZ9Yk0TyKBqBV+rNpgRRI8DEINwJ8rK3WR40 VZIRd1l4lQoOJ5EgKfjJcRgMEc6ggW6+/SViqToSH/nP1b4aiW9yz9xV5EAm5+XiA2xv hxe73Mak+jDnl5J+juwUZVYwPP6Qr8pNPEVOgUZ5maT94ZMT9MejWdBfx7lB2w0420nb EhNZwbl4E+LkIkmvUiJVVg4d3iNFneH84cT5ePXAFlMx+EnUQK1bkx0ebHE2mvDzvjnJ PGGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=la175c9DEDIHk3uGIF+L0/B/W9ixXMBxxvxYraHXojQ=; b=P+Uqg2UZ1+RNQdkgaOyHyptB8TcMQKPYIS0f8OyAvX5tmNJ2cyCxjz3+3ONbpRglcs I8sd2j3T1ImwtcHcXAJwVHDc8Pb0hkgKIiNhazBHavG26bW5dtG45g6v1I/8WDf4wQJR UG3veWZox0igwLWwGHdxn5cT9NfENtHro6ojekc0w5F3HMhl9eTdxPMzzIYKj7Ovw289 WOGQhZ5fppsN+aYj3W29sc+uTrja4qDw3PBVOSYwQ7nXNq4dhNPlGN7pYwDCmehYCrXJ I2Im8wejuFFpx1DFJUBiaib4RhLtyKA2/aBYjld12i8S+73zMVbgtxE7dV+dYKhy65XO FQMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qz+ogVx5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si2174262ook.91.2020.04.07.23.08.28; Tue, 07 Apr 2020 23:08:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qz+ogVx5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbgDHGFt (ORCPT + 99 others); Wed, 8 Apr 2020 02:05:49 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37970 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgDHGFt (ORCPT ); Wed, 8 Apr 2020 02:05:49 -0400 Received: by mail-qt1-f194.google.com with SMTP id 13so2870475qtt.5 for ; Tue, 07 Apr 2020 23:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=la175c9DEDIHk3uGIF+L0/B/W9ixXMBxxvxYraHXojQ=; b=qz+ogVx5bzbsbrrMH2avUgVhCc0+CZz48kXXeN4Ftk6sjRa2KdGvP9q73zpEDXcuCT Nw97Q2VkqpOlbBqI6KZLzopH2Uhp4D9/jyyxibHBQRvzGJIKijJJBzZADNBRGar9BRVx +RAfz9T+ZF1T5mp5B2S/wsNEBrVk1QaR+HE4OhLbvypeEjBVkxjAHLAZLM2AvAs+GShQ tVzb1aJBcTc8yLUVZbY3/X19PGk16mAy5bx4+vkUAuBJgtW7LYWTfPWINt7f2MDDLl6/ HBGAaTtnXzUFmY4d+gzBArtKYumQ5hYJIoMIIJ5QyLEH5J+wW6bwzhDTJTf77cIRdcN3 eiEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=la175c9DEDIHk3uGIF+L0/B/W9ixXMBxxvxYraHXojQ=; b=gK3jKPJi99G6NHnMlg2l1AgPOu3qr2lzUgi5sEJvpOks3gHCLQDv8UqTQtFYVqqpp3 vCrKH3DFwdJLMTThPMDG+VMOFpHy0w8yJz9r0/5finsOmZ1gH7RF9YksjbMOJf/MH/OL OPrEFN+hCo4sTEAEwHX+qTvHMAScbLnaqN17ybynmi2lJCkOr4/FCG1bT5Ij7b2y5lgV elIKDU2XHSoRP80yXyZi/iAgcHy4BSk7yA60cONQD1aJchu09eSuLEwAXHS0sxNtsOVr qRMLXkrC1B1qKK9af1PHt5EnbBgrZw1boI+p2TT/soQ3dg57jHSl/BCMFEimomI/Y3XI qFog== X-Gm-Message-State: AGi0PuaBg3mUhwdpGn3FrPnUQx1UvIbVGddEyrgWuTT/l4CFOn1B291K xynyp9vVfFiK0wFxKGdCX7A= X-Received: by 2002:ac8:2dae:: with SMTP id p43mr5933924qta.341.1586325947491; Tue, 07 Apr 2020 23:05:47 -0700 (PDT) Received: from arch.localdomain (189-69-221-86.dial-up.telesp.net.br. [189.69.221.86]) by smtp.gmail.com with ESMTPSA id w30sm19664170qtw.21.2020.04.07.23.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 23:05:46 -0700 (PDT) From: Gabriela Bittencourt To: rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, manasi.d.navare@intel.com Cc: Gabriela Bittencourt Subject: [PATCH 2/2] drm/vkms: Add 'virtual_hw' module option Date: Wed, 8 Apr 2020 03:05:03 -0300 Message-Id: <20200408060503.47709-3-gabrielabittencourt00@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200408060503.47709-1-gabrielabittencourt00@gmail.com> References: <20200408060503.47709-1-gabrielabittencourt00@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Virtual Vblank, virtual hardware module option ('virtual_hw') allows to skip the timing of vblank routine. Signed-off-by: Gabriela Bittencourt --- drivers/gpu/drm/vkms/vkms_crtc.c | 28 ++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.c | 13 +++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 2 ++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index a72769b81efe..d4aa1ed93bf2 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -58,6 +58,18 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) return HRTIMER_RESTART; } +static void vkms_virtual_vblank_simulate(struct vkms_output *output, + struct drm_crtc *crtc) +{ + struct vkms_crtc_state *state; + bool ret; + + state = output->composer_state; + ret = vkms_queue_compose_worker(output, state); + if (!ret) + DRM_DEBUG_DRIVER("Composer worker already queued\n"); +} + static int vkms_enable_vblank(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; @@ -214,16 +226,25 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, return 0; } +static bool vkms_crtc_atomic_check_vblank_enable(struct drm_crtc *crtc) +{ + struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + + return (!vkms_out->disable_vblank); +} + static void vkms_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - drm_crtc_vblank_on(crtc); + if (vkms_crtc_atomic_check_vblank_enable(crtc)) + drm_crtc_vblank_on(crtc); } static void vkms_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - drm_crtc_vblank_off(crtc); + if (vkms_crtc_atomic_check_vblank_enable(crtc)) + drm_crtc_vblank_off(crtc); } static void vkms_crtc_atomic_begin(struct drm_crtc *crtc, @@ -258,6 +279,9 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, vkms_output->composer_state = to_vkms_crtc_state(crtc->state); spin_unlock_irq(&vkms_output->lock); + + if (vkms_output->disable_vblank) + vkms_virtual_vblank_simulate(vkms_output, crtc); } static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index eef85f1a0ce5..f7c25961b083 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -39,6 +39,11 @@ bool enable_cursor; module_param_named(enable_cursor, enable_cursor, bool, 0444); MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); +bool virtual_hw; +module_param_named(virtual_hw, virtual_hw, bool, 0444); +MODULE_PARM_DESC(virtual_hw, + "Enable virtual hardware mode / Disable vblank"); + static const struct file_operations vkms_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -168,9 +173,13 @@ static int __init vkms_init(void) goto out_put; } - vkms_device->drm.irq_enabled = true; + vkms_device->output.disable_vblank = virtual_hw; + vkms_device->drm.irq_enabled = !virtual_hw; + + if (virtual_hw) + DRM_INFO("Virtual hardware mode enabled"); - ret = drm_vblank_init(&vkms_device->drm, 1); + ret = (virtual_hw) ? 0 : drm_vblank_init(&vkms_device->drm, 1); if (ret) { DRM_ERROR("Failed to vblank\n"); goto out_put; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index eda04ffba7b1..52ad8e06adc5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -19,6 +19,7 @@ #define YRES_MAX 8192 extern bool enable_cursor; +extern bool virtual_hw; struct vkms_composer { struct drm_framebuffer fb; @@ -64,6 +65,7 @@ struct vkms_output { struct drm_encoder encoder; struct drm_connector connector; struct hrtimer vblank_hrtimer; + bool disable_vblank; ktime_t period_ns; struct drm_pending_vblank_event *event; /* ordered wq for composer_work */ -- 2.25.1