<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/gpu/vga, branch v4.19</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2018-09-13T15:58:30Z</updated>
<entry>
<title>ALSA: hda - Enable runtime PM only for discrete GPU</title>
<updated>2018-09-13T15:58:30Z</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2018-09-10T14:20:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=37a3a98ef601f89100e3bb657fb0e190b857028c'/>
<id>urn:sha1:37a3a98ef601f89100e3bb657fb0e190b857028c</id>
<content type='text'>
The recent change of vga_switcheroo allowed the runtime PM for
HD-audio on AMD GPUs, but this also resulted in a regression.  When
the HD-audio controller driver gets runtime-suspended, HD-audio link
is turned off, and the hotplug notification is ignored.  This leads to
the inconsistent audio state (the connection isn't notified and ELD is
ignored).

The best fix would be to implement the proper ELD notification via the
audio component, but it's still not ready.  As a quick workaround,
this patch adds the check of runtime_idle and allows the runtime
suspend only when the vga_switcheroo is bound with discrete GPU.
That is, a system with a single GPU and APU would be again without
runtime PM to keep the HD-audio link for the hotplug notification and
ELD read out.

Also, the codec-&gt;auto_runtime_pm flag is set only for the discrete GPU
at the time GPU gets bound via vga_switcheroo (i.e. only dGPU is
forcibly runtime-PM enabled), so that APU can still get the ELD
notification.

For identifying which GPU is bound, a new vga_switcheroo client
callback, gpu_bound, is implemented.  The vga_switcheroo simply calls
this when GPU is bound, and tells whether it's dGPU or APU.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200945
Fixes: 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller")
Reported-by: Jian-Hong Pan &lt;jian-hong@endlessm.com&gt;
Tested-by: Jian-Hong Pan &lt;jian-hong@endlessm.com&gt;
Acked-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>vga_switcheroo: set audio client id according to bound GPU id</title>
<updated>2018-07-17T09:12:00Z</updated>
<author>
<name>Jim Qu</name>
<email>Jim.Qu@amd.com</email>
</author>
<published>2018-07-17T08:20:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4aaf448fa9754e2d5ee188d32327b24ffc15ca4d'/>
<id>urn:sha1:4aaf448fa9754e2d5ee188d32327b24ffc15ca4d</id>
<content type='text'>
On modern laptop, there are more and more platforms
have two GPUs, and each of them maybe have audio codec
for HDMP/DP output. For some dGPU which is no output,
audio codec usually is disabled.

In currect HDA audio driver, it will set all codec as
VGA_SWITCHEROO_DIS, the audio which is binded to UMA
will be suspended if user use debugfs to contorl power

In HDA driver side, it is difficult to know which GPU
the audio has binded to. So set the bound gpu pci dev
to vga_switcheroo.

if the audio client is not the third registration, audio
id will set in vga_switcheroo enable function. if the
audio client is the last registration when vga_switcheroo
_ready() get true, we should get audio client id from bound
GPU directly.

Signed-off-by: Jim Qu &lt;Jim.Qu@amd.com&gt;
Reviewed-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>docs: Fix some broken references</title>
<updated>2018-06-15T21:10:01Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab+samsung@kernel.org</email>
</author>
<published>2018-05-08T18:14:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5fb94e9ca333f0fe1d96de06704a79942b3832c3'/>
<id>urn:sha1:5fb94e9ca333f0fe1d96de06704a79942b3832c3</id>
<content type='text'>
As we move stuff around, some doc references are broken. Fix some of
them via this script:
	./scripts/documentation-file-ref-check --fix

Manually checked if the produced result is valid, removing a few
false-positives.

Acked-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Acked-by: Stephen Boyd &lt;sboyd@kernel.org&gt;
Acked-by: Charles Keepax &lt;ckeepax@opensource.wolfsonmicro.com&gt;
Acked-by: Mathieu Poirier &lt;mathieu.poirier@linaro.org&gt;
Reviewed-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+samsung@kernel.org&gt;
Acked-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
</content>
</entry>
<entry>
<title>vga_switcheroo: Let HDA autosuspend on mux change</title>
<updated>2018-03-13T21:58:49Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2018-03-03T09:53:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b67ae78efae0d5be5d9c7a507e67cd02971b32e1'/>
<id>urn:sha1:b67ae78efae0d5be5d9c7a507e67cd02971b32e1</id>
<content type='text'>
When switching the display on muxed machines, we currently force the HDA
controller into runtime suspend on the previously used GPU and into
runtime active state on the newly used GPU.

That's unnecessary if the GPU uses driver power control, we can just let
the audio device autosuspend or autoresume as it sees fit.

