In CXL 3.0 SPEC, 8.2.9.8.3.1 and 8.2.9.8.3.2 define temperature fields
as a 2's complement value. However, they are retrieved by the same accessor
for unsigned value. This causes inaccuracy when the value is negative.

The first patch updates the pre-defined value for temperature field of
the Get Health Info command when it is not implemented by complying
CXL 3.0 specification. (CXL 3.0 8.2.9.8.3.1)

The second patch fixes accessors for temperature fields.
Add a new payload accessor for a signed value, then use it for retrieving
temperature properly. INT_MAX is used to indicate errors because negative
errno codes are not distinguishable from the retrieved values when they are
negative. Caller should check errno to know what kind of error occurs.

The third patch fixes the checking value when listing device's health info.

Changes in v2:
- Rebase on the latest pending branch
- Remove dbg() messages in libcxl accessors (Vishal)
- Make signed value accessors to return INT_MAX when error occurs and set
  errno as proper errno codes (Vishal)
- Use proper value for checking "life_used" and "device_temperature" fields
  are implemented
- Link to v1: 
https://lore.kernel.org/r/[email protected]/

Jehoon Park (3):
  libcxl: Update a revision by CXL 3.0 specification
  libcxl: Fix accessors for temperature field to support negative value
  cxl: Fix the checking value when listing device's health info

 cxl/json.c        |  9 +++++----
 cxl/lib/libcxl.c  | 32 +++++++++++++++++++++-----------
 cxl/lib/private.h |  2 +-
 3 files changed, 27 insertions(+), 16 deletions(-)


base-commit: a871e6153b11fe63780b37cdcb1eb347b296095c
-- 
2.17.1


Reply via email to