Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ScheduleEvent from wrong thread when inserting SD card #3989

Merged
merged 1 commit into from Jul 13, 2016

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Jul 7, 2016

/dev/sdio/slot0's EventNotify was being called from the UI thread even though it only should be called from the CPU thread for thread safety reasons. With this PR, the UI thread instead schedules an event that will call EventNotify on the CPU thread.

There is a potential race condition if IsRunning becomes false right after my newly added call to IsRunning, which can end up adding an event to CoreTiming after it has shut down. It's unlikely to occur in practice, and the old code had the same problem (with GetDeviceByName as the equivalent of IsRunning), but it's still a race condition. I'm not sure what to do about it. Suggestions?


This change is Reviewable

@magumagu
Copy link
Contributor

magumagu commented Jul 7, 2016

The race condition where we modify m_WiiSDCard from the UI thread, then access it from the CPU thread seems more important... we really need some sort of centralized system for handling configuration changes while a game is running.

I guess this change is fine as-is for the moment.

@JosJuice
Copy link
Member Author

JosJuice commented Jul 7, 2016

I've added a comment about the problems so they won't get completely forgotten if the code gets merged in its current state.

@Parlane
Copy link
Member

Parlane commented Jul 13, 2016

LGTM

@Parlane
Copy link
Member

Parlane commented Jul 13, 2016

Reviewed 2 of 2 files at r3.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@phire
Copy link
Member

phire commented Jul 13, 2016

LGTM

@Parlane Parlane merged commit 4d2df0a into dolphin-emu:master Jul 13, 2016
void SDIO_EventNotify_CPUThread(u64 userdata, s64 cycles_late)
{
auto device =
static_cast<CWII_IPC_HLE_Device_sdio_slot0*>(GetDeviceByName("/dev/sdio/slot0").get());

This comment was marked as off-topic.

This comment was marked as off-topic.

@JosJuice JosJuice deleted the insert-sd-thread branch July 13, 2016 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants