Máté Kukri has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83736?usp=email )
Change subject: mb/dell/optiplex_9020: Fix UB challenged package power calculation ......................................................................
mb/dell/optiplex_9020: Fix UB challenged package power calculation
Signed-off-by: Mate Kukri km@mkukri.xyz Change-Id: I48ef59c4fbeb0a55675ac24da31e6e0b194cb58d --- M src/mainboard/dell/optiplex_9020/mainboard.c 1 file changed, 4 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/83736/1
diff --git a/src/mainboard/dell/optiplex_9020/mainboard.c b/src/mainboard/dell/optiplex_9020/mainboard.c index 6630a12..c1acbe2 100644 --- a/src/mainboard/dell/optiplex_9020/mainboard.c +++ b/src/mainboard/dell/optiplex_9020/mainboard.c @@ -303,11 +303,10 @@
static uint16_t get_pkg_power(void) { - uint8_t rapl_power_unit = rdmsr(0x606).lo & 0xf; - if (rapl_power_unit) - rapl_power_unit = 2 << (rapl_power_unit - 1); - uint16_t pkg_power_info = rdmsr(0x614).lo & 0x7fff; - if (pkg_power_info / rapl_power_unit > 0x41) + unsigned int pkg_power, power_unit; + pkg_power = rdmsr(0x614).lo & 0x7fff; + power_unit = 1 << (rdmsr(0x606).lo & 0xf); + if (pkg_power / power_unit > 0x41) return 32; else return 16;