diff mbox

drm/i915: Prepare GEM for suspend earlier

Message ID 20180522141709.23734-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson May 22, 2018, 2:17 p.m. UTC
In order to prepare the GPU for sleeping, we may want to submit commands
to it. This is a complicated process that may even require some swapping
in from shmemfs, if the GPU was in the wrong state. As such, we need to
do this preparation step synchronously before the rest of the system has
started to turn off (e.g. swapin fails if scsi is suspended).
Fortunately, we are provided with a such a hook, pm_ops.prepare().

Testcase: igt/drv_suspend after igt/gem_tiled_swapping
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.c | 43 +++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 7 deletions(-)

Comments

kernel test robot May 24, 2018, 5:27 p.m. UTC | #1
Hi Chris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.17-rc6 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Prepare-GEM-for-suspend-earlier/20180524-231951
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-x015-201820 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/gpu//drm/i915/i915_drv.c: In function 'i915_drm_suspend':
   drivers/gpu//drm/i915/i915_drv.c:1624:1: warning: label 'out' defined but not used [-Wunused-label]
    out:
    ^~~
>> drivers/gpu//drm/i915/i915_drv.c:1627:9: warning: 'error' is used uninitialized in this function [-Wuninitialized]
     return error;
            ^~~~~

vim +/error +1627 drivers/gpu//drm/i915/i915_drv.c

156987f3e drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2018-05-22  1574  
5e365c391 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-10-23  1575  static int i915_drm_suspend(struct drm_device *dev)
ba8bbcf6f drivers/char/drm/i915_drv.c     Jesse Barnes      2007-11-22  1576  {
fac5e23e3 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-07-04  1577  	struct drm_i915_private *dev_priv = to_i915(dev);
52a05c302 drivers/gpu/drm/i915/i915_drv.c David Weinehall   2016-08-22  1578  	struct pci_dev *pdev = dev_priv->drm.pdev;
e5747e3ad drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2014-06-12  1579  	pci_power_t opregion_target_state;
d58189385 drivers/gpu/drm/i915/i915_drv.c Daniel Vetter     2015-02-23  1580  	int error;
61caf87cb drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-18  1581  
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1582  	/* ignore lid events during suspend */
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1583  	mutex_lock(&dev_priv->modeset_restore_lock);
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1584  	dev_priv->modeset_restore = MODESET_SUSPENDED;
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1585  	mutex_unlock(&dev_priv->modeset_restore_lock);
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1586  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1587  	disable_rpm_wakeref_asserts(dev_priv);
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1588  
c67a470b1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-08-19  1589  	/* We do a lot of poking in a lot of registers, make sure they work
c67a470b1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-08-19  1590  	 * properly. */
da7e29bd5 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-02-18  1591  	intel_display_set_init_power(dev_priv, true);
cb10799c1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-01-25  1592  
5bcf719b7 drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2010-12-07  1593  	drm_kms_helper_poll_disable(dev);
5bcf719b7 drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2010-12-07  1594  
52a05c302 drivers/gpu/drm/i915/i915_drv.c David Weinehall   2016-08-22  1595  	pci_save_state(pdev);
ba8bbcf6f drivers/char/drm/i915_drv.c     Jesse Barnes      2007-11-22  1596  
6b72d4862 drivers/gpu/drm/i915/i915_drv.c Maarten Lankhorst 2015-06-01  1597  	intel_display_suspend(dev);
7d708ee40 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2013-04-17  1598  
0e32b39ce drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-05-02  1599  	intel_dp_mst_suspend(dev);
09b64267c drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-07-23  1600  
b963291cf drivers/gpu/drm/i915/i915_drv.c Daniel Vetter     2014-09-30  1601  	intel_runtime_pm_disable_interrupts(dev_priv);
1d0d343ab drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1602  	intel_hpd_cancel_work(dev_priv);
0e32b39ce drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-05-02  1603  
07f9cd0b3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1604  	intel_suspend_encoders(dev_priv);
07f9cd0b3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1605  
712bf3644 drivers/gpu/drm/i915/i915_drv.c Ville Syrjälä     2016-10-31  1606  	intel_suspend_hw(dev_priv);
5669fcacc drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2009-02-17  1607  
275a991c0 drivers/gpu/drm/i915/i915_drv.c Tvrtko Ursulin    2016-11-16  1608  	i915_gem_suspend_gtt_mappings(dev_priv);
828c79087 drivers/gpu/drm/i915/i915_drv.c Ben Widawsky      2013-10-16  1609  
af6dc7425 drivers/gpu/drm/i915/i915_drv.c Tvrtko Ursulin    2016-12-01  1610  	i915_save_state(dev_priv);
9e06dd39f drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2009-06-22  1611  
bc87229f3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-11-18  1612  	opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold;
6f9f4b7a2 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-05-23  1613  	intel_opregion_notify_adapter(dev_priv, opregion_target_state);
e5747e3ad drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2014-06-12  1614  
68f60946c drivers/gpu/drm/i915/i915_drv.c Hans de Goede     2017-02-10  1615  	intel_uncore_suspend(dev_priv);
03d92e477 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-05-23  1616  	intel_opregion_unregister(dev_priv);
8ee1c3db9 drivers/gpu/drm/i915/i915_drv.c Matthew Garrett   2008-08-05  1617  
82e3b8c13 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2014-08-13  1618  	intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true);
3fa016a0b drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2012-03-28  1619  
62d5d69b4 drivers/gpu/drm/i915/i915_drv.c Mika Kuoppala     2014-02-25  1620  	dev_priv->suspend_count++;
62d5d69b4 drivers/gpu/drm/i915/i915_drv.c Mika Kuoppala     2014-02-25  1621  
f74ed08d5 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2016-04-18  1622  	intel_csr_ucode_suspend(dev_priv);
f514c2d84 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-10-28  1623  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16 @1624  out:
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1625  	enable_rpm_wakeref_asserts(dev_priv);
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1626  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16 @1627  	return error;
84b79f8d2 drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-07  1628  }
84b79f8d2 drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-07  1629  

