raspberrypi / windows-drivers

Windows IOT drivers
MIT License
121 stars 33 forks source link

bcm2836sdhc - fix early interrupts #26

Closed idigdoug closed 3 years ago

idigdoug commented 3 years ago

The Arasan driver enables interrupts during SlotInitialize, but sdport isn't ready for interrupts at that point. This works ok as long as no interrupts fire right away, but if any interrupts fire before sdport is ready, it causes various problems.

If bcm2836sdhc is the only driver using the given IRQ, and it is only loaded during boot, things seem to work most of the time.

If bcm2836sdhc is sharing an IRQ with another active device or if you load the driver after the system has been running a while, it often crashes or hangs.

Fix this by disabling interrupts during SlotInitialize. sdport will enable interrupts when it is ready for them by calling ToggleInterrupts.

Note that this can be considered a bug in sdport - it should be ready for interrupts before it connects the interrupt. I've provided this feedback to the sdport owners. Fixing the driver works around the issue.

Note that there is still a crash if you load both bcm2836sdhc and SDHostBRCME88C and then unload one of them. I don't know the root cause of this. It may be a bug in sdport.sys.

mariobalanica commented 3 years ago

Thanks!