linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: dri-devel@lists.freedesktop.org
Cc: Peter Wu <peter@lekensteyn.nl>,
	Alex Deucher <alexander.deucher@amd.com>,
	nouveau@lists.freedesktop.org, Imre Deak <imre.deak@intel.com>,
	Maik Freudenberg <hhfeuer@gmx.de>,
	Raphael Doursenaud <rdoursenaud@free.fr>,
	Martin Lopatar <lopin@dataplex.cz>,
	Daniel Drake <dan@reactivated.net>,
	Denis Lisov <dennis.lissov@gmail.com>,
	zigarrre@gmail.com,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org
Subject: [PATCH v2 0/7] Modernize vga_switcheroo by using device link for HDA
Date: Sat, 3 Mar 2018 10:53:24 +0100	[thread overview]
Message-ID: <cover.1520068884.git.lukas@wunner.de> (raw)

Modernize vga_switcheroo by using a device link to enforce a runtime PM
dependency from an HDA controller to the GPU it's integrated into, v2.

Changes since v1:

- Replace patch [1/7] to use pci_save_state() / pci_restore_state()
  for consistency between runtime PM code path of bound and unbound
  devices. (Rafael, Bjorn)

- Patch [5/7]: Drop an unnecessary initialization. (Bjorn)
  Rephrase error message on failed link addition for clarity.

Link to v1:
https://www.spinics.net/lists/dri-devel/msg165889.html

Testing on more machines would be greatly appreciated, particularly
Nvidia Optimus or AMD PowerXpress.

The series is based on 4.16-rc3.  To test it on 4.15, you need to
cherry-pick 7506dc798993 and 2fa6d6cdaf28.  For your convenience
I've pushed a 4.15-based branch to:
https://github.com/l1k/linux/commits/switcheroo_devlink_v2

Minimal test procedure:

- Note well: Recent Optimus require that a Mini-DP or HDMI cable is
  plugged in on boot for the HDA device to be present.

- Check that HDA, GPU and root port autosuspend when not in use:
  cat /sys/bus/pci/devices/0000:01:00.1/power/runtime_status  # HDA
  cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status  # GPU
  cat /sys/bus/pci/devices/0000:00:01.0/power/runtime_status  # Root Port

- Check that all three autoresume when accessing the HDA:
  hdajacksensetest -c 1

- Unbind the HDA controller:
  echo 0000:01:00.1 > /sys/bus/pci/drivers/snd_hda_intel/unbind
  Wait for GPU to power off, then rebind the HDA controller:
  echo 0000:01:00.1 > /sys/bus/pci/drivers/snd_hda_intel/bind
  Check dmesg for errors, try accessing HDA with hdajacksensetest.

- If your laptop uses the root port's _PR3 to cut power to the GPU:
  Unbind the GPU:
  echo 0000:01:00.0 > /sys/bus/pci/drivers/{nouveau,amdgpu,radeon}/unbind
  Allow runtime PM on the GPU:
  echo auto > /sys/bus/pci/devices/0000:01:00.0/power/control
  Wait for GPU to power off, then rebind it:
  echo 0000:01:00.0 > /sys/bus/pci/drivers/{nouveau,amdgpu,radeon}/bind
  Check dmesg for errors.  If you see any then we may need to perform
  further actions in pci_pm_runtime_resume(), see patch [1/7].

Thanks,

Lukas


Lukas Wunner (6):
  PCI: Make pci_wakeup_bus() & pci_bus_set_current_state() public
  vga_switcheroo: Update PCI current_state on power change
  vga_switcheroo: Deduplicate power state tracking
  vga_switcheroo: Use device link for HDA controller
  vga_switcheroo: Let HDA autosuspend on mux change
  drm/nouveau: Runtime suspend despite HDA being unbound

Rafael J. Wysocki (1):
  PCI: Restore config space on runtime resume despite being unbound

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |   2 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  46 ----------
 drivers/gpu/drm/nouveau/nouveau_drv.h   |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c     |   2 -
 drivers/gpu/vga/vga_switcheroo.c        | 152 ++++++++------------------------
 drivers/pci/pci-driver.c                |  17 ++--
 drivers/pci/pci.c                       |   8 +-
 drivers/pci/quirks.c                    |  39 ++++++++
 include/linux/pci.h                     |   2 +
 include/linux/pci_ids.h                 |   1 +
 include/linux/vga_switcheroo.h          |   6 --
 include/sound/hdaudio.h                 |   3 -
 sound/pci/hda/hda_intel.c               |  36 +++++---
 sound/pci/hda/hda_intel.h               |   3 -
 14 files changed, 117 insertions(+), 201 deletions(-)

-- 
2.15.1

             reply	other threads:[~2018-03-03  9:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03  9:53 Lukas Wunner [this message]
2018-03-03  9:53 ` [PATCH v2 5/7] vga_switcheroo: Use device link for HDA controller Lukas Wunner
2018-03-03  9:53 ` [PATCH v2 1/7] PCI: Restore config space on runtime resume despite being unbound Lukas Wunner
2018-03-13 17:34   ` Bjorn Helgaas
2018-03-05 20:58 ` [PATCH v2 0/7] Modernize vga_switcheroo by using device link for HDA Peter Wu
2018-03-10  6:09   ` Lukas Wunner
2018-03-06 10:29 ` Daniel Vetter
2018-03-11 15:55   ` Lukas Wunner
2018-03-12 16:54     ` Daniel Vetter
2018-03-13 17:36     ` Bjorn Helgaas
2018-03-14  6:07     ` Lukas Wunner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1520068884.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=alexander.deucher@amd.com \
    --cc=bhelgaas@google.com \
    --cc=dan@reactivated.net \
    --cc=dennis.lissov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hhfeuer@gmx.de \
    --cc=imre.deak@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lopin@dataplex.cz \
    --cc=nouveau@lists.freedesktop.org \
    --cc=peter@lekensteyn.nl \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rdoursenaud@free.fr \
    --cc=zigarrre@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).