From patchwork Wed Jul 10 01:55:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11037707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FDC4138D for ; Wed, 10 Jul 2019 01:55:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D5A1288A9 for ; Wed, 10 Jul 2019 01:55:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AE1C28900; Wed, 10 Jul 2019 01:55:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F5B9288A9 for ; Wed, 10 Jul 2019 01:55:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B49288972B; Wed, 10 Jul 2019 01:55:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFF4D8972B for ; Wed, 10 Jul 2019 01:55:19 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id h21so718754qtn.13 for ; Tue, 09 Jul 2019 18:55:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=+A+XURfQyB8AGFyMf1LEzeRDTsqVu/9+CULnouL4R1Y=; b=sJSw8r1UzST5EWqWQN2vKuQCX4o4r7bFqw6ZE556Y1G7bpUPtO3/wjHO3HuLClE1Lt Xczj4+1hdgFIyQH+dfCiXv4/ihsLgIQHkWDlRVBjvfGEes+D1gFl4wnISaIzJiCPhyOu eAKWWuPyk2TD/hPlwH/aIl+cnJOszQ5xkIobJcgWTow+i2aqgO5uDmBxMDbPZcRXhcGZ XQAQFg/wir/CgXAtIqT8PDrEKfl9TEYwPYV+kpUSWODGXTEE3jTH27jN0BX6khJG2xq4 xGceH+YQ4z9IJVsxQFdBIuYZfG9G/HQrXWekJqAIn0txm/7hgL2jxky/lkY7Vc3UWpwB B8LQ== X-Gm-Message-State: APjAAAUhTxqi+S8dtIqxUJMFYGDEVP1O5KAbz8Sn33pN/qyo564TjfYS 2zoEH9ytj7EyPVXMkUWmnF4= X-Google-Smtp-Source: APXvYqxBcjbo+yP5AUv1Ap9d8SOzy//okd1bX0SnEzMbzUs56O39l3Czd6XGj3iXhVjga9zgt4d5ng== X-Received: by 2002:ac8:36b9:: with SMTP id a54mr21981970qtc.300.1562723719095; Tue, 09 Jul 2019 18:55:19 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id z4sm406271qtd.60.2019.07.09.18.55.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 18:55:18 -0700 (PDT) Date: Tue, 9 Jul 2019 22:55:14 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Haneen Mohammed , David Airlie , Simon Ser , Oleg Vasilev Subject: [PATCH V3] drm/vkms: Add support for vkms work without vblank Message-ID: <20190710015514.42anrmx3r2ijaomz@smtp.gmail.com> MIME-Version: 1.0 User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=+A+XURfQyB8AGFyMf1LEzeRDTsqVu/9+CULnouL4R1Y=; b=Kf1ZG5989CAPh773hWh61mlxI7hJpjFULTKfO6o9mI051brplF5Ag+TJCLa+tu7rbs CH1z34q9ANrkA1eE2ArJFFmD9DhTM0xjtw5gdChjav4mjfu1paPqYxxBLwHGr80o+qR2 L/FRXpmikkLBHBDzdTgvTE7b4uTcYlVAabk1PTf6S7Rgh/T2dIssdUtG4zCNfEY+OqoV 0tjBJf5xTrh5dJf5TALbvY+gUPuqqECUETbmpgwDnJO2WD2/IKQJJb+4dIxnSWe3uKQ4 RkLk9GVU5cEL/SJKy1Xb7h7oqBUaaWFUtJsopzqwVTv0Fz0ojJNznnimE26PnHjPIQwd sy7g== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, vkms only work with enabled VBlank. This patch adds another operation model that allows vkms to work without VBlank support. In this scenario, vblank signaling is faked by calling drm_send_vblank_event() in vkms_crtc_atomic_flush(); this approach works due to the drm_vblank_get() == 0 checking. Changes since V2: - Rebase Changes since V1: Daniel Vetter: - Change module parameter name from disablevblank to virtual_hw - Improve parameter description - Improve commit message Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_crtc.c | 10 ++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 13 +++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 49a8ec2cb1c1..a0c75b8c4335 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -207,12 +207,22 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, static void vkms_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { + struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + + if (vkms_out->disable_vblank) + return; + drm_crtc_vblank_on(crtc); } static void vkms_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { + struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + + if (vkms_out->disable_vblank) + return; + drm_crtc_vblank_off(crtc); } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 152d7de24a76..542a002ef9d5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -34,6 +34,11 @@ bool enable_writeback; module_param_named(enable_writeback, enable_writeback, bool, 0444); MODULE_PARM_DESC(enable_writeback, "Enable/Disable writeback connector"); +bool virtual_hw; +module_param_named(virtual_hw, virtual_hw, bool, 0444); +MODULE_PARM_DESC(virtual_hw, + "Enable virtual hardware mode (disables vblanks and immediately completes flips)"); + static const struct file_operations vkms_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -154,9 +159,13 @@ static int __init vkms_init(void) if (ret) goto out_unregister; - 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_fini; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 9ff2cd4ebf81..256e5e65c947 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -21,6 +21,7 @@ extern bool enable_cursor; extern bool enable_writeback; +extern bool virtual_hw; struct vkms_composer { struct drm_framebuffer fb; @@ -69,6 +70,7 @@ struct vkms_output { struct drm_connector connector; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; + bool disable_vblank; ktime_t period_ns; struct drm_pending_vblank_event *event; /* ordered wq for composer_work */