1. 31 5月, 2016 1 次提交
    • L
      vga_switcheroo: Add helper for deferred probing · b00e5334
      Lukas Wunner 提交于
      So far we've got one condition when DRM drivers need to defer probing
      on a dual GPU system and it's coded separately into each of the relevant
      drivers. As suggested by Daniel Vetter, deduplicate that code in the
      drivers and move it to a new vga_switcheroo helper. This yields better
      encapsulation of concepts and lets us add further checks in a central
      place. (The existing check pertains to pre-retina MacBook Pros and an
      additional check is expected to be needed for retinas.)
      
      One might be tempted to check deferred probing conditions in
      vga_switcheroo_register_client(), but this is usually called fairly late
      during driver load. The GPU is fully brought up and ready for switching
      at that point. On boot the ->probe hook is potentially called dozens of
      times until it finally succeeds, and each time we'd repeat bringup and
      teardown of the GPU, lengthening boot time considerably and cluttering
      logfiles. A separate helper is therefore needed which can be called
      right at the beginning of the ->probe hook.
      
      Note that amdgpu currently does not call this helper as the AMD GPUs
      built into MacBook Pros are only supported by radeon so far.
      
      v2: This helper could eventually be used by audio clients as well,
          so rephrase kerneldoc to refer to "client" instead of "GPU"
          and move the single existing check in an if block specific
          to PCI_CLASS_DISPLAY_VGA devices. Move documentation on
          that check from kerneldoc to a comment. (Daniel Vetter)
      
      v3: Mandate in kerneldoc that registration of client shall only
          happen after calling this helper. (Daniel Vetter)
      
      v4: Rebase on 412c8f7d ("drm/radeon: Return -EPROBE_DEFER when
          amdkfd not loaded")
      
      v5: Some Optimus GPUs use PCI_CLASS_DISPLAY_3D, make sure those are
          matched as well. (Emil Velikov)
      
      v6: The if-condition referring to PCI_BASE_CLASS_DISPLAY may be
          considered a functional change. Move to a separate commit to
          keep this a pure refactoring change. (Emil Velikov, Jani Nikula)
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/575885fd440c2b13c3f19ddf44360cfbbff35f50.1464685538.git.lukas@wunner.de
      b00e5334
  2. 09 2月, 2016 2 次提交
    • L
      vga_switcheroo: Add support for switching only the DDC · e4cb81d7
      Lukas Wunner 提交于
      Originally by Seth Forshee <seth.forshee@canonical.com>, 2012-10-04:
          During graphics driver initialization it's useful to be able to mux
          only the DDC to the inactive client in order to read the EDID. Add
          a switch_ddc callback to allow capable handlers to provide this
          functionality, and add vga_switcheroo_switch_ddc() to allow DRM
          to mux only the DDC.
      
      Modified by Dave Airlie <airlied@gmail.com>, 2012-12-22:
          I can't figure out why I didn't like this, but I rewrote this [...]
          to lock/unlock the ddc lines [...]. I think I'd prefer something
          like that otherwise the interface got really ugly.
      
      Modified by Lukas Wunner <lukas@wunner.de>, 2015-04 - 2015-10:
          Change semantics of ->switch_ddc handler callback to return previous
          DDC owner. Original version tried to determine previous DDC owner
          with find_active_client() but this fails if the inactive client
          registers before the active client.
      
          Don't lock vgasr_mutex in _lock_ddc() / _unlock_ddc(), it can cause
          deadlocks because (a) during switch (with vgasr_mutex already held),
          GPU is woken and probes its outputs, tries to re-acquire vgasr_mutex
          to lock DDC lines; (b) Likewise during switch, GPU is suspended and
          calls cancel_delayed_work_sync() to stop output polling, if poll
          task is running at this moment we may wait forever for it to finish.
      
          Instead, lock mux_hw_lock when unregistering the handler because
          the only reason why we'd want to lock vgasr_mutex in _lock_ddc() /
          _unlock_ddc() is to block the handler from disappearing while DDC
          lines are switched.
      
          Also acquire mux_hw_lock in stage2 to avoid race condition where
          reading the EDID and switching happens simultaneously. Likewise on
          MIGD / MDIS commands and on runtime suspend.
      
          v2.1: Overhaul locking, squash commits (Daniel Vetter)
      
          v2.2: Readability improvements (Thierry Reding)
      
          v2.3: Overhaul locking once more
      
          v2.4: Retain semantics of ->switchto handler callback to switch all
                pins, including DDC (Daniel Vetter)
      
          v5:   Rename ddc_lock to mux_hw_lock: Since we acquire this both
                when calling ->switch_ddc and ->switchto, it protects not just
                access to the DDC lines but to the mux in general. This is in
                line with the DRM convention to use low-level locks to avoid
                concurrent hw access (e.g. i2c, dp_aux) which are often called
                hw_lock (Daniel Vetter)
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88861
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61115Tested-by: NLukas Wunner <lukas@wunner.de>
          [MBP  9,1 2012  intel IVB + nvidia GK107  pre-retina  15"]
      Cc: Seth Forshee <seth.forshee@canonical.com>
      Cc: Dave Airlie <airlied@gmail.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/e81ae9722b84c5ed591805fee3ea6dbf5dc6c4b3.1452525860.git.lukas@wunner.de
      e4cb81d7
    • L
      vga_switcheroo: Add handler flags infrastructure · 156d7d41
      Lukas Wunner 提交于
      Allow handlers to declare their capabilities and allow clients to
      obtain that information. So far we have these use cases:
      
      * If the handler is able to switch DDC separately, clients need to
        probe EDID with drm_get_edid_switcheroo(). We should allow them
        to detect a capable handler to ensure this function only gets
        called when needed.
      
      * Likewise if the handler is unable to switch AUX separately, the active
        client needs to communicate link training parameters to the inactive
        client, which may then skip the AUX handshake and set up its output
        with these pre-calibrated values (DisplayPort specification v1.1a,
        section 2.5.3.3). Clients need a way to recognize such a situation.
      
      The flags for the radeon_atpx_handler and amdgpu_atpx_handler are
      initially set to 0, this can later on be amended with
        handler_flags |= VGA_SWITCHEROO_CAN_SWITCH_DDC;
      when a ->switch_ddc callback is added.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88861
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61115Tested-by: NLukas Wunner <lukas@wunner.de>
          [MBP  9,1 2012  intel IVB + nvidia GK107  pre-retina  15"]
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Reviewed-by: NDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: http://patchwork.freedesktop.org/patch/msgid/2b0d93ed6e511ca09e95e45e0b35627f330fabce.1452525860.git.lukas@wunner.de
      156d7d41
  3. 08 1月, 2016 1 次提交
  4. 04 1月, 2016 1 次提交
  5. 05 11月, 2015 1 次提交
    • L
      vga_switcheroo: Drop client power state VGA_SWITCHEROO_INIT · e02328f4
      Lukas Wunner 提交于
      hda_intel.c:azx_probe() defers initialization of an audio controller
      on the discrete GPU if the GPU is powered off. The power state of the
      GPU is determined by calling vga_switcheroo_get_client_state().
      
      vga_switcheroo_get_client_state() returns VGA_SWITCHEROO_INIT if
      vga_switcheroo is not enabled, i.e. if no second GPU or no handler
      has registered.
      
      This can go wrong in the following scenario:
      - Driver for the integrated GPU is not loaded.
      - Driver for the discrete GPU registers with vga_switcheroo, uses driver
        power control to power down the GPU, handler cuts power to the GPU.
      - Driver for the audio controller gets loaded after the GPU was powered
        down, calls vga_switcheroo_get_client_state() which returns
        VGA_SWITCHEROO_INIT instead of VGA_SWITCHEROO_OFF.
      - Consequence: azx_probe() tries to initialize the audio controller even
        though the GPU is powered down.
      
      The power state VGA_SWITCHEROO_INIT was introduced by c8e9cf7b
      ("vga_switcheroo: Add a helper function to get the client state").
      It is not apparent what its benefit might be. The idea seems to
      be to initialize the audio controller even if the power state is
      VGA_SWITCHEROO_OFF (were vga_switcheroo enabled), but as shown
      above this can fail.
      
      Drop VGA_SWITCHEROO_INIT to solve this.
      Acked-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      e02328f4
  6. 21 10月, 2015 1 次提交
    • L
      vga_switcheroo: Constify vga_switcheroo_handler · 5d170139
      Lukas Wunner 提交于
      vga_switcheroo_client_ops has always been declared const since its
      introduction with 26ec685f ("vga_switcheroo: Introduce struct
      vga_switcheroo_client_ops").
      
      Do so for vga_switcheroo_handler as well.
      
       drivers/gpu/drm/amd/amdgpu/amdgpu.ko:
         6 .rodata       00009888
      - 19 .data         00001f00
      + 19 .data         00001ee0
       drivers/gpu/drm/nouveau/nouveau.ko:
         6 .rodata       000460b8
        17 .data         00018fe0
       drivers/gpu/drm/radeon/radeon.ko:
      -  7 .rodata       00030944
      +  7 .rodata       00030964
      - 21 .data         0000d6a0
      + 21 .data         0000d678
       drivers/platform/x86/apple-gmux.ko:
      -  7 .rodata       00000140
      +  7 .rodata       00000160
      - 11 .data         000000e0
      + 11 .data         000000b8
      
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Reviewed-by: Christian König <christian.koenig@amd.com>.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      5d170139
  7. 16 10月, 2015 3 次提交
  8. 02 10月, 2015 1 次提交
    • L
      vga_switcheroo: Add missing locking · 8f12a311
      Lukas Wunner 提交于
      The following functions iterate over the client list, invoke client
      callbacks or invoke handler callbacks without locking anything at all:
      
      - Introduced by c8e9cf7b ("vga_switcheroo: Add a helper function to
        get the client state"):
        vga_switcheroo_get_client_state()
      
      - Introduced by 0d69704a ("gpu/vga_switcheroo: add driver control
        power feature. (v3)"):
        vga_switcheroo_set_dynamic_switch()
        vga_switcheroo_runtime_suspend()
        vga_switcheroo_runtime_resume()
        vga_switcheroo_runtime_resume_hdmi_audio()
      
      Refactor vga_switcheroo_runtime_resume_hdmi_audio() a bit to be able to
      release vgasr_mutex immediately after iterating over the client list.
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      8f12a311
  9. 25 9月, 2015 2 次提交
    • L
      vga_switcheroo: Set active attribute to false for audio clients · 21b45676
      Lukas Wunner 提交于
      The active attribute in struct vga_switcheroo_client denotes whether
      the outputs are currently switched to this client. The attribute is
      only meaningful for vga clients. It is never used for audio clients.
      
      The function vga_switcheroo_register_audio_client() misuses this
      attribute to store whether the audio device is fully initialized.
      Most likely there was a misunderstanding about the meaning of
      "active" when this was added.
      
      Comment from Takashi's review:
      
      "Not really.  The full initialization of audio was meant that the audio
      is active indeed.  Admittedly, though, the active flag for each audio
      client doesn't play any role because the audio always follows the gfx
      state changes, and the value passed there doesn't reflect the actual
      state due to the later change.  So, I agree with the removal of the
      flag itself -- or let the audio active flag following the
      corresponding gfx flag.  The latter will make the proc output more
      consistent while the former is certainly more reduction of code."
      
      Set the active attribute to false for audio clients. Remove the
      active parameter from vga_switcheroo_register_audio_client() and
      its sole caller, hda_intel.c:register_vga_switcheroo().
      
      vga_switcheroo_register_audio_client() was introduced by 3e9e63db
      ("vga_switcheroo: Add the support for audio clients"). Its use in
      hda_intel.c was introduced by a82d51ed ("ALSA: hda - Support
      VGA-switcheroo").
      
      v1.1: The changes above imply that in find_active_client() the call
      to client_is_vga() is now superfluous. Drop it.
      
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      [danvet: Add Takashi's clarification to the commit message.]
      Reviewed-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      21b45676
    • L
      vga_switcheroo: Sort headers alphabetically · 4127838c
      Lukas Wunner 提交于
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      4127838c
  10. 22 9月, 2015 1 次提交
  11. 12 8月, 2015 5 次提交
  12. 19 9月, 2014 1 次提交
  13. 02 6月, 2014 1 次提交
  14. 29 8月, 2013 1 次提交
    • D
      gpu/vga_switcheroo: add driver control power feature. (v3) · 0d69704a
      Dave Airlie 提交于
      For optimus and powerxpress muxless we really want the GPU
      driver deciding when to power up/down the GPU, not userspace.
      
      This adds the ability for a driver to dynamically power up/down
      the GPU and remove the switcheroo from controlling it, the
      switcheroo reports the dynamic state to userspace also.
      
      It also adds 2 power domains, one for machine where the power
      switch is controlled outside the GPU D3 state, so the powerdown
      ordering is done correctly, and the second for the hdmi audio
      device to make sure it can resume for PCI config space accesses.
      
      v1.1: fix build with switcheroo off
      
      v2: add power domain support for radeon and v1 nvidia dsms
      v2.1: fix typo in off case
      
      v3: add audio power domain for hdmi audio + misc audio fixes
      
      v4: use PCI_SLOT macro, drop power reference on hdmi audio resume
      failure also.
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      0d69704a
  15. 08 2月, 2013 1 次提交
  16. 20 11月, 2012 1 次提交
  17. 18 8月, 2012 2 次提交
  18. 09 6月, 2012 1 次提交
  19. 08 6月, 2012 1 次提交
  20. 13 5月, 2012 3 次提交
  21. 24 4月, 2012 1 次提交
  22. 16 5月, 2011 1 次提交
  23. 04 5月, 2011 1 次提交
  24. 07 1月, 2011 1 次提交
  25. 05 1月, 2011 5 次提交