SF: Restore mStateLock mutex for modesetting
In order to fix a deadlock during display hotplug, the modesetting mutex
was changed from mStateLock to a granular DisplayModeController lock, in
the following CLs:
I30ec756f134d2d67a70ac8797008dc792eac035e
Iaae02d95e175e55f52f65da1481b64f1f533a04c (reverted)
This exposed a data race leading to a crash, which, unlike the deadlock,
affects all devices with refresh rate switching. The race will be fixed
by:
If6141d2928643e82b3251b321e18c300cd8c201c (WIP)
As a stopgap until then, restore mStateLock (on top of the DMC lock) on
the main thread to fix the race, but reintroduce the deadlock. The lock
was already restored on the idle timer thread by the reverted CL above.
Fixes: 348827779
Flag: com.android.graphics.surfaceflinger.flags.connected_display
Test: Manual (foldable, connected display)
Change-Id: Ie15de10d16eefeb65289574b120d2ef4cc09d6c0
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 3369e00..8446de7 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -739,9 +739,9 @@
status_t setActiveModeFromBackdoor(const sp<display::DisplayToken>&, DisplayModeId, Fps minFps,
Fps maxFps);
- void initiateDisplayModeChanges() REQUIRES(kMainThreadContext) EXCLUDES(mStateLock);
+ void initiateDisplayModeChanges() REQUIRES(kMainThreadContext) REQUIRES(mStateLock);
void finalizeDisplayModeChange(PhysicalDisplayId) REQUIRES(kMainThreadContext)
- EXCLUDES(mStateLock);
+ REQUIRES(mStateLock);
void dropModeRequest(PhysicalDisplayId) REQUIRES(kMainThreadContext);
void applyActiveMode(PhysicalDisplayId) REQUIRES(kMainThreadContext);