:::::: The code at line 1627 was first introduced by commit
:::::: 1f814daca43a2d99248fd754eacfb8ba12449235 drm/i915: add support for checking if we hold an RPM reference

:::::: TO: Imre Deak <imre.deak@intel.com>
:::::: CC: Imre Deak <imre.deak@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot May 24, 2018, 5:34 p.m. UTC | #2
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.17-rc6 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Prepare-GEM-for-suspend-earlier/20180524-231951
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x000-201820 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/gpu//drm/i915/i915_drv.c: In function 'i915_drm_suspend':
>> drivers/gpu//drm/i915/i915_drv.c:1624:1: error: label 'out' defined but not used [-Werror=unused-label]
    out:
    ^~~
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_read
   Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_write
   Cyclomatic Complexity 2 arch/x86/include/asm/bitops.h:clear_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls
   Cyclomatic Complexity 1 arch/x86/include/asm/arch_hweight.h:__arch_hweight32
   Cyclomatic Complexity 1 arch/x86/include/asm/arch_hweight.h:__arch_hweight8
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32
   Cyclomatic Complexity 1 include/linux/list.h:list_empty
   Cyclomatic Complexity 1 arch/x86/include/asm/mem_encrypt.h:sme_active
   Cyclomatic Complexity 1 include/linux/mem_encrypt.h:sme_get_me_mask
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_dec
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_read
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_inc
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_dec
   Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 3 include/linux/err.h:IS_ERR_OR_NULL
   Cyclomatic Complexity 1 include/linux/lockdep.h:lock_is_held
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock_irq
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irq
   Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
   Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
   Cyclomatic Complexity 3 include/linux/ktime.h:ktime_compare
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_after
   Cyclomatic Complexity 1 include/linux/workqueue.h:queue_delayed_work
   Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 3 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/device.h:dev_pm_set_driver_flags
   Cyclomatic Complexity 1 include/linux/pci.h:pci_disable_msi
   Cyclomatic Complexity 1 include/linux/pci.h:pci_enable_msi
   Cyclomatic Complexity 1 arch/x86/include/asm/pci.h:pci_domain_nr
   Cyclomatic Complexity 1 include/linux/pci.h:pci_get_drvdata
   Cyclomatic Complexity 1 include/linux/pci.h:pci_set_drvdata
   Cyclomatic Complexity 1 arch/x86/include/asm/dma-mapping.h:get_arch_dma_ops
   Cyclomatic Complexity 4 include/linux/dma-mapping.h:get_dma_ops
   Cyclomatic Complexity 3 include/linux/dma-mapping.h:dma_check_mask
   Cyclomatic Complexity 4 include/linux/dma-mapping.h:dma_supported
   Cyclomatic Complexity 2 include/linux/dma-mapping.h:dma_set_coherent_mask
   Cyclomatic Complexity 1 include/linux/vgaarb.h:vga_client_register
   Cyclomatic Complexity 2 include/linux/fb.h:alloc_apertures
   Cyclomatic Complexity 1 include/linux/vga_switcheroo.h:vga_switcheroo_unregister_client
   Cyclomatic Complexity 1 include/linux/vga_switcheroo.h:vga_switcheroo_register_client
   Cyclomatic Complexity 1 include/linux/vga_switcheroo.h:vga_switcheroo_process_delayed_switch
   Cyclomatic Complexity 1 include/drm/drm_print.h:drm_debug_printer
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_utils.h:onoff
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/intel_device_info.h:sseu_subslice_total
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_ringbuffer.h:intel_engine_flag
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_uncore.h:intel_wait_for_register
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_gpu_error.h:i915_reset_error_state
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_gvt.h:intel_gvt_init
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_gvt.h:intel_gvt_cleanup
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_gvt.h:intel_gvt_sanitize_options
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.h:to_i915
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.h:kdev_to_i915
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.h:intel_info
   Cyclomatic Complexity 1 include/drm/drm_fb_helper.h:drm_fb_helper_remove_conflicting_framebuffers
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_drv.h:disable_rpm_wakeref_asserts
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/intel_drv.h:enable_rpm_wakeref_asserts
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.h:i915_queue_hangcheck
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.h:intel_vgpu_active
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.h:i915_gem_drain_freed_objects
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.h:i915_gem_drain_workqueue
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.h:mkwrite_device_info
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_error_injected
   Cyclomatic Complexity 6 drivers/gpu//drm/i915/i915_drv.c:intel_is_virt_pch
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_switcheroo_can_switch
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_kick_out_vgacon
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:intel_init_dpio
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:intel_gt_reset_engine
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:vlv_save_gunit_s0ix_state
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:vlv_restore_gunit_s0ix_state
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_gem_reject_pin_ioctl
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_engines_cleanup
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_kick_out_firmware_fb
   Cyclomatic Complexity 14 drivers/gpu//drm/i915/i915_drv.c:intel_virt_detect_pch
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:vlv_check_no_gt_access
   Cyclomatic Complexity 42 drivers/gpu//drm/i915/i915_drv.c:i915_getparam_ioctl
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_lastclose
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_postclose
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_driver_open
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_workqueues_cleanup
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_workqueues_init
   Cyclomatic Complexity 59 drivers/gpu//drm/i915/i915_drv.c:intel_pch_type
   Cyclomatic Complexity 10 drivers/gpu//drm/i915/i915_drv.c:intel_detect_pch
   Cyclomatic Complexity 8 drivers/gpu//drm/i915/i915_drv.c:intel_detect_preproduction_hw
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_get_bridge_dev
   Cyclomatic Complexity 7 drivers/gpu//drm/i915/i915_drv.c:intel_alloc_mchbar_resource
   Cyclomatic Complexity 7 drivers/gpu//drm/i915/i915_drv.c:intel_setup_mchbar
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_mmio_setup
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:intel_sanitize_options
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:vlv_wait_for_pw_status
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:vlv_allow_gt_wake
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:vlv_wait_for_gt_wells
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_drm_resume
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_pm_resume
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_pm_thaw
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_pm_restore
   Cyclomatic Complexity 5 drivers/gpu//drm/i915/i915_drv.c:intel_suspend_encoders
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:suspend_to_idle
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_drm_suspend
>> drivers/gpu//drm/i915/i915_drv.c:1627:9: error: 'error' is used uninitialized in this function [-Werror=uninitialized]
     return error;
            ^~~~~
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_vga_set_decode
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_gem_fini
   Cyclomatic Complexity 6 drivers/gpu//drm/i915/i915_drv.c:i915_driver_register
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_welcome_messages
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_driver_cleanup_hw
   Cyclomatic Complexity 5 drivers/gpu//drm/i915/i915_drv.c:intel_teardown_mchbar
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_mmio_cleanup
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_cleanup_mmio
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_cleanup_early
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_release
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_driver_unregister
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_drm_prepare
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:i915_pm_suspend
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:i915_pm_prepare
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:i915_pm_freeze
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:__i915_inject_load_failure
   Cyclomatic Complexity 5 drivers/gpu//drm/i915/i915_drv.c:i915_driver_init_early
   Cyclomatic Complexity 5 drivers/gpu//drm/i915/i915_drv.c:i915_driver_init_mmio
   Cyclomatic Complexity 14 drivers/gpu//drm/i915/i915_drv.c:i915_driver_init_hw
   Cyclomatic Complexity 11 drivers/gpu//drm/i915/i915_drv.c:i915_load_modeset_init
   Cyclomatic Complexity 6 drivers/gpu//drm/i915/i915_drv.c:__i915_printk
   Cyclomatic Complexity 13 drivers/gpu//drm/i915/i915_drv.c:i915_driver_load
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_driver_unload
   Cyclomatic Complexity 15 drivers/gpu//drm/i915/i915_drv.c:i915_reset
   Cyclomatic Complexity 6 drivers/gpu//drm/i915/i915_drv.c:i915_reset_engine
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:vlv_force_gfx_clock
   Cyclomatic Complexity 5 drivers/gpu//drm/i915/i915_drv.c:vlv_resume_prepare
   Cyclomatic Complexity 9 drivers/gpu//drm/i915/i915_drv.c:i915_drm_resume_early
   Cyclomatic Complexity 3 drivers/gpu//drm/i915/i915_drv.c:i915_resume_switcheroo
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_pm_resume_early
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_pm_thaw_early
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/i915_drv.c:i915_pm_restore_early
   Cyclomatic Complexity 18 drivers/gpu//drm/i915/i915_drv.c:intel_runtime_resume
   Cyclomatic Complexity 6 drivers/gpu//drm/i915/i915_drv.c:vlv_suspend_complete
   Cyclomatic Complexity 14 drivers/gpu//drm/i915/i915_drv.c:i915_drm_suspend_late
   Cyclomatic Complexity 8 drivers/gpu//drm/i915/i915_drv.c:i915_suspend_switcheroo
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_switcheroo_set_state
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_pm_suspend_late
   Cyclomatic Complexity 2 drivers/gpu//drm/i915/i915_drv.c:i915_pm_poweroff_late
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/i915_drv.c:i915_pm_freeze_late
   Cyclomatic Complexity 23 drivers/gpu//drm/i915/i915_drv.c:intel_runtime_suspend
   Cyclomatic Complexity 4 drivers/gpu//drm/i915/selftests/mock_drm.c:mock_file
   Cyclomatic Complexity 1 drivers/gpu//drm/i915/selftests/mock_drm.c:mock_file_free
   cc1: all warnings being treated as errors

