From b9a0d8634de4e0ac8e830bb0a26a2c2d4479c7ac Mon Sep 17 00:00:00 2001 From: ooonea <35407790+ooonea@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:56:37 +0200 Subject: [PATCH] throttled: use mmio.write64/read64 for MCHBAR PKG_POWER_LIMIT Replaces the open-coded write32(0, low) + write32(4, high) pair (and the matching read32 merge in the debug path) with a single 64-bit access. Besides being less code, this also closes a small window between the two 32-bit writes in which the register briefly held (new_low, old_high). Signed-off-by: ooonea <35407790+ooonea@users.noreply.github.com> --- throttled.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/throttled.py b/throttled.py index 31e0d18..f9030f7 100755 --- a/throttled.py +++ b/throttled.py @@ -770,10 +770,9 @@ def power_thread(config, regs, exit_event, cpuid): log(f'[D] MSR PACKAGE_POWER_LIMIT - write {write_value:#x} - read {read_value:#x} - match {match}') if mchbar_mmio is not None: # set MCHBAR register to the same PL1/2 values - mchbar_mmio.write32(0, write_value & 0xFFFFFFFF) - mchbar_mmio.write32(4, write_value >> 32) + mchbar_mmio.write64(0, write_value) if args.debug: - read_value = mchbar_mmio.read32(0) | (mchbar_mmio.read32(4) << 32) + read_value = mchbar_mmio.read64(0) match = OK if write_value == read_value else ERR log( f'[D] MCHBAR PACKAGE_POWER_LIMIT - write {write_value:#x} - read {read_value:#x} - match {match}'