Cc: Dave Airlie &lt;airlied@redhat.com&gt;
Cc: Ben Skeggs &lt;bskeggs@redhat.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Reviewed-by: Peter Wu &lt;peter@lekensteyn.nl&gt;
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/098ed883460eb4976a899eac6f5192fefc877c0f.1520068884.git.lukas@wunner.de
</content>
</entry>
<entry>
<title>vga_switcheroo: Use device link for HDA controller</title>
<updated>2018-03-13T21:58:09Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2018-03-03T09:53:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=07f4f97d7b4bf325d9f558c5b58230387e4e57e0'/>
<id>urn:sha1:07f4f97d7b4bf325d9f558c5b58230387e4e57e0</id>
<content type='text'>
Back in 2013, runtime PM for GPUs with integrated HDA controller was
introduced with commits 0d69704ae348 ("gpu/vga_switcheroo: add driver
control power feature. (v3)") and 246efa4a072f ("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 -&gt;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  ===&gt;  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 -&gt;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 -&gt;probe, a runtime PM ref was previously released under
the condition "azx_has_pm_runtime(chip) || hda-&gt;use_vga_switcheroo", but
on -&gt;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 &lt;airlied@redhat.com&gt;
Cc: Ben Skeggs &lt;bskeggs@redhat.com&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Cc: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Reviewed-by: Peter Wu &lt;peter@lekensteyn.nl&gt;
Tested-by: Kai Heng Feng &lt;kai.heng.feng@canonical.com&gt; # AMD PowerXpress
Tested-by: Mike Lothian &lt;mike@fireburn.co.uk&gt;          # AMD PowerXpress
Tested-by: Denis Lisov &lt;dennis.lissov@gmail.com&gt;       # Nvidia Optimus
Tested-by: Peter Wu &lt;peter@lekensteyn.nl&gt;              # Nvidia Optimus
Tested-by: Lukas Wunner &lt;lukas@wunner.de&gt;              # MacBook Pro
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/51bd38360ff502a8c42b1ebf4405ee1d3f27118d.1520068884.git.lukas@wunner.de
</content>
</entry>
<entry>
<title>vga_switcheroo: Deduplicate power state tracking</title>
<updated>2018-03-13T21:58:02Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2018-03-03T09:53:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8948ca1a12c9a039361bbc3e4627064153971d57'/>
<id>urn:sha1:8948ca1a12c9a039361bbc3e4627064153971d57</id>
<content type='text'>
If DRM drivers use runtime PM, they currently notify vga_switcheroo
whenever they -&gt;runtime_suspend or -&gt;runtime_resume to update
vga_switcheroo's internal power state tracking.

That's essentially a duplication of a functionality performed by the
PM core as it already tracks the GPU's power state and vga_switcheroo
can always query it.

Introduce a new internal helper vga_switcheroo_pwr_state() which does
just that if runtime PM is used, or falls back to vga_switcheroo's
internal power state tracking if manual power control is used.
Drop a redundant power state check in set_audio_state() while at it.

This removes one of the two purposes of the notification mechanism
implemented by vga_switcheroo_set_dynamic_switch().  The other one is
power management of the audio device and we'll remove that next.

Cc: Dave Airlie &lt;airlied@redhat.com&gt;
Cc: Ben Skeggs &lt;bskeggs@redhat.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Cc: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Reviewed-by: Peter Wu &lt;peter@lekensteyn.nl&gt;
Tested-by: Kai Heng Feng &lt;kai.heng.feng@canonical.com&gt; # AMD PowerXpress
Tested-by: Mike Lothian &lt;mike@fireburn.co.uk&gt;          # AMD PowerXpress
Tested-by: Denis Lisov &lt;dennis.lissov@gmail.com&gt;       # Nvidia Optimus
Tested-by: Peter Wu &lt;peter@lekensteyn.nl&gt;              # Nvidia Optimus
Tested-by: Lukas Wunner &lt;lukas@wunner.de&gt;              # MacBook Pro
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/0aa49d735b988aa04524a8dc339582ace33f0f94.1520068884.git.lukas@wunner.de
</content>
</entry>
<entry>
<title>vga_switcheroo: Update PCI current_state on power change</title>
<updated>2018-03-13T21:57:55Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2018-03-03T09:53:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dcac86b7d0be71563d6219ce52c9918e44b84f0a'/>
<id>urn:sha1:dcac86b7d0be71563d6219ce52c9918e44b84f0a</id>
<content type='text'>
When cutting power to a GPU and its integrated HDA controller, their
cached current_state should be updated to D3cold to reflect reality.

We currently rely on the DRM and HDA drivers to do that, however:

- The HDA driver updates the current_state in azx_vs_set_state(), which
  will no longer be called with driver power control once we migrate to
  device links.  (It will still be called with manual power control.)

- If the HDA device is not bound, its current_state remains at D0 even
  though the GPU driver may decide to go to D3cold.

- The DRM drivers update the current_state using pci_set_power_state()
  which can't put the device into a deeper power state than D3hot if the
  GPU is not deemed power-manageable by the platform (even though it
  *is* power-manageable by some nonstandard means, such as a _DSM).

Centralize updating the current_state of the GPU and HDA controller in
vga_switcheroo's -&gt;runtime_suspend hook to overcome these deficiencies.

The GPU and HDA controller are two functions of the same PCI device
(VGA class device on function 0 and audio device on function 1) and
no other PCI devices reside on the same bus since this is a PCIe
point-to-point link, so we can just walk the bus and update the
current_state of all devices.

On -&gt;runtime_resume, the HDA controller is in D0uninitialized state.
Resume to D0active and then let it autosuspend as it sees fit.

Note that vga_switcheroo_init_domain_pm_ops() is not supposed to be
called by hybrid graphics laptops which power down the GPU via its root
port's _PR3 resources and consequently vga_switcheroo_runtime_suspend()
is not used.  On those laptops, the root port is power-manageable by the
platform (instead of by a nonstandard means) and the current_state is
therefore updated by the PCI core through the following call chain:

  pci_set_power_state()
    __pci_complete_power_transition()
      pci_bus_set_current_state()

Resuming to D0active happens through:

  pci_set_power_state()
    __pci_start_power_transition()
      pci_wakeup_bus()

Cc: Dave Airlie &lt;airlied@redhat.com&gt;
Cc: Ben Skeggs &lt;bskeggs@redhat.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Cc: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Cc: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Reviewed-by: Peter Wu &lt;peter@lekensteyn.nl&gt;
Tested-by: Kai Heng Feng &lt;kai.heng.feng@canonical.com&gt; # AMD PowerXpress
Tested-by: Mike Lothian &lt;mike@fireburn.co.uk&gt;          # AMD PowerXpress
Tested-by: Denis Lisov &lt;dennis.lissov@gmail.com&gt;       # Nvidia Optimus
Tested-by: Peter Wu &lt;peter@lekensteyn.nl&gt;              # Nvidia Optimus
Tested-by: Lukas Wunner &lt;lukas@wunner.de&gt;              # MacBook Pro
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/8416958482c8c42d6f311ea5c1e5a65ccf21f5db.1520068884.git.lukas@wunner.de
</content>
</entry>
<entry>
<title>vfs: do bulk POLL* -&gt; EPOLL* replacement</title>
<updated>2018-02-11T22:34:03Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2018-02-11T22:34:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a9a08845e9acbd224e4ee466f5c1275ed50054e8'/>
<id>urn:sha1:a9a08845e9acbd224e4ee466f5c1275ed50054e8</id>
<content type='text'>
This is the mindless scripted replacement of kernel use of POLL*
variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
        L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
        for f in $L; do sed -i "-es/^\([^\"]*\)\(\&lt;POLL$V\&gt;\)/\\1E\\2/" $f; done
    done

with de-mangling cleanups yet to come.

NOTE! On almost all architectures, the EPOLL* constants have the same
values as the POLL* constants do.  But they keyword here is "almost".
For various bad reasons they aren't the same, and epoll() doesn't
actually work quite correctly in some cases due to this on Sparc et al.

The next patch from Al will sort out the final differences, and we
should be all done.

Scripted-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>the rest of drivers/*: annotate -&gt;poll() instances</title>
<updated>2017-11-28T16:06:58Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2017-07-03T10:39:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=afc9a42b7464f76e1388cad87d8543c69f6f74ed'/>
<id>urn:sha1:afc9a42b7464f76e1388cad87d8543c69f6f74ed</id>
<content type='text'>
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>vgaarb: Factor out EFI and fallback default device selection</title>
<updated>2017-10-18T08:04:56Z</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2017-10-13T03:47:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=505a1b571711a977b7d069dec3c14381521e9683'/>
<id>urn:sha1:505a1b571711a977b7d069dec3c14381521e9683</id>
<content type='text'>
The default VGA device is normally set in vga_arbiter_add_pci_device() when
we call it for the first enabled device that can be accessed with the
legacy VGA resources ([mem 0xa0000-0xbffff], etc.)

That default device can be overridden by an EFI device that owns the boot
framebuffer.  As a fallback, we can also select a VGA device that can't be
accessed via legacy VGA resources, or a VGA device that isn't even enabled.

Factor out this EFI and fallback selection from vga_arb_device_init() into
a separate vga_arb_select_default_device() function.  This doesn't change
any behavior, but it untangles the "bridge control possible" checking and
messages from the default device selection.

Tested-by: Zhou Wang &lt;wangzhou1@hisilicon.com&gt;  # D05 Hisi Hip07, Hip08
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Acked-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Reviewed-by: Daniel Axtens &lt;dja@axtens.net&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20171013034729.14630.30419.stgit@bhelgaas-glaptop.roam.corp.google.com
</content>
</entry>
</feed>
