git: 6058dfa40238 - main - e1000: Compare decoded PCH LTR latencies

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Tue, 11 Aug 2026 20:45:17 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=6058dfa40238e2cd6ac6f2377986fdff99d14686

commit 6058dfa40238e2cd6ac6f2377986fdff99d14686
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-11 16:18:33 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-11 20:44:58 +0000

    e1000: Compare decoded PCH LTR latencies
    
    The LTR encoding combines a value and a nonlinear scale, so encoded
    values cannot be compared directly.  Decode both the device latency and
    the platform maximum before deciding whether to clamp the request.
    
    MFC after:      2 weeks
---
 sys/dev/e1000/e1000_ich8lan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/dev/e1000/e1000_ich8lan.c b/sys/dev/e1000/e1000_ich8lan.c
index 29f5b2ff69bd..e7ff5a581ad1 100644
--- a/sys/dev/e1000/e1000_ich8lan.c
+++ b/sys/dev/e1000/e1000_ich8lan.c
@@ -1218,6 +1218,7 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
 		u16 speed, duplex, scale = 0;
 		u16 max_snoop, max_nosnoop;
 		u16 max_ltr_enc;	/* max LTR latency encoded */
+		u64 max_ltr_ns;
 		s64 lat_ns;
 		s64 value;
 		u32 rxa;
@@ -1266,10 +1267,11 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
 		e1000_read_pci_cfg(hw, E1000_PCI_LTR_CAP_LPT, &max_snoop);
 		e1000_read_pci_cfg(hw, E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);
 		max_ltr_enc = E1000_MAX(max_snoop, max_nosnoop);
+		max_ltr_ns = e1000_ltr2ns(max_ltr_enc);
 
-		if (lat_enc > max_ltr_enc) {
+		if (e1000_ltr2ns(lat_enc) > max_ltr_ns) {
 			lat_enc = max_ltr_enc;
-			lat_ns = e1000_ltr2ns(max_ltr_enc);
+			lat_ns = max_ltr_ns;
 		}
 
 		if (lat_ns) {