From patchwork Thu Aug 23 17:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10574477 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 4F053920 for ; Thu, 23 Aug 2018 17:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 318652C2D9 for ; Thu, 23 Aug 2018 17:34:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D482C570; Thu, 23 Aug 2018 17:34:19 +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 C73F12C2D9 for ; Thu, 23 Aug 2018 17:34:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDB566E571; Thu, 23 Aug 2018 17:34:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x241.google.com (mail-qk0-x241.google.com [IPv6:2607:f8b0:400d:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9805A6E574 for ; Thu, 23 Aug 2018 17:34:16 +0000 (UTC) Received: by mail-qk0-x241.google.com with SMTP id z78-v6so4163882qka.0 for ; Thu, 23 Aug 2018 10:34:16 -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=E3thtkV23S6jApdUMbzat6Y+jzFXj2m3gOOPjoE8EOw=; b=Dfycy6H8Sm2CzZm6brokq600hCO/HL4kSF1zqSfL8GsDWhK1kXpZkIRXbhFwpcB0My T0YSAI0vF2mZgk6X35cT1AhWJuRh7bO2iqsp90Mf/UDqDgcwiLpiHPIUhX3bI7rBouxD 4yWskb2iTkBWMNc0E/0B8BPLAmKZGSDrQ5OqQJYx7aJ5xZsaMthGvtNbMCTUyP8snIFc Wvyb7ZQ9Q+HrAVJrY5HXtiHvzDbvZbensWwXQnzTAbjXGSDEkYHps2+4vn6rhgfP7KTf hBAVy6xT03qasuEp5kOXoMWRMOoWhswSqzyY/aJsPdASmKO3sR4Gbms33EglnBB0NPkY huAA== X-Gm-Message-State: AOUpUlE1I7OkN0zMQdgUdj+HTI560P8sdYz6H0woehzaVMEjc9lhW3PU D3Y8GECjebER0yoN3D8j+UA= X-Google-Smtp-Source: AA+uWPxy1+tSomP1TkawMcPssYo3mfD8zqeT3eRpKQQS4GTqTuV05KmmvJh3Iy8XzQ4CC0xr5zzdZQ== X-Received: by 2002:a37:6ac3:: with SMTP id f186-v6mr58788347qkc.224.1535045655639; Thu, 23 Aug 2018 10:34:15 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id d100-v6sm3644072qkh.34.2018.08.23.10.34.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 10:34:15 -0700 (PDT) Date: Thu, 23 Aug 2018 14:34:12 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Gustavo Padovan , Sean Paul , Haneen Mohammed Subject: [PATCH V2] drm/vkms: Add support for vkms work without vblank Message-ID: <20180823173412.m4txq5vmqhhxumc6@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, vkms needs VBlank to work well. This patch adds another operation model that make vkms works 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 verification. 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 | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index bfe6e0312cc4..001fa5c1d326 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -145,12 +145,22 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = { 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 5d78bd97e69c..0b6569ee9dcc 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -21,6 +21,11 @@ static struct vkms_device *vkms_device; +static 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, @@ -105,9 +110,13 @@ static int __init vkms_init(void) goto out_fini; } - 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 f156c930366a..9ee862e6f7e5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -52,6 +52,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; bool crc_enabled;