vim +/out +1624 drivers/gpu//drm/i915/i915_drv.c

156987f3e drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2018-05-22  1574  
5e365c391 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-10-23  1575  static int i915_drm_suspend(struct drm_device *dev)
ba8bbcf6f drivers/char/drm/i915_drv.c     Jesse Barnes      2007-11-22  1576  {
fac5e23e3 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-07-04  1577  	struct drm_i915_private *dev_priv = to_i915(dev);
52a05c302 drivers/gpu/drm/i915/i915_drv.c David Weinehall   2016-08-22  1578  	struct pci_dev *pdev = dev_priv->drm.pdev;
e5747e3ad drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2014-06-12  1579  	pci_power_t opregion_target_state;
d58189385 drivers/gpu/drm/i915/i915_drv.c Daniel Vetter     2015-02-23  1580  	int error;
61caf87cb drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-18  1581  
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1582  	/* ignore lid events during suspend */
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1583  	mutex_lock(&dev_priv->modeset_restore_lock);
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1584  	dev_priv->modeset_restore = MODESET_SUSPENDED;
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1585  	mutex_unlock(&dev_priv->modeset_restore_lock);
b8efb17b3 drivers/gpu/drm/i915/i915_drv.c Zhang Rui         2013-02-05  1586  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1587  	disable_rpm_wakeref_asserts(dev_priv);
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1588  
c67a470b1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-08-19  1589  	/* We do a lot of poking in a lot of registers, make sure they work
c67a470b1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-08-19  1590  	 * properly. */
da7e29bd5 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-02-18  1591  	intel_display_set_init_power(dev_priv, true);
cb10799c1 drivers/gpu/drm/i915/i915_drv.c Paulo Zanoni      2013-01-25  1592  
5bcf719b7 drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2010-12-07  1593  	drm_kms_helper_poll_disable(dev);
5bcf719b7 drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2010-12-07  1594  
52a05c302 drivers/gpu/drm/i915/i915_drv.c David Weinehall   2016-08-22  1595  	pci_save_state(pdev);
ba8bbcf6f drivers/char/drm/i915_drv.c     Jesse Barnes      2007-11-22  1596  
6b72d4862 drivers/gpu/drm/i915/i915_drv.c Maarten Lankhorst 2015-06-01  1597  	intel_display_suspend(dev);
7d708ee40 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2013-04-17  1598  
0e32b39ce drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-05-02  1599  	intel_dp_mst_suspend(dev);
09b64267c drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-07-23  1600  
b963291cf drivers/gpu/drm/i915/i915_drv.c Daniel Vetter     2014-09-30  1601  	intel_runtime_pm_disable_interrupts(dev_priv);
1d0d343ab drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1602  	intel_hpd_cancel_work(dev_priv);
0e32b39ce drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2014-05-02  1603  
07f9cd0b3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1604  	intel_suspend_encoders(dev_priv);
07f9cd0b3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2014-08-18  1605  
712bf3644 drivers/gpu/drm/i915/i915_drv.c Ville Syrjälä     2016-10-31  1606  	intel_suspend_hw(dev_priv);
5669fcacc drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2009-02-17  1607  
275a991c0 drivers/gpu/drm/i915/i915_drv.c Tvrtko Ursulin    2016-11-16  1608  	i915_gem_suspend_gtt_mappings(dev_priv);
828c79087 drivers/gpu/drm/i915/i915_drv.c Ben Widawsky      2013-10-16  1609  
af6dc7425 drivers/gpu/drm/i915/i915_drv.c Tvrtko Ursulin    2016-12-01  1610  	i915_save_state(dev_priv);
9e06dd39f drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2009-06-22  1611  
bc87229f3 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-11-18  1612  	opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold;
6f9f4b7a2 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-05-23  1613  	intel_opregion_notify_adapter(dev_priv, opregion_target_state);
e5747e3ad drivers/gpu/drm/i915/i915_drv.c Jesse Barnes      2014-06-12  1614  
68f60946c drivers/gpu/drm/i915/i915_drv.c Hans de Goede     2017-02-10  1615  	intel_uncore_suspend(dev_priv);
03d92e477 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2016-05-23  1616  	intel_opregion_unregister(dev_priv);
8ee1c3db9 drivers/gpu/drm/i915/i915_drv.c Matthew Garrett   2008-08-05  1617  
82e3b8c13 drivers/gpu/drm/i915/i915_drv.c Chris Wilson      2014-08-13  1618  	intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true);
3fa016a0b drivers/gpu/drm/i915/i915_drv.c Dave Airlie       2012-03-28  1619  
62d5d69b4 drivers/gpu/drm/i915/i915_drv.c Mika Kuoppala     2014-02-25  1620  	dev_priv->suspend_count++;
62d5d69b4 drivers/gpu/drm/i915/i915_drv.c Mika Kuoppala     2014-02-25  1621  
f74ed08d5 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2016-04-18  1622  	intel_csr_ucode_suspend(dev_priv);
f514c2d84 drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-10-28  1623  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16 @1624  out:
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1625  	enable_rpm_wakeref_asserts(dev_priv);
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16  1626  
1f814daca drivers/gpu/drm/i915/i915_drv.c Imre Deak         2015-12-16 @1627  	return error;
84b79f8d2 drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-07  1628  }
84b79f8d2 drivers/gpu/drm/i915/i915_drv.c Rafael J. Wysocki 2010-02-07  1629  

