All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Mikityanskiy <maxtram95@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
	Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>,
	Rui Salvaterra <rsalvaterra@gmail.com>,
	Sui Jingfeng <suijingfeng@loongson.cn>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Peter Wu <peter@lekensteyn.nl>, Lukas Wunner <lukas@wunner.de>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda: intel: Fix Optimus when GPU has no sound
Date: Sat, 7 Sep 2024 16:45:41 +0300	[thread overview]
Message-ID: <ZtxZBUjlF8TeIUKC@mail.gmail.com> (raw)
In-Reply-To: <87wmjndbha.wl-tiwai@suse.de>

On Sat, 07 Sep 2024 at 12:06:25 +0200, Takashi Iwai wrote:
> On Fri, 06 Sep 2024 20:05:06 +0200,
> Maxim Mikityanskiy wrote:
> > 
> > On Thu, 05 Sep 2024 at 16:24:26 +0200, Takashi Iwai wrote:
> > > On Wed, 04 Sep 2024 22:39:55 +0200,
> > > Maxim Mikityanskiy wrote:
> > > > 
> > > > Lenovo IdeaPad Z570 with NVIDIA GeForce Ge 520M doesn't have sound on
> > 
> > Spotted a typo: s/520M/540M/
> > 
> > > > the discrete GPU. snd_hda_intel probes the device and schedules
> > > > azx_probe_continue(), which fails at azx_first_init(). The driver ends
> > > > up probed, but calls azx_free() and stops the chip. However, from the
> > > > runtime PM point of view, the device remains active, because the PCI
> > > > subsystem makes it active on probe, and it's still bound. It prevents
> > > > vga_switcheroo from turning off the DGPU (pci_create_device_link() syncs
> > > > power management for the video and audio devices).
> > > > 
> > > > Fix it by forcing the device to the suspended state in azx_free().
> > > > 
> > > > Fixes: 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller")
> > > > Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
> > > 
> > > What if this device probe is skipped (e.g. adding your device entry to
> > > driver_denylist[] in hda_intel.c)?  Is the device also in the
> > > runtime-suspended state?
> > 
> > I added the following:
> > 
> > { PCI_DEVICE_SUB(0x10de, 0x0bea, 0x0000, 0x0000) },
> > 
> > The probe was apparently skipped (the device is not attached to a
> > driver), runtime_status=suspended, runtime_usage=0, the GPU goes to
> > DynOff.
> 
> OK, that's good.
> 
> > However, I'm not sure whether it's a good idea to blacklist 540M
> > entirely, as there might be other laptops with this GPU that have sound,
> > and AFAIK there are variants of Lenovo Z570 with other NVIDIA GPUs.
> 
> You should specify the PCI SSID of your device instead of 0:0 in the
> above, so that it's picked up only for yours.

Where can I get it?

# cat /sys/bus/pci/devices/0000\:01\:00.1/subsystem_vendor
0x0000
# cat /sys/bus/pci/devices/0000\:01\:00.1/subsystem_device
0x0000

Is it not the right place?

> 
> Takashi
> 
> > Another way to make vga_switcheroo work is to disable quirk_nvidia_hda,
> > although I don't know whether it can be done without recompiling the
> > kernel. In this case, 0000:01:00.1 doesn't even appear on the bus.
> > 
> > (Note that I need to set nouveau.modeset=2 either way, otherwise it
> > stays in DynPwr if the screen is on.)
> > 
> > > 
> > > 
> > > thanks,
> > > 
> > > Takashi
> > > 
> > > > ---
> > > >  sound/pci/hda/hda_intel.c | 14 +++++++++++++-
> > > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> > > > index b79020adce63..65fcb92e11c7 100644
> > > > --- a/sound/pci/hda/hda_intel.c
> > > > +++ b/sound/pci/hda/hda_intel.c
> > > > @@ -1361,8 +1361,20 @@ static void azx_free(struct azx *chip)
> > > >  	if (use_vga_switcheroo(hda)) {
> > > >  		if (chip->disabled && hda->probe_continued)
> > > >  			snd_hda_unlock_devices(&chip->bus);
> > > > -		if (hda->vga_switcheroo_registered)
> > > > +		if (hda->vga_switcheroo_registered) {
> > > >  			vga_switcheroo_unregister_client(chip->pci);
> > > > +
> > > > +			/* Some GPUs don't have sound, and azx_first_init fails,
> > > > +			 * leaving the device probed but non-functional. As long
> > > > +			 * as it's probed, the PCI subsystem keeps its runtime
> > > > +			 * PM status as active. Force it to suspended (as we
> > > > +			 * actually stop the chip) to allow GPU to suspend via
> > > > +			 * vga_switcheroo.
> > > > +			 */
> > > > +			pm_runtime_disable(&pci->dev);
> > > > +			pm_runtime_set_suspended(&pci->dev);
> > > > +			pm_runtime_enable(&pci->dev);
> > > > +		}
> > > >  	}
> > > >  
> > > >  	if (bus->chip_init) {
> > > > -- 
> > > > 2.46.0
> > > > 

  reply	other threads:[~2024-09-07 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 20:39 [PATCH] ALSA: hda: intel: Fix Optimus when GPU has no sound Maxim Mikityanskiy
2024-09-05 14:24 ` Takashi Iwai
2024-09-06 18:05   ` Maxim Mikityanskiy
2024-09-07 10:06     ` Takashi Iwai
2024-09-07 13:45       ` Maxim Mikityanskiy [this message]
2024-09-07 15:49         ` Takashi Iwai
2024-09-07 17:24           ` Maxim Mikityanskiy
2024-09-07 18:10             ` Takashi Iwai
2024-09-21  8:10               ` Maxim Mikityanskiy
2024-09-30  6:43                 ` Takashi Iwai
2024-09-30  7:29                   ` Maxim Mikityanskiy
2024-09-30  9:15                     ` Lukas Wunner
2024-09-30 10:50                     ` Takashi Iwai

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=ZtxZBUjlF8TeIUKC@mail.gmail.com \
    --to=maxtram95@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=chaitanya.kumar.borah@intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=peter@lekensteyn.nl \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rsalvaterra@gmail.com \
    --cc=suijingfeng@loongson.cn \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.