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

[RP2040] Fix I2C lockups, improve error handling and performance #329

Merged
merged 1 commit into from
Jul 27, 2022

Conversation

KarlK90
Copy link
Contributor

@KarlK90 KarlK90 commented Jul 20, 2022

Problem

  • in edge-case scenarios the tx empty interrupt was still enabled after a transmission was finished. This would lead to endless interrupt tail chaining that completely starved the system.

Solution

  • all irqs are now disabled at the end of a transaction by default

Error handling

  • all error condition irqs like over and under-runs of tx and rx fifos are now enabled and handled with an wake-up of the sleeping thread plus disabling of all irqs

Optimizations

  • irq status register is only read once for evaluation in the irq handler
  • better Utilization of the rx fifos during reception, which are now only read if all data has been successfully received.

Fixes qmk/qmk_firmware#17720

@KarlK90 KarlK90 changed the title [RP2040] Tentative fixes for I2C lockups [RP2040] Fix I2C lockups and improve error handling Jul 21, 2022
@KarlK90 KarlK90 marked this pull request as ready for review July 21, 2022 19:40
@KarlK90
Copy link
Contributor Author

KarlK90 commented Jul 21, 2022

CC: @hanya

@KarlK90 KarlK90 marked this pull request as draft July 22, 2022 11:48
@KarlK90 KarlK90 force-pushed the fix/rp2040-i2c-irq-lockup branch 2 times, most recently from 47b0775 to dc3280a Compare July 26, 2022 07:40
@KarlK90 KarlK90 marked this pull request as ready for review July 26, 2022 17:41
@KarlK90 KarlK90 changed the title [RP2040] Fix I2C lockups and improve error handling [RP2040] RX Fix I2C lockups, improve error handling and performance Jul 26, 2022
@KarlK90 KarlK90 changed the title [RP2040] RX Fix I2C lockups, improve error handling and performance [RP2040] Fix I2C lockups, improve error handling and performance Jul 26, 2022
Problem:

* in edge-case scenarios the tx empty interrupt was still enabled after a
  transmission was finished. This would lead to endless interrupt tail
  chaining that completely starved the system.

Solution:

* all irqs are now disabled at the end of a transaction by default

Error handling:

* all error condition irqs like over and underruns of tx and rx fifos
  are now enabled and handled with an wake-up of the sleeping thread
  plus disabling of all irqs

Optimizations:

* irq status register is only read once for evalutation in the irq
  handler
* better utilization of the rx fifos during reception, which are now only
  read if all data has been successfully received.
@fpoussin fpoussin merged commit 49da37f into ChibiOS:chibios-21.11.x Jul 27, 2022
@KarlK90 KarlK90 deleted the fix/rp2040-i2c-irq-lockup branch July 27, 2022 07:37
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.

[Bug] OLED over I2C on RP2040 causes secondary half of split keyboard to slowdown and crash
2 participants