lspci: Slot Power Limit values above EFh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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];
 }
 



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux