1. 07 9月, 2018 3 次提交
  2. 16 7月, 2018 3 次提交
    • L
      drm/nouveau: Fix runtime PM leak in drm_open() · 922a8c82
      Lyude Paul 提交于
      Noticed this as I was skimming through, if we fail to allocate memory
      for cli we'll end up returning without dropping the runtime PM ref we
      got. Additionally, we'll even return the wrong return code! (ret most
      likely will == 0 here, we want -ENOMEM).
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Reviewed-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
      922a8c82
    • L
      drm/nouveau: Set DRIVER_ATOMIC cap earlier to fix debugfs · eb493fbc
      Lyude Paul 提交于
      Currently nouveau doesn't actually expose the state debugfs file that's
      usually provided for any modesetting driver that supports atomic, even
      if nouveau is loaded with atomic=1. This is due to the fact that the
      standard debugfs files that DRM creates for atomic drivers is called
      when drm_get_pci_dev() is called from nouveau_drm.c. This happens well
      before we've initialized the display core, which is currently
      responsible for setting the DRIVER_ATOMIC cap.
      
      So, move the atomic option into nouveau_drm.c and just add the
      DRIVER_ATOMIC cap whenever it's enabled on the kernel commandline. This
      shouldn't cause any actual issues, as the atomic ioctl will still fail
      as expected even if the display core doesn't disable it until later in
      the init sequence. This also provides the added benefit of being able to
      use the state debugfs file to check the current display state even if
      clients aren't allowed to modify it through anything other than the
      legacy ioctls.
      
      Additionally, disable the DRIVER_ATOMIC cap in nv04's display core, as
      this was already disabled there previously.
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
      eb493fbc
    • L
      drm/nouveau: Remove bogus crtc check in pmops_runtime_idle · 68fe23a6
      Lyude Paul 提交于
      This both uses the legacy modesetting structures in a racy manner, and
      additionally also doesn't even check the right variable (enabled != the
      CRTC is actually turned on for atomic).
      
      This fixes issues on my P50 regarding the dedicated GPU not entering
      runtime suspend.
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
      68fe23a6
  3. 18 5月, 2018 5 次提交
  4. 14 3月, 2018 2 次提交
    • L
      drm/nouveau: Runtime suspend despite HDA being unbound · fd1eabd8
      Lukas Wunner 提交于
      Commit 5addcf0a ("nouveau: add runtime PM support (v0.9)") prevents
      runtime suspend of the GPU if its integrated HDA controller is not bound
      to a driver.  The rationale appears to be that probing the HDA fails if
      the GPU is in D3cold.
      
      However we now use a device link to ensure that the GPU is runtime
      resumed while the HDA controller is probed, rendering this safety
      measure obsolete.  Remove it.
      
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NPeter Wu <peter@lekensteyn.nl>
      Tested-by: Denis Lisov <dennis.lissov@gmail.com>       # Nvidia Optimus
      Tested-by: Peter Wu <peter@lekensteyn.nl>              # Nvidia Optimus
      Tested-by: Lukas Wunner <lukas@wunner.de>              # MacBook Pro
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/77e0ab74f3377ea9b6acf8fab624acfb4f7dbeca.1520068884.git.lukas@wunner.de
      fd1eabd8
    • L
      vga_switcheroo: Use device link for HDA controller · 07f4f97d
      Lukas Wunner 提交于
      Back in 2013, runtime PM for GPUs with integrated HDA controller was
      introduced with commits 0d69704a ("gpu/vga_switcheroo: add driver
      control power feature. (v3)") and 246efa4a ("snd/hda: add runtime
      suspend/resume on optimus support (v4)").
      
      Briefly, the idea was that the HDA controller is forced on and off in
      unison with the GPU.
      
      The original code is mostly still in place even though it was never a
      100% perfect solution:  E.g. on access to the HDA controller, the GPU
      is powered up via vga_switcheroo_runtime_resume_hdmi_audio() but there
      are no provisions to keep it resumed until access to the HDA controller
      has ceased:  The GPU autosuspends after 5 seconds, rendering the HDA
      controller inaccessible.
      
      Additionally, a kludge is required when hda_intel.c probes:  It has to
      check whether the GPU is powered down (check_hdmi_disabled()) and defer
      probing if so.
      
      However in the meantime (in v4.10) the driver core has gained a feature
      called device links which promises to solve such issues in a clean way:
      It allows us to declare a dependency from the HDA controller (consumer)
      to the GPU (supplier).  The PM core then automagically ensures that the
      GPU is runtime resumed as long as the HDA controller's ->probe hook is
      executed and whenever the HDA controller is accessed.
      
      By default, the HDA controller has a dependency on its parent, a PCIe
      Root Port.  Adding a device link creates another dependency on its
      sibling:
      
                                  PCIe Root Port
                                   ^          ^
                                   |          |
                                   |          |
                                  HDA  ===>  GPU
      
      The device link is not only used for runtime PM, it also guarantees that
      on system sleep, the HDA controller suspends before the GPU and resumes
      after the GPU, and on system shutdown the HDA controller's ->shutdown
      hook is executed before the one of the GPU.  It is a complete solution.
      
      Using this functionality is as simple as calling device_link_add(),
      which results in a dmesg entry like this:
      
              pci 0000:01:00.1: Linked as a consumer to 0000:01:00.0
      
      The code for the GPU-governed audio power management can thus be removed
      (except where it's still needed for legacy manual power control).
      
      The device link is added in a PCI quirk rather than in hda_intel.c.
      It is therefore legal for the GPU to runtime suspend to D3cold even if
      the HDA controller is not bound to a driver or if CONFIG_SND_HDA_INTEL
      is not enabled, for accesses to the HDA controller will cause the GPU to
      wake up regardless if they're occurring outside of hda_intel.c (think
      config space readout via sysfs).
      
      Contrary to the previous implementation, the HDA controller's power
      state is now self-governed, rather than GPU-governed, whereas the GPU's
      power state is no longer fully self-governed.  (The HDA controller needs
      to runtime suspend before the GPU can.)
      
      It is thus crucial that runtime PM is always activated on the HDA
      controller even if CONFIG_SND_HDA_POWER_SAVE_DEFAULT is set to 0 (which
      is the default), lest the GPU stays awake.  This is achieved by setting
      the auto_runtime_pm flag on every codec and the AZX_DCAPS_PM_RUNTIME
      flag on the HDA controller.
      
      A side effect is that power consumption might be reduced if the GPU is
      in use but the HDA controller is not, because the HDA controller is now
      allowed to go to D3hot.  Before, it was forced to stay in D0 as long as
      the GPU was in use.  (There is no reduction in power consumption on my
      Nvidia GK107, but there might be on other chips.)
      
      The code paths for legacy manual power control are adjusted such that
      runtime PM is disabled during power off, thereby preventing the PM core
      from resuming the HDA controller.
      
      Note that the device link is not only added on vga_switcheroo capable
      systems, but for *any* GPU with integrated HDA controller.  The idea is
      that the HDA controller streams audio via connectors located on the GPU,
      so the GPU needs to be on for the HDA controller to do anything useful.
      
      This commit implicitly fixes an unbalanced runtime PM ref upon unbind of
      hda_intel.c:  On ->probe, a runtime PM ref was previously released under
      the condition "azx_has_pm_runtime(chip) || hda->use_vga_switcheroo", but
      on ->remove a runtime PM ref was only acquired under the first of those
      conditions.  Thus, binding and unbinding the driver twice on a
      vga_switcheroo capable system caused the runtime PM refcount to drop
      below zero.  The issue is resolved because the AZX_DCAPS_PM_RUNTIME flag
      is now always set if use_vga_switcheroo is true.
      
      For more information on device links please refer to:
      https://www.kernel.org/doc/html/latest/driver-api/device_link.html
      Documentation/driver-api/device_link.rst
      
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NTakashi Iwai <tiwai@suse.de>
      Reviewed-by: NPeter Wu <peter@lekensteyn.nl>
      Tested-by: Kai Heng Feng <kai.heng.feng@canonical.com> # AMD PowerXpress
      Tested-by: Mike Lothian <mike@fireburn.co.uk>          # AMD PowerXpress
      Tested-by: Denis Lisov <dennis.lissov@gmail.com>       # Nvidia Optimus
      Tested-by: Peter Wu <peter@lekensteyn.nl>              # Nvidia Optimus
      Tested-by: Lukas Wunner <lukas@wunner.de>              # MacBook Pro
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/51bd38360ff502a8c42b1ebf4405ee1d3f27118d.1520068884.git.lukas@wunner.de
      07f4f97d
  5. 12 1月, 2018 1 次提交
    • S
      drm/nouveau: deprecate pci_get_bus_and_slot() · 2fa6d6cd
      Sinan Kaya 提交于
      pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
      where a PCI device is present. This restricts the device drivers to be
      reused for other domain numbers.
      
      Getting ready to remove pci_get_bus_and_slot() function in favor of
      pci_get_domain_bus_and_slot().
      
      Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot()
      and extract the domain number from
      1. struct pci_dev
      2. struct pci_dev through drm_device->pdev
      3. struct pci_dev through fb->subdev->drm_device->pdev
      Signed-off-by: NSinan Kaya <okaya@codeaurora.org>
      Signed-off-by: NBjorn Helgaas <helgaas@kernel.org>
      2fa6d6cd
  6. 23 12月, 2017 1 次提交
  7. 02 11月, 2017 8 次提交
  8. 22 8月, 2017 1 次提交
  9. 29 7月, 2017 1 次提交
  10. 20 6月, 2017 2 次提交
  11. 16 6月, 2017 1 次提交
  12. 06 6月, 2017 2 次提交
    • B
      drm/nouveau: enable autosuspend only when it'll actually be used · 8fa4338a
      Ben Skeggs 提交于
      This prevents a deadlock that somehow results from the suspend() ->
      forbid() -> resume() callchain.
      
      [  125.266960] [drm] Initialized nouveau 1.3.1 20120801 for 0000:02:00.0 on minor 1
      [  370.120872] INFO: task kworker/4:1:77 blocked for more than 120 seconds.
      [  370.120920]       Tainted: G           O    4.12.0-rc3 #20
      [  370.120947] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [  370.120982] kworker/4:1     D13808    77      2 0x00000000
      [  370.120998] Workqueue: pm pm_runtime_work
      [  370.121004] Call Trace:
      [  370.121018]  __schedule+0x2bf/0xb40
      [  370.121025]  ? mark_held_locks+0x5f/0x90
      [  370.121038]  schedule+0x3d/0x90
      [  370.121044]  rpm_resume+0x107/0x870
      [  370.121052]  ? finish_wait+0x90/0x90
      [  370.121065]  ? pci_pm_runtime_resume+0xa0/0xa0
      [  370.121070]  pm_runtime_forbid+0x4c/0x60
      [  370.121129]  nouveau_pmops_runtime_suspend+0xaf/0xc0 [nouveau]
      [  370.121139]  pci_pm_runtime_suspend+0x5f/0x170
      [  370.121147]  ? pci_pm_runtime_resume+0xa0/0xa0
      [  370.121152]  __rpm_callback+0xb9/0x1e0
      [  370.121159]  ? pci_pm_runtime_resume+0xa0/0xa0
      [  370.121166]  rpm_callback+0x24/0x80
      [  370.121171]  ? pci_pm_runtime_resume+0xa0/0xa0
      [  370.121176]  rpm_suspend+0x138/0x6e0
      [  370.121192]  pm_runtime_work+0x7b/0xc0
      [  370.121199]  process_one_work+0x253/0x6a0
      [  370.121216]  worker_thread+0x4d/0x3b0
      [  370.121229]  kthread+0x133/0x150
      [  370.121234]  ? process_one_work+0x6a0/0x6a0
      [  370.121238]  ? kthread_create_on_node+0x70/0x70
      [  370.121246]  ret_from_fork+0x2a/0x40
      [  370.121283]
                     Showing all locks held in the system:
      [  370.121291] 2 locks held by kworker/4:1/77:
      [  370.121298]  #0:  ("pm"){.+.+.+}, at: [<ffffffffac0d3530>] process_one_work+0x1d0/0x6a0
      [  370.121315]  #1:  ((&dev->power.work)){+.+.+.}, at: [<ffffffffac0d3530>] process_one_work+0x1d0/0x6a0
      [  370.121330] 1 lock held by khungtaskd/81:
      [  370.121333]  #0:  (tasklist_lock){.+.+..}, at: [<ffffffffac10fc8d>] debug_show_all_locks+0x3d/0x1a0
      [  370.121355] 1 lock held by dmesg/1639:
      [  370.121358]  #0:  (&user->lock){+.+.+.}, at: [<ffffffffac124b6d>] devkmsg_read+0x4d/0x360
      
      [  370.121377] =============================================
      Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
      8fa4338a
    • B
  13. 17 5月, 2017 2 次提交
  14. 10 5月, 2017 1 次提交
    • D
      drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos · 1bf6ad62
      Daniel Vetter 提交于
      If we restrict this helper to only kms drivers (which is the case) we
      can look up the correct mode easily ourselves. But it's a bit tricky:
      
      - All legacy drivers look at crtc->hwmode. But that is updated already
        at the beginning of the modeset helper, which means when we disable
        a pipe. Hence the final timestamps might be a bit off. But since
        this is an existing bug I'm not going to change it, but just try to
        be bug-for-bug compatible with the current code. This only applies
        to radeon&amdgpu.
      
      - i915 tries to get it perfect by updating crtc->hwmode when the pipe
        is off (i.e. vblank->enabled = false).
      
      - All other atomic drivers look at crtc->state->adjusted_mode. Those
        that look at state->requested_mode simply don't adjust their mode,
        so it's the same. That has two problems: Accessing crtc->state from
        interrupt handling code is unsafe, and it's updated before we shut
        down the pipe. For nonblocking modesets it's even worse.
      
      For atomic drivers try to implement what i915 does. To do that we add
      a new hwmode field to the vblank structure, and update it from
      drm_calc_timestamping_constants(). For atomic drivers that's called
      from the right spot by the helper library already, so all fine. But
      for safety let's enforce that.
      
      For legacy driver this function is only called at the end (oh the
      fun), which is broken, so again let's not bother and just stay
      bug-for-bug compatible.
      
      The  benefit is that we can use drm_calc_vbltimestamp_from_scanoutpos
      directly to implement ->get_vblank_timestamp in every driver, deleting
      a lot of code.
      
      v2: Completely new approach, trying to mimick the i915 solution.
      
      v3: Fixup kerneldoc.
      
      v4: Drop the WARN_ON to check that the vblank is off, atomic helpers
      currently unconditionally call this. Recomputing the same stuff should
      be harmless.
      
      v5: Fix typos and move misplaced hunks to the right patches (Neil).
      
      v6: Undo hunk movement (kbuild).
      
      Cc: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: linux-arm-msm@vger.kernel.org
      Cc: freedreno@lists.freedesktop.org
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Reviewed-by: NNeil Armstrong <narmstrong@baylibre.com>
      Acked-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20170509140329.24114-4-daniel.vetter@ffwll.ch
      1bf6ad62
  15. 09 5月, 2017 1 次提交
  16. 01 3月, 2017 1 次提交
  17. 17 2月, 2017 5 次提交