Skip to content

Commit

Permalink
DasharoSystemFeaturesUiLib: Use callbacks to update CPU Throttling Th…
Browse files Browse the repository at this point in the history
…reshold

For some reason the CPU Throttling Threshold dsiplayed negative value when
user changed CPU throttling, exited Power Management Options menu, went back
to front page and then entered Power Management Options menu again.

Always calculate the threshold based on PCD and current throttling offset
value. Add interactive flag to the options and patch the value in the
callback.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
  • Loading branch information
miczyg1 committed Feb 4, 2025
1 parent e6e8326 commit 27e4a00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ DasharoSystemFeaturesUiLibConstructor (
PRIVATE_DATA(ShowPs2Option) = FixedPcdGetBool (PcdShowPs2Option);
PRIVATE_DATA(Have2ndUart) = FixedPcdGetBool (PcdHave2ndUart);
PRIVATE_DATA(ShowCpuThrottlingThreshold) = FixedPcdGetBool (PcdShowCpuThrottlingThreshold);
PRIVATE_DATA(CpuMaxTemperature) = FixedPcdGet8 (PcdCpuMaxTemperature);
PRIVATE_DATA(ShowCpuCoreDisable) = FixedPcdGetBool(PcdShowCpuCoreDisable);
PRIVATE_DATA(ShowCpuHyperThreading) = FixedPcdGetBool(PcdShowCpuHyperThreading);
PRIVATE_DATA(WatchdogAvailable) = FixedPcdGetBool (PcdShowOcWdtOptions);
Expand Down Expand Up @@ -280,7 +279,7 @@ DasharoSystemFeaturesUiLibConstructor (
#undef LOAD_VAR

PRIVATE_DATA(CpuThrottlingThreshold) =
PRIVATE_DATA(CpuMaxTemperature) - PRIVATE_DATA(CpuThrottlingOffset);
FixedPcdGet8(PcdCpuMaxTemperature) - PRIVATE_DATA(CpuThrottlingOffset);

if (PRIVATE_DATA(HybridCpuArchitecture) &&
PRIVATE_DATA(SmallCoreActiveCount) == 0 &&
Expand Down Expand Up @@ -619,10 +618,29 @@ DasharoSystemFeaturesCallback (
{
EFI_STATUS Status;
EFI_INPUT_KEY Key;
DASHARO_SYSTEM_FEATURES_PRIVATE_DATA *Private;

Status = EFI_SUCCESS;
Private = DASHARO_SYSTEM_FEATURES_PRIVATE_DATA_FROM_THIS (This);

switch (Action) {
case EFI_BROWSER_ACTION_RETRIEVE:
switch (QuestionId) {
case CPU_THROTTLING_THRESHOLD_QUESTION_ID:
/*
* For some reason CpuMaxTemperature is zeroed when user changes CPU
* throttling, exits PWR MGMT menu, goes to front page and goes back to
* PWR MGMT menu again. It results in the negative throttling threshold
* to be displayed. Always calculate the threshold based on PCD and
* current throttling offset value.
*/
Value->u8 = FixedPcdGet8(PcdCpuMaxTemperature) - Private->DasharoFeaturesData.CpuThrottlingOffset;
break;
default:
Status = EFI_UNSUPPORTED;
break;
}
break;
case EFI_BROWSER_ACTION_DEFAULT_STANDARD:
case EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ typedef struct {
BOOLEAN SerialPort2Redirection;
UINT8 CpuThrottlingThreshold;
UINT8 CpuThrottlingOffset;
UINT8 CpuMaxTemperature;
BOOLEAN HybridCpuArchitecture;
BOOLEAN HyperThreadingSupported;
BOOLEAN HyperThreading;
Expand Down Expand Up @@ -152,5 +151,6 @@ typedef struct {
#define SERIAL_PORT2_REDIR_QUESTION_ID 0x800B
#define HYPER_THREADING_QUESTION_ID 0x800C
#define CPU_THROTTLING_OFFSET_QUESTION_ID 0x800D
#define CPU_THROTTLING_THRESHOLD_QUESTION_ID 0x800E

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -369,19 +369,18 @@ formset
maximum = 63,
step = 1,

write set(FeaturesData.CpuThrottlingThreshold, get(FeaturesData.CpuMaxTemperature) - pushthis);
write set(FeaturesData.CpuThrottlingThreshold, FixedPcdGet8(PcdCpuMaxTemperature) - pushthis);

endnumeric;

grayoutif TRUE;
numeric varid = FeaturesData.CpuThrottlingThreshold,
questionid = CPU_THROTTLING_THRESHOLD_QUESTION_ID,
prompt = STRING_TOKEN(STR_CPU_THROTTLING_THRESHOLD_PROMPT),
help = STRING_TOKEN(STR_CPU_THROTTLING_THRESHOLD_HELP),
flags = INTERACTIVE,
minimum = 0,
maximum = 255,

read get(FeaturesData.CpuMaxTemperature) - get(FeaturesData.CpuThrottlingOffset);

endnumeric;
endif;
endif;
Expand Down

0 comments on commit 27e4a00

Please sign in to comment.