Display freezes: (EE) NVIDIA(GPU-0): WAIT

I am now running kernel 5.16.10, which fixes the problem. I have tested from 5.16.5 and higher, which all worked. I didn’t test any 5.16.X lower and also didn’t test any 5.14 or 5.15.

The only remaining issue that I have:
When I have selected prime modus ‘on-demand’ and I connect an externel display, the UI becomes really slow. (Except the mouse). I expect the X server should always switch to the NVIDIA gpu when an external display is connected, but it doesn’t.
A semi permanent workaround is to just switch to performance mode, though this forces all processes to use the NVIDIA GPU, which reduces the available GPU memory for my AI application.