Bug 219561 - linux >= 6.7.x breaks NVidia HDMI audio
Summary: linux >= 6.7.x breaks NVidia HDMI audio
Status: NEEDINFO
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(Other) (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: drivers_video-other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-04 20:03 UTC by Mathias Anselmann
Modified: 2024-12-14 22:42 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmesg, aplay and speaker-test of 6.6.10 (working) and 6.7 (not working) (4.63 KB, application/zip)
2024-12-04 20:03 UTC, Mathias Anselmann
Details
This patch fixes the sound issue for me (1.03 KB, patch)
2024-12-14 20:58 UTC, Mathias Anselmann
Details | Diff

Description Mathias Anselmann 2024-12-04 20:03:09 UTC
Hello,

I have an older computer, that acts as a kind of media player.
It has a

GK208B [GeForce GT 710]

and until recently I used the proprietary NVIDIA 470 drivers.
Currently they are brokwn with linux 6.12, that's why I used the chance and wanted to switch to nouveau. Graphics with this work fine - but the sound over HDMI does not work.
I installed older kernel versions to roughly debug the problem and with linux 6.6.10 everything works fine - problems start with linux 6.7.
Currently I use the LTS kernel 6.6.63 that also works just fine.

I attach here several outputs of the working 6.6.10 version and the non-working 6.7 version:

00 and 03:
$ dmesg|grep -iE "nouve|snd"

01 and 04:
$ aplay -L

02 and 05:
speaker-test -Dhdmi:NVidia -c 2

Maybe anybody can help me here - I can provide more information, if needed.

Many greetings
Mathias
Comment 1 Mathias Anselmann 2024-12-04 20:03:41 UTC
Created attachment 307320 [details]
dmesg, aplay and speaker-test of 6.6.10 (working) and 6.7 (not working)
Comment 2 Artem S. Tashkinov 2024-12-05 18:56:04 UTC
Please bisect:

https://docs.kernel.org/admin-guide/bug-bisect.html
Comment 3 Mathias Anselmann 2024-12-10 15:50:20 UTC
@Artem just a short intermediate update: I started bisecting this issue, unfortunately this is tougher than I thought.
I could bisect successfully only with "--first-parent" switch, here the result was:


> 7d461b291e65938f15f56fe58da2303b07578a76 is the first bad commit
> f56fe58da2303b07578a76 (HEAD)
> Merge: 8bc9e6515183 631808095a82
> Author: Linus Torvalds <torvalds@linux-foundation.org>
> Date:   Wed Nov 1 06:28:35 2023 -1000
>
> Merge tag 'drm-next-2023-10-31-1' of git://anongit.freedesktop.org/drm/drm
>
>     Pull drm updates from Dave Airlie:
>      "Highlights:
>       - AMD adds some more upcoming HW platforms
>       - Intel made Meteorlake stable and started adding Lunarlake
>       - nouveau has a bunch of display rework in prepartion for the NVIDIA
>         GSP firmware support
>       - msm adds a7xx support

Without using "--first-parent" I stumbled across multiple other problems and was not able to boot.

I tried to bisect further between
7d461b291e65938f15f56fe58da2303b07578a76
and
git merge-base 7d461b291e65938f15f56fe58da2303b07578a76^1 7d461b291e65938f15f56fe58da2303b07578a76^2
which is 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1
And found the following good commits:
5a6a09e97199d6600d31383055f9d43fbbcbe86f
5cbff4b2d9e2a59f4096af8b8f967e2b30f025f2

and the following bad commits:
27442758e9b4e083bef3f164a1739475c01f3202
614351f41e8c557068f1898eef5bacbca3b20911

Unfortunately, when I try to test many other commits, e.g.
e5f9d543419c78ac58f3b3557bc5a76b20ff600b

I was not able to boot due to a "BUG: unable to handle page fault for address: XXX" error directly after loading my initramfs.
So I first bisected this boot problem and found that my machine relies on
3ac873c76d79f055e1712754d9f2e90e41582f04:

If I cherry-pick this commit, I can at least boot. But even then e5f9d543419c78ac58f3b3557bc5a76b20ff600b does not load "nouveau" and does not boot into my graphical.target.
Trying to "modprove v nouveau" results in:

insmod /lib/modules/6.5.0-1-git-v6.5-rc2-764-ge5f9d543419c/kernel/drivers/gpu/drm/nouveau/nouveau.ko.zst
modprobe: ERROR: could not insert 'nouveau': Cannot allocate memory

I will put some more time into trying to find the commit that leads to this situation and (not being able to load nouveau). I just wanted to keep you updated.

Many greetings
Mathias
Comment 4 Mathias Anselmann 2024-12-14 20:57:07 UTC
Hello,

I could finally bisect the problem to the end. In order to be able to compile intermediate commits, I needed to cherry-pick
- 3ac873c76d79f055e1712754d9f2e90e41582f04 (wrong parentheses)
- a419beac4a070aff63c520f36ebf7cb8a76a8ae5 (vmalloc usage for zstd decompression)

The result of the bisection was:

--------------------------------------------------------------------------------------------------
6c6abab20b99169f5fb11a8619012225ecd02f1e is the first bad commit
commit 6c6abab20b99169f5fb11a8619012225ecd02f1e
Author: Ben Skeggs <bskeggs@redhat.com>
Date:   Tue Sep 19 17:56:14 2023 -0400

    drm/nouveau/disp: add output hdmi config method
    - was previously part of acquire()
    - preparation for GSP-RM
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
    Reviewed-by: Lyude Paul <lyude@redhat.com>
    Acked-by: Danilo Krummrich <me@dakr.org>
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230919220442.202488-20-lyude@redhat.com
--------------------------------------------------------------------------------------------------


The commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6c6abab20b99169f5fb11a8619012225ecd02f1e

changes the logic of nv50_hdmi_enable() in
drivers/gpu/drm/nouveau/dispnv50/disp.c

Before a local variable
u8 scdc = 0;
was created in the function, filled and later nvif_outp_acquire_tmds() was called (where scdc was passed).
The new logic creates also
u8 scdc;
locally, but does not pass it to nvif_outp_hdmi() - the function that replaced the call to nvif_outp_acquire_tmds().
Instead it passes a bool variable hdmi->scdc.supported

These values are later used in uoutp.c in
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c in the function nvkm_uoutp_mthd_hdmi(), respectively nvkm_uoutp_mthd_acquire_tmds() (before the last commit).
Here is a debug output of the last good commit (c0f7b729425b8f0764b9e89f19d33a0deba89811) at the beginning of nvkm_uoutp_mthd_acquire_tmds():

outp=000000007ea185c3, head=0, hdmi=1, hdmi_max_ac_packet=7, hdmi_rekey=56, hdmi_scdc=0, hdmi_hda=1

and here the output after the bad commit (6c6abab20b99169f5fb11a8619012225ecd02f1e) of nvkm_uoutp_mthd_hdmi():
args->v0.head=0, args->v0.enable=1, args->v0.max_ac_packet=7, args->v0.rekey=56, args->v0.scdc=1, args->v0.scdc_scrambling=1, args->v0.scdc_low_rates=0, args->v0.khz=297000

You see hdmi_scdc was 0 before and is now replaced with bool args->v0.scdc, which is 1 on the affected machine.
I updated disp.c to use the old logic before (create a local _u8 and use this in nvif_outp_hdmi) that fixes the problem for me and attach the patch here in the file fix_v6.12.patch
It can be applied to v6.12 (adc218676eef25575469234709c2d87185ca223a) and results in working sound for me - tested with v6.7 and v6.12.

Maybe the problem can be generally fixed upsteram?
Thank you very much and many greetings
Mathias
Comment 5 Mathias Anselmann 2024-12-14 20:58:00 UTC
Created attachment 307360 [details]
This patch fixes the sound issue for me
Comment 6 Mathias Anselmann 2024-12-14 21:08:56 UTC
And I forgot one thing:
the different value of scdc results in the (for me) broken commit, that in
nvkm_uoutp_mthd_hdmi() we take the branch:

if (args->v0.scdc && !ior->func->hdmi->scdc)

and

return -EINVAL;

In the former function, nvkm_uoutp_mthd_acquire_tmds(), we did not enter this branch and returned 0.
Comment 7 Jaroslav Kysela 2024-12-14 21:25:08 UTC
Note that nouveau driver team uses gitlab.freedesktop.org: https://nouveau.freedesktop.org/Bugs.html . I suggest to move your findings there.
Comment 8 Mathias Anselmann 2024-12-14 22:42:45 UTC
@Jaroslav: Thanks for the hint! Just for completeness: I created a bug report at the gitlab bug tracker here:
https://gitlab.freedesktop.org/drm/nouveau/-/issues/402

Many greetings
Mathias

Note You need to log in before you can comment on or make changes to this bug.