From cedbcba3e32c0995b5eb5555cfcbdb3d65b2e931 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 24 Jan 2019 11:41:32 -0800 Subject: [PATCH] 0.8.3: fix some memory/deadlock issues --- stratosphere/fs_mitm/source/fsmitm_main.cpp | 13 +++++-------- stratosphere/pm/source/pm_resource_limits.cpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/stratosphere/fs_mitm/source/fsmitm_main.cpp b/stratosphere/fs_mitm/source/fsmitm_main.cpp index 40808a34c..24fa8b647 100644 --- a/stratosphere/fs_mitm/source/fsmitm_main.cpp +++ b/stratosphere/fs_mitm/source/fsmitm_main.cpp @@ -62,6 +62,11 @@ void __appInit(void) { fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); } + rc = fsInitialize(); + if (R_FAILED(rc)) { + fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); + } + CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); } @@ -89,14 +94,6 @@ int main(int argc, char **argv) /* Create fsp-srv mitm. */ AddMitmServerToManager(server_manager, "fsp-srv", 61); - - /* Connect to FS */ - { - Result rc = fsInitialize(); - if (R_FAILED(rc)) { - fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); - } - } if (R_FAILED(threadCreate(&sd_initializer_thread, &Utils::InitializeSdThreadFunc, NULL, 0x4000, 0x15, 0))) { /* TODO: Panic. */ diff --git a/stratosphere/pm/source/pm_resource_limits.cpp b/stratosphere/pm/source/pm_resource_limits.cpp index 4dcdfa5a8..99763cbf4 100644 --- a/stratosphere/pm/source/pm_resource_limits.cpp +++ b/stratosphere/pm/source/pm_resource_limits.cpp @@ -179,11 +179,17 @@ void ResourceLimitUtils::InitializeLimits() { } } - /* Atmosphere: Allocate extra memory (24 MiB) to SYSTEM away from Application. */ + /* Atmosphere: Allocate extra memory (24 MiB) to SYSTEM away from Applet. */ for (unsigned int i = 0; i < 6; i++) { g_memory_resource_limits[i][0] += ATMOSPHERE_EXTRA_SYSTEM_MEMORY_FOR_SYSMODULES; - /* Taking from application instead of applet fixes a rare hang on boot on < 4.0.0. */ - g_memory_resource_limits[i][1] -= ATMOSPHERE_EXTRA_SYSTEM_MEMORY_FOR_SYSMODULES; + /* On < 4.0.0, taking from application instead of applet fixes a rare hang on boot. */ + if (kernelAbove600()) { + g_memory_resource_limits[i][1] -= ATMOSPHERE_EXTRA_SYSTEM_MEMORY_FOR_SYSMODULES; + } else if (kernelAbove400()) { + g_memory_resource_limits[i][2] -= ATMOSPHERE_EXTRA_SYSTEM_MEMORY_FOR_SYSMODULES; + } else { + g_memory_resource_limits[i][1] -= ATMOSPHERE_EXTRA_SYSTEM_MEMORY_FOR_SYSMODULES; + } } /* Set resource limits. */