:::::: The code at line 1624 was first introduced by commit
:::::: 1f814daca43a2d99248fd754eacfb8ba12449235 drm/i915: add support for checking if we hold an RPM reference

:::::: TO: Imre Deak <imre.deak@intel.com>
:::::: CC: Imre Deak <imre.deak@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 9c449b8d8eab..256642fb8315 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1553,6 +1553,25 @@  static bool suspend_to_idle(struct drm_i915_private *dev_priv)
 	return false;
 }
 
+static int i915_drm_prepare(struct drm_device *dev)
+{
+	struct drm_i915_private *i915 = to_i915(dev);
+	int err;
+
+	disable_rpm_wakeref_asserts(i915);
+
+	err = i915_gem_suspend(i915);
+	if (err) {
+		dev_err(&i915->drm.pdev->dev,
+			"GEM idle failed, suspend/resume might fail\n");
+		goto out;
+	}
+out:
+	enable_rpm_wakeref_asserts(i915);
+
+	return err;
+}
+
 static int i915_drm_suspend(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -1575,13 +1594,6 @@  static int i915_drm_suspend(struct drm_device *dev)
 
 	pci_save_state(pdev);
 
-	error = i915_gem_suspend(dev_priv);
-	if (error) {
-		dev_err(&pdev->dev,
-			"GEM idle failed, resume might fail\n");
-		goto out;
-	}
-
 	intel_display_suspend(dev);
 
 	intel_dp_mst_suspend(dev);
@@ -2081,6 +2093,22 @@  int i915_reset_engine(struct intel_engine_cs *engine, const char *msg)
 	return ret;
 }
 
+static int i915_pm_prepare(struct device *kdev)
+{
+	struct pci_dev *pdev = to_pci_dev(kdev);
+	struct drm_device *dev = pci_get_drvdata(pdev);
+
+	if (!dev) {
+		dev_err(kdev, "DRM not initialized, aborting suspend.\n");
+		return -ENODEV;
+	}
+
+	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+		return 0;
+
+	return i915_drm_prepare(dev);
+}
+
 static int i915_pm_suspend(struct device *kdev)
 {
 	struct pci_dev *pdev = to_pci_dev(kdev);
@@ -2731,6 +2759,7 @@  const struct dev_pm_ops i915_pm_ops = {
 	 * S0ix (via system suspend) and S3 event handlers [PMSG_SUSPEND,
 	 * PMSG_RESUME]
 	 */
+	.prepare = i915_pm_prepare,
 	.suspend = i915_pm_suspend,
 	.suspend_late = i915_pm_suspend_late,
 	.resume_early = i915_pm_resume_early,