From patchwork Thu Feb 21 15:47:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10824245 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 1055315AC for ; Thu, 21 Feb 2019 15:47:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F30C2314E5 for ; Thu, 21 Feb 2019 15:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E75CC314EA; Thu, 21 Feb 2019 15:47:46 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable 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 92889314E5 for ; Thu, 21 Feb 2019 15:47:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D533D89174; Thu, 21 Feb 2019 15:47:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C29489123; Thu, 21 Feb 2019 15:47:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79645305D788; Thu, 21 Feb 2019 15:47:42 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EDBA27C4B; Thu, 21 Feb 2019 15:47:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A38F611AAB; Thu, 21 Feb 2019 16:47:33 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Date: Thu, 21 Feb 2019 16:47:33 +0100 Message-Id: <20190221154733.5516-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 21 Feb 2019 15:47:42 +0000 (UTC) Subject: [Intel-gfx] [PATCH v3] drm: move i915_kick_out_vgacon to drm_fb_helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , "open list:INTEL DRM DRIVERS excluding Poulsbo, Moorestow..." , open list , David Airlie , Gerd Hoffmann MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Also rename it and call it automatically from drm_fb_helper_remove_conflicting_pci_framebuffers() Signed-off-by: Gerd Hoffmann --- include/drm/drm_fb_helper.h | 18 ++++++++++++++--- drivers/gpu/drm/drm_fb_helper.c | 35 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.c | 43 ----------------------------------------- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index bb9acea61369..aef764c3dd7f 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -36,6 +36,7 @@ struct drm_fb_helper; #include #include #include +#include enum mode_set_atomic { LEAVE_ATOMIC_MODE_SET, @@ -625,6 +626,8 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +int drm_fb_helper_kick_out_vgacon(void); + /** * drm_fb_helper_remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices * @pdev: PCI device @@ -642,11 +645,20 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int resource_id, const char *name) { + int ret = 0; + + /* + * WARNING: Apparently we must kick fbdev drivers before vgacon, + * otherwise the vga fbdev driver falls over. + */ #if IS_REACHABLE(CONFIG_FB) - return remove_conflicting_pci_framebuffers(pdev, resource_id, name); -#else - return 0; + ret = remove_conflicting_pci_framebuffers(pdev, resource_id, name); #endif +#if IS_REACHABLE(CONFIG_DRM_FBDEV_EMULATION) + if (ret == 0 && vga_default_device() == pdev) + ret = drm_fb_helper_kick_out_vgacon(); +#endif + return ret; } #endif diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 04d23cb430bf..57f410e2bba6 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -3355,3 +3356,37 @@ int __init drm_fb_helper_modinit(void) return 0; } EXPORT_SYMBOL(drm_fb_helper_modinit); + +#if !defined(CONFIG_VGA_CONSOLE) +int drm_fb_helper_kick_out_vgacon(void) +{ + return 0; +} +#elif !defined(CONFIG_DUMMY_CONSOLE) +int drm_fb_helper_kick_out_vgacon(void) +{ + return -ENODEV; +} +#else +int drm_fb_helper_kick_out_vgacon(void) +{ + int ret = 0; + + DRM_INFO("Replacing VGA console driver\n"); + + console_lock(); + if (con_is_bound(&vga_con)) + ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1); + if (ret == 0) { + ret = do_unregister_con_driver(&vga_con); + + /* Ignore "already unregistered". */ + if (ret == -ENODEV) + ret = 0; + } + console_unlock(); + + return ret; +} +#endif +EXPORT_SYMBOL(drm_fb_helper_kick_out_vgacon); diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 6630212f2faf..0e87eef542da 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) return ret; } -#if !defined(CONFIG_VGA_CONSOLE) -static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) -{ - return 0; -} -#elif !defined(CONFIG_DUMMY_CONSOLE) -static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) -{ - return -ENODEV; -} -#else -static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) -{ - int ret = 0; - - DRM_INFO("Replacing VGA console driver\n"); - - console_lock(); - if (con_is_bound(&vga_con)) - ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1); - if (ret == 0) { - ret = do_unregister_con_driver(&vga_con); - - /* Ignore "already unregistered". */ - if (ret == -ENODEV) - ret = 0; - } - console_unlock(); - - return ret; -} -#endif - static void intel_init_dpio(struct drm_i915_private *dev_priv) { /* @@ -1410,22 +1377,12 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) if (ret) goto err_perf; - /* - * WARNING: Apparently we must kick fbdev drivers before vgacon, - * otherwise the vga fbdev driver falls over. - */ ret = i915_kick_out_firmware_fb(dev_priv); if (ret) { DRM_ERROR("failed to remove conflicting framebuffer drivers\n"); goto err_ggtt; } - ret = i915_kick_out_vgacon(dev_priv); - if (ret) { - DRM_ERROR("failed to remove conflicting VGA console\n"); - goto err_ggtt; - } - ret = i915_ggtt_init_hw(dev_priv); if (ret) goto err_ggtt;