Skip to content

Conversation

thwuedwin
Copy link
Contributor

If the userspace program exits while the game is paused, the display flag is not cleared, causing the kernel module to stop producing output. As a result, restarting the program in this state causes it to hang on waiting for device data.

This patch resets the display flag on program exit, ensuring the kernel module resumes output normally when the program is restarted.

kxo has a critical issue: if the userspace program xo-user exits while
the game is paused, restarting the program will cause it to hang.

The userspace program communicates the game state to the kernel module
via the 'kxo_state' attribute exposed through sysfs. This attribute
reflects the current game state (e.g., paused, quitting) and controls
whether the kernel module continues to produce output.

However, if the userspace program exits while the game is paused, the
'display' flag is not cleared. As a result, the kernel module does not
resume producing output when the program is relaunched, even though it
is still functioning correctly.

This patch resolves the issue by resetting the 'display' flag when the
userspace program exits.
@weiso131
Copy link
Contributor

If this change is applied, when running xo-user in multiple user space programs, pausing and exiting in one program will cause the others to resume from pause. I’m not sure if that’s the intended behavior.

My suggestion is to move attr_obj.display = 49; inside the if statement.

if (atomic_dec_and_test(&open_cnt)) {
    del_timer_sync(&timer);
    flush_workqueue(kxo_workqueue);
    fast_buf_clear();
+   attr_obj.display = 49;
}

This would keep the current behavior, where other programs fail to properly resume after being paused, but since your commit message only mentions ensuring that restart works correctly, I think it’s better to minimize unintended side effects.

As for the multiple–user space program issue, I think it can be discussed separately.

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.

2 participants