From patchwork Thu Aug 9 00:15:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 10560645 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 ADBB71057 for ; Thu, 9 Aug 2018 00:17:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FE9920952 for ; Thu, 9 Aug 2018 00:17:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94B2C2AC60; Thu, 9 Aug 2018 00:17:03 +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=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 DA8A620952 for ; Thu, 9 Aug 2018 00:17:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A75B96E62D; Thu, 9 Aug 2018 00:16:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D8B96E621 for ; Thu, 9 Aug 2018 00:16:54 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 17:16:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,212,1531810800"; d="scan'208";a="60976894" Received: from josouza-mobl.jf.intel.com ([10.24.11.40]) by fmsmga007.fm.intel.com with ESMTP; 08 Aug 2018 17:16:53 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Aug 2018 17:15:56 -0700 Message-Id: <20180809001606.26876-10-jose.souza@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809001606.26876-1-jose.souza@intel.com> References: <20180809001606.26876-1-jose.souza@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 10/20] drm/i915: Do not call modeset related functions when display is disabled 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP No need to run i915_load_modeset_init() when num_pipes == 0 also kms depends on things initialized in i915_load_modeset_init() so not initializing it too. fbdev and audio have guards against num_pipes == 0 but lets move it to the if block to make it explicit to readers. Also as planes, CRTCs, encoders and connectors are not being added it is necessary to unset the MODESET driver feature otherwise it will crash when registering driver in drm, also disabling ATOMIC as do not make sense have ATOMIC and do not have MODESET. There is more modeset/display calls that still needs to be removed, this is a initial work. Signed-off-by: José Roberto de Souza --- drivers/gpu/drm/i915/i915_drv.c | 157 +++++++++++++++--------- drivers/gpu/drm/i915/i915_suspend.c | 24 ++-- drivers/gpu/drm/i915/intel_runtime_pm.c | 3 +- 3 files changed, 114 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index e9a6cc7b3efd..e93be91a6701 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -917,7 +917,8 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv, intel_wopcm_init_early(&dev_priv->wopcm); intel_uc_init_early(dev_priv); intel_pm_setup(dev_priv); - intel_init_dpio(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_init_dpio(dev_priv); ret = intel_power_domains_init(dev_priv); if (ret < 0) goto err_uc; @@ -925,8 +926,10 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv, intel_hangcheck_init(dev_priv); intel_init_display_hooks(dev_priv); intel_init_clock_gating_hooks(dev_priv); - intel_init_audio_hooks(dev_priv); - intel_display_crc_init(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_init_audio_hooks(dev_priv); + intel_display_crc_init(dev_priv); + } intel_detect_preproduction_hw(dev_priv); @@ -1258,23 +1261,26 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) if (IS_GEN5(dev_priv)) intel_gpu_ips_init(dev_priv); - intel_audio_init(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_audio_init(dev_priv); - /* - * Some ports require correctly set-up hpd registers for detection to - * work properly (leading to ghost connected connector status), e.g. VGA - * on gm45. Hence we can only set up the initial fbdev config after hpd - * irqs are fully enabled. We do it last so that the async config - * cannot run before the connectors are registered. - */ - intel_fbdev_initial_config_async(dev); + /* + * Some ports require correctly set-up hpd registers for + * detection to work properly (leading to ghost connected + * connector status), e.g. VGA on gm45. Hence we can only set + * up the initial fbdev config after hpd irqs are fully enabled. + * We do it last so that the async config cannot run before the + * connectors are registered. + */ + intel_fbdev_initial_config_async(dev); - /* - * We need to coordinate the hotplugs with the asynchronous fbdev - * configuration, for which we use the fbdev->async_cookie. - */ - if (INTEL_INFO(dev_priv)->num_pipes) + /* + * We need to coordinate the hotplugs with the asynchronous + * fbdev configuration, for which we use the + * fbdev->async_cookie. + */ drm_kms_helper_poll_init(dev); + } } /** @@ -1283,15 +1289,17 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) */ static void i915_driver_unregister(struct drm_i915_private *dev_priv) { - intel_fbdev_unregister(dev_priv); - intel_audio_deinit(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_fbdev_unregister(dev_priv); + intel_audio_deinit(dev_priv); - /* - * After flushing the fbdev (incl. a late async config which will - * have delayed queuing of a hotplug event), then flush the hotplug - * events. - */ - drm_kms_helper_poll_fini(&dev_priv->drm); + /* + * After flushing the fbdev (incl. a late async config which + * will have delayed queuing of a hotplug event), then flush the + * hotplug events. + */ + drm_kms_helper_poll_fini(&dev_priv->drm); + } intel_gpu_ips_teardown(); acpi_video_unregister(); @@ -1343,6 +1351,9 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) if (!i915_modparams.nuclear_pageflip && match_info->gen < 5) driver.driver_features &= ~DRIVER_ATOMIC; + if (i915_modparams.disable_display) + driver.driver_features &= ~(DRIVER_MODESET | DRIVER_ATOMIC); + ret = -ENOMEM; dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL); if (dev_priv) @@ -1400,9 +1411,11 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto cleanup_irq; - ret = i915_load_modeset_init(&dev_priv->drm); - if (ret < 0) - goto cleanup_gem; + if (INTEL_INFO(dev_priv)->num_pipes) { + ret = i915_load_modeset_init(&dev_priv->drm); + if (ret < 0) + goto cleanup_gem; + } /* intel_power_domains_init_hw() counter part */ intel_display_set_init_power(dev_priv, false); @@ -1469,11 +1482,13 @@ void i915_driver_unload(struct drm_device *dev) intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); - drm_atomic_helper_shutdown(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + drm_atomic_helper_shutdown(dev); intel_gvt_cleanup(dev_priv); - intel_modeset_cleanup_prepare(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_modeset_cleanup_prepare(dev); intel_disable_gt_powersave(dev_priv); @@ -1484,11 +1499,13 @@ void i915_driver_unload(struct drm_device *dev) */ intel_irq_uninstall(dev_priv); - intel_modeset_cleanup(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_modeset_cleanup(dev); intel_cleanup_gt_powersave(dev_priv); - i915_modeset_unload(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + i915_modeset_unload(dev); /* Free error state after interrupts are fully disabled. */ cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); @@ -1540,8 +1557,12 @@ static int i915_driver_open(struct drm_device *dev, struct drm_file *file) */ static void i915_driver_lastclose(struct drm_device *dev) { - intel_fbdev_restore_mode(dev); - vga_switcheroo_process_delayed_switch(); + struct drm_i915_private *dev_priv = to_i915(dev); + + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_fbdev_restore_mode(dev); + vga_switcheroo_process_delayed_switch(); + } } static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) @@ -1611,19 +1632,24 @@ static int i915_drm_suspend(struct drm_device *dev) /* We do a lot of poking in a lot of registers, make sure they work * properly. */ intel_display_set_init_power(dev_priv, true); - - drm_kms_helper_poll_disable(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + drm_kms_helper_poll_disable(dev); pci_save_state(pdev); - intel_display_suspend(dev); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_display_suspend(dev); - intel_dp_mst_suspend(dev_priv); + intel_dp_mst_suspend(dev_priv); + } intel_runtime_pm_disable_interrupts(dev_priv); - intel_hpd_cancel_work(dev_priv); - intel_suspend_encoders(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_hpd_cancel_work(dev_priv); + + intel_suspend_encoders(dev_priv); + } intel_suspend_hw(dev_priv); @@ -1636,11 +1662,13 @@ static int i915_drm_suspend(struct drm_device *dev) intel_opregion_unregister(dev_priv); - intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true); dev_priv->suspend_count++; - intel_csr_ucode_suspend(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_csr_ucode_suspend(dev_priv); enable_rpm_wakeref_asserts(dev_priv); @@ -1751,10 +1779,12 @@ static int i915_drm_resume(struct drm_device *dev) if (ret) DRM_ERROR("failed to re-enable GGTT\n"); - intel_csr_ucode_resume(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_csr_ucode_resume(dev_priv); i915_restore_state(dev_priv); - intel_pps_unlock_regs_wa(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_pps_unlock_regs_wa(dev_priv); intel_opregion_setup(dev_priv); intel_init_pch_refclk(dev_priv); @@ -1771,7 +1801,8 @@ static int i915_drm_resume(struct drm_device *dev) */ intel_runtime_pm_enable_interrupts(dev_priv); - drm_mode_config_reset(dev); + if (INTEL_INFO(dev_priv)->num_pipes) + drm_mode_config_reset(dev); i915_gem_resume(dev_priv); @@ -1779,27 +1810,30 @@ static int i915_drm_resume(struct drm_device *dev) intel_init_clock_gating(dev_priv); spin_lock_irq(&dev_priv->irq_lock); - if (dev_priv->display.hpd_irq_setup) + if (dev_priv->display.hpd_irq_setup && INTEL_INFO(dev_priv)->num_pipes) dev_priv->display.hpd_irq_setup(dev_priv); spin_unlock_irq(&dev_priv->irq_lock); - intel_dp_mst_resume(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + intel_dp_mst_resume(dev_priv); - intel_display_resume(dev); + intel_display_resume(dev); - drm_kms_helper_poll_enable(dev); + drm_kms_helper_poll_enable(dev); - /* - * ... but also need to make sure that hotplug processing - * doesn't cause havoc. Like in the driver load code we don't - * bother with the tiny race here where we might lose hotplug - * notifications. - * */ - intel_hpd_init(dev_priv); + /* + * ... but also need to make sure that hotplug processing + * doesn't cause havoc. Like in the driver load code we don't + * bother with the tiny race here where we might lose hotplug + * notifications. + */ + intel_hpd_init(dev_priv); + } intel_opregion_register(dev_priv); - intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING, false); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING, false); intel_opregion_notify_adapter(dev_priv, PCI_D0); @@ -2700,7 +2734,8 @@ static int intel_runtime_suspend(struct device *kdev) assert_forcewakes_inactive(dev_priv); - if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) + if (INTEL_INFO(dev_priv)->num_pipes && (!IS_VALLEYVIEW(dev_priv) && + !IS_CHERRYVIEW(dev_priv))) intel_hpd_poll_init(dev_priv); DRM_DEBUG_KMS("Device suspended\n"); @@ -2757,10 +2792,12 @@ static int intel_runtime_resume(struct device *kdev) * power well, so hpd is reinitialized from there. For * everyone else do it here. */ - if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) + if (INTEL_INFO(dev_priv)->num_pipes && (!IS_VALLEYVIEW(dev_priv) && + !IS_CHERRYVIEW(dev_priv))) intel_hpd_init(dev_priv); - intel_enable_ipc(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_enable_ipc(dev_priv); enable_rpm_wakeref_asserts(dev_priv); diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c index 8f3aa4dc0c98..f697865236a6 100644 --- a/drivers/gpu/drm/i915/i915_suspend.c +++ b/drivers/gpu/drm/i915/i915_suspend.c @@ -63,11 +63,13 @@ int i915_save_state(struct drm_i915_private *dev_priv) mutex_lock(&dev_priv->drm.struct_mutex); - i915_save_display(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + i915_save_display(dev_priv); - if (IS_GEN4(dev_priv)) - pci_read_config_word(pdev, GCDGMBUS, - &dev_priv->regfile.saveGCDGMBUS); + if (IS_GEN4(dev_priv)) + pci_read_config_word(pdev, GCDGMBUS, + &dev_priv->regfile.saveGCDGMBUS); + } /* Cache mode state */ if (INTEL_GEN(dev_priv) < 7) @@ -108,10 +110,13 @@ int i915_restore_state(struct drm_i915_private *dev_priv) mutex_lock(&dev_priv->drm.struct_mutex); - if (IS_GEN4(dev_priv)) - pci_write_config_word(pdev, GCDGMBUS, - dev_priv->regfile.saveGCDGMBUS); - i915_restore_display(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) { + if (IS_GEN4(dev_priv)) + pci_write_config_word(pdev, GCDGMBUS, + dev_priv->regfile.saveGCDGMBUS); + + i915_restore_display(dev_priv); + } /* Cache mode state */ if (INTEL_GEN(dev_priv) < 7) @@ -143,7 +148,8 @@ int i915_restore_state(struct drm_i915_private *dev_priv) mutex_unlock(&dev_priv->drm.struct_mutex); - intel_i2c_reset(dev_priv); + if (INTEL_INFO(dev_priv)->num_pipes) + intel_i2c_reset(dev_priv); return 0; } diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c index 9575b7402172..97178d512852 100644 --- a/drivers/gpu/drm/i915/intel_runtime_pm.c +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c @@ -1049,7 +1049,8 @@ static void vlv_display_power_well_deinit(struct drm_i915_private *dev_priv) intel_power_sequencer_reset(dev_priv); /* Prevent us from re-enabling polling on accident in late suspend */ - if (!dev_priv->drm.dev->power.is_suspended) + if (INTEL_INFO(dev_priv)->num_pipes && + !dev_priv->drm.dev->power.is_suspended) intel_hpd_poll_init(dev_priv); }