@@ -1009,9 +1009,8 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
10091009 mPowerAdvisor ->init ();
10101010
10111011 if (base::GetBoolProperty (" service.sf.prime_shader_cache" s, true )) {
1012- if (setSchedFifo (false ) != NO_ERROR) {
1013- ALOGW (" Can't set SCHED_OTHER for primeCache" );
1014- }
1012+ constexpr const char * kWhence = " primeCache" ;
1013+ setSchedFifo (false , kWhence );
10151014
10161015 mRenderEnginePrimeCacheFuture .callOnce ([this ] {
10171016 renderengine::PrimeCacheConfig config;
@@ -1047,9 +1046,7 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
10471046 return getRenderEngine ().primeCache (config);
10481047 });
10491048
1050- if (setSchedFifo (true ) != NO_ERROR) {
1051- ALOGW (" Can't set SCHED_FIFO after primeCache" );
1052- }
1049+ setSchedFifo (true , kWhence );
10531050 }
10541051
10551052 // Avoid blocking the main thread on `init` to set properties.
@@ -2286,8 +2283,7 @@ void SurfaceFlinger::scheduleSample() {
22862283
22872284void SurfaceFlinger::onComposerHalVsync (hal::HWDisplayId hwcDisplayId, int64_t timestamp,
22882285 std::optional<hal::VsyncPeriodNanos> vsyncPeriod) {
2289- if (FlagManager::getInstance ().connected_display () && timestamp < 0 &&
2290- vsyncPeriod.has_value ()) {
2286+ if (timestamp < 0 && vsyncPeriod.has_value ()) {
22912287 if (mIsHdcpViaNegVsync && vsyncPeriod.value () == ~1 ) {
22922288 const int32_t value = static_cast <int32_t >(-timestamp);
22932289 // one byte is good enough to encode android.hardware.drm.HdcpLevel
@@ -3564,9 +3560,8 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
35643560 std::vector<HWComposer::HWCDisplayMode> hwcModes;
35653561 std::optional<hal::HWConfigId> activeModeHwcIdOpt;
35663562
3567- const bool isExternalDisplay = FlagManager::getInstance ().connected_display () &&
3568- getHwComposer ().getDisplayConnectionType (displayId) ==
3569- ui::DisplayConnectionType::External;
3563+ const bool isExternalDisplay = getHwComposer ().getDisplayConnectionType (displayId) ==
3564+ ui::DisplayConnectionType::External;
35703565
35713566 int attempt = 0 ;
35723567 constexpr int kMaxAttempts = 3 ;
@@ -4066,8 +4061,7 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken,
40664061 // For an external display, loadDisplayModes already attempted to select the same mode
40674062 // as DM, but SF still needs to be updated to match.
40684063 // TODO (b/318534874): Let DM decide the initial mode.
4069- if (const auto & physical = state.physical ;
4070- mScheduler && physical && FlagManager::getInstance ().connected_display ()) {
4064+ if (const auto & physical = state.physical ; mScheduler && physical) {
40714065 const bool isInternalDisplay = mPhysicalDisplays .get (physical->id )
40724066 .transform (&PhysicalDisplay::isInternal)
40734067 .value_or (false );
@@ -5710,16 +5704,11 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
57105704 }
57115705
57125706 if (displayId == mActiveDisplayId ) {
5713- // TODO(b/281692563): Merge the syscalls. For now, keep uclamp in a separate syscall and
5714- // set it before SCHED_FIFO due to b/190237315.
5715- if (setSchedAttr (true ) != NO_ERROR) {
5716- ALOGW (" Failed to set uclamp.min after powering on active display: %s" ,
5717- strerror (errno));
5718- }
5719- if (setSchedFifo (true ) != NO_ERROR) {
5720- ALOGW (" Failed to set SCHED_FIFO after powering on active display: %s" ,
5721- strerror (errno));
5722- }
5707+ // TODO: b/281692563 - Merge the syscalls. For now, keep uclamp in a separate syscall
5708+ // and set it before SCHED_FIFO due to b/190237315.
5709+ constexpr const char * kWhence = " setPowerMode(ON)" ;
5710+ setSchedAttr (true , kWhence );
5711+ setSchedFifo (true , kWhence );
57235712 }
57245713
57255714 getHwComposer ().setPowerMode (displayId, mode);
@@ -5746,14 +5735,9 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
57465735 if (const auto display = getActivatableDisplay ()) {
57475736 onActiveDisplayChangedLocked (activeDisplay.get (), *display);
57485737 } else {
5749- if (setSchedFifo (false ) != NO_ERROR) {
5750- ALOGW (" Failed to set SCHED_OTHER after powering off active display: %s" ,
5751- strerror (errno));
5752- }
5753- if (setSchedAttr (false ) != NO_ERROR) {
5754- ALOGW (" Failed set uclamp.min after powering off active display: %s" ,
5755- strerror (errno));
5756- }
5738+ constexpr const char * kWhence = " setPowerMode(OFF)" ;
5739+ setSchedFifo (false , kWhence );
5740+ setSchedAttr (false , kWhence );
57575741
57585742 if (currentModeNotDozeSuspend) {
57595743 if (!FlagManager::getInstance ().multithreaded_present ()) {
@@ -7216,7 +7200,7 @@ static status_t validateScreenshotPermissions(const CaptureArgs& captureArgs) {
72167200 return PERMISSION_DENIED;
72177201}
72187202
7219- status_t SurfaceFlinger::setSchedFifo (bool enabled) {
7203+ void SurfaceFlinger::setSchedFifo (bool enabled, const char * whence ) {
72207204 static constexpr int kFifoPriority = 2 ;
72217205 static constexpr int kOtherPriority = 0 ;
72227206
@@ -7231,19 +7215,19 @@ status_t SurfaceFlinger::setSchedFifo(bool enabled) {
72317215 }
72327216
72337217 if (sched_setscheduler (0 , sched_policy, ¶m) != 0 ) {
7234- return -errno;
7218+ const char * kPolicy [] = {" SCHED_OTHER" , " SCHED_FIFO" };
7219+ ALOGW (" %s: Failed to set %s: %s" , whence, kPolicy [sched_policy == SCHED_FIFO],
7220+ strerror (errno));
72357221 }
7236-
7237- return NO_ERROR;
72387222}
72397223
7240- status_t SurfaceFlinger::setSchedAttr (bool enabled) {
7224+ void SurfaceFlinger::setSchedAttr (bool enabled, const char * whence ) {
72417225 static const unsigned int kUclampMin =
72427226 base::GetUintProperty<unsigned int >(" ro.surface_flinger.uclamp.min" s, 0U );
72437227
72447228 if (!kUclampMin ) {
72457229 // uclamp.min set to 0 (default), skip setting
7246- return NO_ERROR ;
7230+ return ;
72477231 }
72487232
72497233 sched_attr attr = {};
@@ -7254,10 +7238,9 @@ status_t SurfaceFlinger::setSchedAttr(bool enabled) {
72547238 attr.sched_util_max = 1024 ;
72557239
72567240 if (syscall (__NR_sched_setattr, 0 , &attr, 0 )) {
7257- return -errno;
7241+ const char * kAction [] = {" disable" , " enable" };
7242+ ALOGW (" %s: Failed to %s uclamp.min: %s" , whence, kAction [enabled], strerror (errno));
72587243 }
7259-
7260- return NO_ERROR;
72617244}
72627245
72637246namespace {
@@ -8377,10 +8360,6 @@ status_t SurfaceFlinger::getStalledTransactionInfo(
83778360
83788361void SurfaceFlinger::updateHdcpLevels (hal::HWDisplayId hwcDisplayId, int32_t connectedLevel,
83798362 int32_t maxLevel) {
8380- if (!FlagManager::getInstance ().connected_display ()) {
8381- return ;
8382- }
8383-
83848363 Mutex::Autolock lock (mStateLock );
83858364
83868365 const auto idOpt = getHwComposer ().toPhysicalDisplayId (hwcDisplayId);
0 commit comments