Skip to content

gx: fix application hang on GPU FIFO overflow#264

Closed
mardy wants to merge 1 commit intodevkitPro:masterfrom
mardy:gx-fifo-fix
Closed

gx: fix application hang on GPU FIFO overflow#264
mardy wants to merge 1 commit intodevkitPro:masterfrom
mardy:gx-fifo-fix

Conversation

@mardy
Copy link
Copy Markdown
Contributor

@mardy mardy commented Apr 25, 2026

This fixes a bug which began to manifest itself after the switch to Tuxedo, though we haven't been able to find anything wrong with Tuxedo's implementation -- we cannot even rule out that this is due to a compiler / toolkit update, though this seems less likely.

The bug happens when the FIFO gets full and both the overflow and underflow status bits are set: the overflow handler suspends (with LWP_SuspendThread()) the graphical thread, which often is the application main thread, after which the underflow handler is never invoked anymore, so the graphical thread remains stopped. Other threads continue to work (wiimotes do connect to the Wii). Why exactly the underflow handler is not invoked anymore is unclear.

The solution (or rather workaround) is to clear both the FIFO overflow bit (obviously) and the underflow one, despite the fact that this should have already been done by the underflow handler.

Another workaround which has been shown to be working is adding an else before the check for the overflow bits, in order not to immediately invoke the overflow handler if we just invoked the underflow one. Should we for some reason need to revert this commit, that is another path that could be taken.

Fixes: #262

This fixes a bug which began to manifest itself after the switch to
Tuxedo, though we haven't been able to find anything wrong with Tuxedo's
implementation -- we cannot even rule out that this is due to a compiler
/ toolkit update, though this seems less likely.

The bug happens when the FIFO gets full and both the overflow and
underflow status bits are set: the overflow handler suspends (with
LWP_SuspendThread()) the graphical thread, which often is the
application main thread, after which the underflow handler is never
invoked anymore, so the graphical thread remains stopped. Other threads
continue to work (wiimotes do connect to the Wii). Why exactly the
underflow handler is not invoked anymore is unclear.

The solution (or rather workaround) is to clear both the FIFO overflow
bit (obviously) and the underflow one, despite the fact that this should
have already been done by the underflow handler.

Another workaround which has been shown to be working is adding an
`else` before the check for the overflow bits, in order not to
immediately invoke the overflow handler if we just invoked the underflow
one. Should we for some reason need to revert this commit, that is
another path that could be taken.

Fixes: devkitPro#262
@fincs
Copy link
Copy Markdown
Member

fincs commented Apr 26, 2026

As discussed privately, we are still actively trying to locate and fix the real cause of the problem. I found and fixed a relevant threading issue, however it still doesn't seem to be enough. Users who run into this GX FIFO overflow issue should consider instead increasing the size of the GX FIFO buffer (or optimizing their command usage), which is generally a better idea for performance if you're running into GX FIFO overflows in the first place.

@fincs fincs closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirmed: graphic hangs

2 participants