Skip to content

Remove msync() on /dev/fb0 mmap: blocks forever on PW3, freezing the device#3

Open
iamgagan wants to merge 1 commit into
thecodedose:mainfrom
iamgagan:fix-pw3-msync-freeze
Open

Remove msync() on /dev/fb0 mmap: blocks forever on PW3, freezing the device#3
iamgagan wants to merge 1 commit into
thecodedose:mainfrom
iamgagan:fix-pw3-msync-freeze

Conversation

@iamgagan

@iamgagan iamgagan commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #2.

On a Kindle Paperwhite 7th gen (PW3, 2015, firmware 5.x, mxcfb driver), msync(fb, screensize, MS_SYNC) on the /dev/fb0 mapping never returns. The pixel copy completes (the save-pgm is written correctly) but execution never reaches the eips '' refresh, so the screen never updates. Because the input thread holds an exclusive EVIOCGRAB on the touchscreen, the whole device appears frozen and users end up force-rebooting.

Diagnosed by instrumenting renderToFramebuffer() with a marker after each step; the log ends at the copy step while the touch thread keeps logging events (full trace in #2).

The three msync calls (one in renderToFramebuffer(), two in flashTouchRectOnFramebuffer()) are unnecessary: the mapping is MAP_SHARED on device memory, so stores land directly in framebuffer memory, and the e-ink refresh is driven by eips/the EPDC rather than page-cache writeback.

Verified on a real PW3: with the calls removed, the dashboard renders, refreshes, and the tap feedback flash works. make -C kindle/native local (native:check) still passes.

🤖 Generated with Claude Code

…device

On a Kindle Paperwhite 7th gen (PW3, 2015, mxcfb driver),
msync(fb, screensize, MS_SYNC) on the framebuffer mapping never returns.
The render completes (save-pgm is written) but execution never reaches the
eips refresh, so the screen stays unchanged while the input thread keeps an
exclusive EVIOCGRAB on the touchscreen - the whole device appears frozen
until a forced reboot.

The calls are unnecessary: the mapping is MAP_SHARED on device memory, so
stores land directly in framebuffer memory, and the display refresh is
driven by eips/the EPDC rather than page-cache writeback. Verified on a
PW3: with msync removed, rendering and the tap feedback flash work.

Fixes thecodedose#2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@iamgagan iamgagan changed the title Remove msync() on /dev/fb0 mmap: blocks forever on PW3, freezing the … Remove msync() on /dev/fb0 mmap: blocks forever on PW3, freezing the device Jul 12, 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.

Freeze on Paperwhite 3: msync() on /dev/fb0 mmap blocks forever, screen never updates

1 participant