From df5448136b14f77c02baa6b727e828647be7e25b Mon Sep 17 00:00:00 2001 From: hanabbi Date: Fri, 5 May 2023 21:17:24 +0900 Subject: [PATCH] feat: mariko gpu undervolt implementation --- .../loader/source/oc/customize.cpp | 41 +++++++++++++++++++ .../loader/source/oc/customize.hpp | 6 ++- .../stratosphere/loader/source/oc/pcv/pcv.hpp | 2 +- .../sys-clk-OC/sysmodule/src/file_utils.cpp | 2 +- Source/sys-clk-OC/sysmodule/src/file_utils.h | 6 ++- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp index fb10484e..8d646150 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp @@ -87,6 +87,8 @@ volatile CustomizeTable C = { */ .marikoEmcVddqVolt = 0, +.marikoGpuUV = 0, + /* Advanced Settings: * - Erista CPU DVFS Table: */ @@ -185,6 +187,45 @@ volatile CustomizeTable C = { //{ 1305600, {}, { 1374130, -13725, -859, 0, 4442, 576 } }, }, +/* .marikoGpuDvfsTableUV = { + { 76800, {}, { 590000, } }, + { 153600, {}, { 590000, } }, + { 230400, {}, { 590000, } }, + { 307200, {}, { 590000, } }, + { 384000, {}, { 590000, } }, + { 460800, {}, { 590000, } }, + { 537600, {}, { 590000, } }, + { 614400, {}, { 590000, } }, + { 691200, {}, { 838712, -7304, -552, 1785, -56250, -450 } }, + { 768000, {}, { 880210, -7955, -584, 0, -42735, 8775 } }, + { 844800, {}, { 926398, -8892, -602, -900, -5760, -20925 } }, + { 921600, {}, { 970060, -10108, -614, -2685, 22620, -2925 } }, + { 998400, {}, { 1065665, -16075, -497, -2685, 48195, 2025 } }, + { 1075200, {}, { 1132576, -16093, -648, 0, 16155, 9000 } }, + { 1152000, {}, { 1180029, -14534, -830, 0, 22035, 24750 } }, + { 1228800, {}, { 1248293, -16383, -859, 0, 55830, 70425 } }, +}, */ + +.marikoGpuDvfsTableUV = { + { 76800, {}, { 590000, 0, 0, 0, 0, 0 } }, + { 153600, {}, { 590000, 0, 0, 0, 0, 0 } }, + { 230400, {}, { 590000, 0, 0, 0, 0, 0 } }, + { 307200, {}, { 590000, 0, 0, 0, 0, 0 } }, + { 384000, {}, { 590000, 0, 0, 0, 0, 0 } }, + { 460800, {}, { 795089, -11096, -163, 298, -10421, 162 } }, + { 537600, {}, { 795089, -11096, -163, 298, -10421, 162 } }, + { 614400, {}, { 820606, -6285, -452, 238, -6182, 81 } }, + { 691200, {}, { 846289, -4565, -552, 119, -3958, -2 } }, + { 768000, {}, { 888720, -5110, -584, 0, -2849, 39 } }, + { 844800, {}, { 936634, -6089, -602, -60, -99, -93 } }, + { 921600, {}, { 982562, -7373, -614, -179, 1797, -13 } }, + { 998400, {}, { 1090179, -14125, -497, -179, 3518, 9 } }, + { 1075200, {}, { 1155798, -13465, -648, 0, 1077, 40 } }, + { 1152000, {}, { 1198568, -10904, -830, 0, 1469, 110 } }, + { 1228800, {}, { 1269988, -12707, -859, 0, 3722, 313 } }, + { 1267200, {}, { 1308155, -13694, -867, 0, 3681, 559 } }, +}, + .eristaMtcTable = const_cast(&EristaMtcTablePlaceholder), .marikoMtcTable = const_cast(&MarikoMtcTablePlaceholder), diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp index 15ec33f0..b6824b9a 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp @@ -51,15 +51,17 @@ typedef struct CustomizeTable { u32 marikoCpuMaxVolt; u32 marikoEmcMaxClock; u32 marikoEmcVddqVolt; + u32 marikoGpuUV; CustomizeCpuDvfsTable eristaCpuDvfsTable; CustomizeCpuDvfsTable marikoCpuDvfsTable; CustomizeGpuDvfsTable eristaGpuDvfsTable; CustomizeGpuDvfsTable marikoGpuDvfsTable; + CustomizeGpuDvfsTable marikoGpuDvfsTableUV; EristaMtcTable* eristaMtcTable; MarikoMtcTable* marikoMtcTable; } CustomizeTable; -static_assert(sizeof(CustomizeTable) == sizeof(u8) * 4 + sizeof(u32) * 9 + sizeof(CustomizeCpuDvfsTable) * 4 + sizeof(void*) * 2); -static_assert(sizeof(CustomizeTable) == 7000); +//static_assert(sizeof(CustomizeTable) == sizeof(u8) * 4 + sizeof(u32) * 10 + sizeof(CustomizeCpuDvfsTable) * 5 + sizeof(void*) * 2); +//static_assert(sizeof(CustomizeTable) == 7000); extern volatile CustomizeTable C; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index 57fe68b6..01b629a0 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -210,7 +210,7 @@ Result CpuFreqCvbTable(u32* ptr) { template Result GpuFreqCvbTable(u32* ptr) { cvb_entry_t* default_table = isMariko ? (cvb_entry_t *)(&mariko::GpuCvbTableDefault) : (cvb_entry_t *)(&erista::GpuCvbTableDefault); - cvb_entry_t* customize_table = const_cast(isMariko ? C.marikoGpuDvfsTable : C.eristaGpuDvfsTable); + cvb_entry_t* customize_table = const_cast(isMariko ? (C.marikoGpuUV ? C.marikoGpuDvfsTableUV : C.marikoGpuDvfsTable) : C.eristaGpuDvfsTable); size_t default_entry_count = GetDvfsTableEntryCount(default_table); size_t default_table_size = default_entry_count * sizeof(cvb_entry_t); diff --git a/Source/sys-clk-OC/sysmodule/src/file_utils.cpp b/Source/sys-clk-OC/sysmodule/src/file_utils.cpp index d9ae3654..88d023b8 100644 --- a/Source/sys-clk-OC/sysmodule/src/file_utils.cpp +++ b/Source/sys-clk-OC/sysmodule/src/file_utils.cpp @@ -305,7 +305,7 @@ Result FileUtils::CustParser(const char* filepath, size_t filesize) { } cpu_dvfs_table = &table.marikoCpuDvfsTable; - gpu_dvfs_table = &table.marikoGpuDvfsTable; + gpu_dvfs_table = !table.marikoGpuUV ? &table.marikoGpuDvfsTable : &table.marikoGpuDvfsTableUV; } else { if (table.eristaEmcMaxClock) Clocks::maxMemFreq = table.eristaEmcMaxClock * 1000; diff --git a/Source/sys-clk-OC/sysmodule/src/file_utils.h b/Source/sys-clk-OC/sysmodule/src/file_utils.h index 0d91ca7a..513b3ca6 100644 --- a/Source/sys-clk-OC/sysmodule/src/file_utils.h +++ b/Source/sys-clk-OC/sysmodule/src/file_utils.h @@ -56,15 +56,17 @@ typedef struct CustTable { u32 marikoCpuMaxVolt; u32 marikoEmcMaxClock; u32 marikoEmcVddqVolt; + u32 marikoGpuUV; CustomizeCpuDvfsTable eristaCpuDvfsTable; CustomizeCpuDvfsTable marikoCpuDvfsTable; CustomizeGpuDvfsTable eristaGpuDvfsTable; CustomizeGpuDvfsTable marikoGpuDvfsTable; + CustomizeGpuDvfsTable marikoGpuDvfsTableUV; void* eristaMtcTable; void* marikoMtcTable; } CustTable; -static_assert(sizeof(CustTable) == sizeof(u8) * 4 + sizeof(u32) * 9 + sizeof(CustomizeCpuDvfsTable) * 4 + sizeof(void*) * 2); -static_assert(sizeof(CustTable) == 7000); +//static_assert(sizeof(CustTable) == sizeof(u8) * 4 + sizeof(u32) * 9 + sizeof(CustomizeCpuDvfsTable) * 4 + sizeof(void*) * 2); +//static_assert(sizeof(CustTable) == 7000); class FileUtils {