[Nouveau] [PATCH v2] ALSA: hda: Continue to probe when codec probe fails

Roy Spliet nouveau at spliet.org
Sat Apr 10 17:51:27 CEST 2021


Reviving this thread as we have another user (rightfully) complaining on 
IRC about this.

The way I see it there's two issues:
1) snd_hda_intel not allowing runpm (or w/e vgaswitcheroo needs) when 
there's missing codecs, inhibiting the entire GPU from performing runpm. 
This needlessly wastes lots of battery power.
2) HDMI audio not working on such machines unless it was plugged in at 
boot-time.

The original workarounds proposed by Kai-Heng seem to fix 1), which is 
progress. I don't see a reason why that should be held off even if it 
doesn't fix 2).
To fix 2), more work is needed. On a high level, I suspect nouveau 
should start controlling the enabling/disabling of the HDA controller 
based on connector events and/or connector state at module load. 
Currently the PCI quirk seems to enable it wholesale, and I don't know 
why. If no GPU driver is loaded, it's pointless to turn the HDA device 
on. The blob presumably doesn't need this either, as it can control the 
device just as well as nouveau. If it doesn't, NVIDIA should fix it 
rather than rely on this quirk. The only reason I can think of is that 
snd_hda_intel or vgaswitcheroo isn't prepared for hot(un)plugging (or 
alternatively reprobing) devices. Without that, we presumably won't 
solve issue 2). Can I ask someone with more technical knowledge of 
snd_hda_intel and vgaswitcheroo to brainstorm about the possible 
challenges of nouveau taking matters into its own hand rather than 
keeping this PCI quirk around?

Roy

Op 04-01-2021 om 13:20 schreef Karol Herbst:
> On Tue, Dec 22, 2020 at 3:50 AM Kai-Heng Feng
> <kai.heng.feng at canonical.com> wrote:
>>
>> On Tue, Dec 22, 2020 at 1:56 AM Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>>>
>>> On Mon, Dec 21, 2020 at 11:33 AM Kai-Heng Feng
>>> <kai.heng.feng at canonical.com> wrote:
>>>>
>>>> [+Cc nouveau]
>>>>
>>>> On Fri, Dec 18, 2020 at 4:06 PM Takashi Iwai <tiwai at suse.de> wrote:
>>>> [snip]
>>>>>> Quite possibly the system doesn't power up HDA controller when there's
>>>>>> no external monitor.
>>>>>> So when it's connected to external monitor, it's still needed for HDMI audio.
>>>>>> Let me ask the user to confirm this.
>>>>>
>>>>> Yeah, it's the basic question whether the HD-audio is supposed to work
>>>>> on this machine at all.  If yes, the current approach we take makes
>>>>> less sense - instead we should rather make the HD-audio controller
>>>>> working.
>>>>
>>>> Yea, confirmed that the Nvidia HDA works when HDMI is connected prior boot.
>>>>
>>>>>>> - The second problem is that pci_enable_device() ignores the error
>>>>>>>    returned from pci_set_power_state() if it's -EIO.  And the
>>>>>>>    inaccessible access error returns -EIO, although it's rather a fatal
>>>>>>>    problem.  So the driver believes as the PCI device gets enabled
>>>>>>>    properly.
>>>>>>
>>>>>> This was introduced in 2005, by Alan's 11f3859b1e85 ("[PATCH] PCI: Fix
>>>>>> regression in pci_enable_device_bars") to fix UHCI controller.
>>>>>>
>>>>>>>
>>>>>>> - The third problem is that HD-audio driver blindly believes the
>>>>>>>    codec_mask read from the register even if it's a read failure as I
>>>>>>>    already showed.
>>>>>>
>>>>>> This approach has least regression risk.
>>>>>
>>>>> Yes, but it assumes that HD-audio is really non-existent.
>>>>
>>>> I really don't know any good approach to address this.
>>>> On Windows, HDA PCI is "hidden" until HDMI cable is plugged, then the
>>>> driver will flag the magic bit to make HDA audio appear on the PCI
>>>> bus.
>>>> IIRC the current approach is to make nouveau and device link work.
>>>
>>> I don't have the full context of this discussion, but the kernel
>>> force-enables the HDA subfunction nowadays, irrespective of nouveau or
>>> nvidia or whatever:
>>
>> That's the problem.
>>
>> The nvidia HDA controller on the affected system only gets its power
>> after HDMI cable plugged, so the probe on boot fails.
>>
> 
> it might be that the code to enable the sub function is a bit broken
> :/ but it should work. Maybe the quirk_nvidia_hda function needs to be
> called on more occasions? No idea.
> 
>> Kai-Heng
>>
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/quirks.c?h=v5.10#n5267
>>>
>>> Cheers,
>>>
>>>    -ilia
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau
>>
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
> 


More information about the Alsa-devel mailing list