linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* lspci: Slot Power Limit values above EFh
@ 2021-04-03 11:48 Pali Rohár
  2021-04-03 15:48 ` Matthew Wilcox
  2021-11-01 14:47 ` [PATCH v2] lspci: Show " Pali Rohár
  0 siblings, 2 replies; 10+ messages in thread
From: Pali Rohár @ 2021-04-03 11:48 UTC (permalink / raw)
  To: Martin Mares, Bjorn Helgaas, Krzysztof Wilczyński,
	Matthew Wilcox, linux-pci

Hello!

PCI Express Base Specification rev. 3.0 has the following definition for
the Slot Power Limit Value:

=======================================================================
When the Slot Power Limit Scale field equals 00b (1.0x) and Slot Power
Limit Value exceeds EFh, the following alternative encodings are used:
  F0h = 250 W Slot Power Limit
  F1h = 275 W Slot Power Limit
  F2h = 300 W Slot Power Limit
  F3h to FFh = Reserved for Slot Power Limit values above 300 W
=======================================================================

But the function power_limit() in ls-caps.c does not handle value above
EFh according to this definition.

Here is a simple patch which fixes it for values F0h..F2h. But I'm not
sure how (reserved) values above F2h should be handled.

diff --git a/ls-caps.c b/ls-caps.c
index db56556971cb..bc1eaa15017d 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -659,6 +659,9 @@ static int exp_downstream_port(int type)
 static float power_limit(int value, int scale)
 {
   static const float scales[4] = { 1.0, 0.1, 0.01, 0.001 };
+  static const int scale0_values[3] = { 250, 275, 300 }; /* F3h to FFh = Reserved for Slot Power Limit values above 300 W */
+  if (scale == 0 && value >= 0xF0)
+    value = scale0_values[(value > 0xF2 ? 0xF2 : value) & 0xF];
   return value * scales[scale];
 }
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-26 23:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-03 11:48 lspci: Slot Power Limit values above EFh Pali Rohár
2021-04-03 15:48 ` Matthew Wilcox
2021-11-01 14:47 ` [PATCH v2] lspci: Show " Pali Rohár
2021-11-01 15:03   ` Matthew Wilcox
2021-11-24 12:46     ` Pali Rohár
2021-12-26 22:07       ` Martin Mareš
2021-12-26 22:41         ` [PATCH v3 pciutils] " Pali Rohár
2021-12-26 22:43           ` Martin Mareš
2021-12-26 23:34             ` [PATCH v4 " Pali Rohár
2021-12-26 23:55               ` Martin Mareš

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).