[PATCH v5 0/2] AMD Promontory 21 xHCI temperature sensor support

Jihong Min posted 2 patches 1 month ago
There is a newer version of this series
Documentation/hwmon/index.rst                 |   1 +
Documentation/hwmon/prom21-xhci.rst           | 101 ++++++++
drivers/hwmon/Kconfig                         |  10 +
drivers/hwmon/Makefile                        |   1 +
drivers/hwmon/prom21-xhci.c                   | 238 ++++++++++++++++++
drivers/usb/host/Kconfig                      |  20 ++
drivers/usb/host/Makefile                     |   1 +
drivers/usb/host/xhci-pci-prom21.c            | 123 +++++++++
drivers/usb/host/xhci-pci.c                   |  11 +
drivers/usb/host/xhci-pci.h                   |   3 +
include/linux/platform_data/usb-xhci-prom21.h |  22 ++
11 files changed, 531 insertions(+)
create mode 100644 Documentation/hwmon/prom21-xhci.rst
create mode 100644 drivers/hwmon/prom21-xhci.c
create mode 100644 drivers/usb/host/xhci-pci-prom21.c
create mode 100644 include/linux/platform_data/usb-xhci-prom21.h
[PATCH v5 0/2] AMD Promontory 21 xHCI temperature sensor support
Posted by Jihong Min 1 month ago
Hi,

This series adds temperature monitoring for AMD Promontory 21 (PROM21)
xHCI PCI functions.

Patch 1 adds a small PROM21-specific xHCI PCI glue driver. USB host
operation is delegated to the common xhci-pci code, while the PROM21 glue
publishes an auxiliary device for optional sensor support.

Patch 2 adds an auxiliary-bus hwmon driver that binds to that auxiliary
device and exposes the PROM21 xHCI temperature value as temp1_input.

The hwmon driver reads the sensor through a vendor index/data register pair
in the xHCI PCI MMIO BAR. It does not wake the parent PCI device for hwmon
reads; if the parent is suspended, the read returns -ENODATA.

Changes in v5:
- Add support for AMD 1022:43fc PROM21 xHCI controllers and document the
  new PCI ID.
- Make USB_XHCI_PCI_PROM21 depend on X86 and default to USB_XHCI_PCI.
- Keep the PROM21 PCI glue built-in-only when enabled, while allowing the
  hwmon sensor driver to be built as a separate module.
- Move PROM21 xHCI PCI device IDs to xhci-pci.h so xhci-pci.c and
  xhci-pci-prom21.c use shared definitions.
- Pass the parent PCI device, MMIO base, and resource length to the hwmon
  driver through platform data defined in a common header, instead of
  inspecting the parent driver's drvdata from the hwmon driver.
- Remove the private hwmon mutex and rely on hwmon core serialization for
  this driver's callbacks.
- Clarify that the driver only serializes its own hwmon callbacks and does
  not synchronize with firmware, SMM, ACPI AML, or other possible users of
  the PROM21 vendor index/data register pair.
- Use readb() for the temperature data register, validate the value before
  writing the output pointer, and drop the 0xff invalid-value check.
- Use pm_runtime_put() after successful reads with the parent device active
  so the PM core can re-evaluate the parent device's idle state.
- Simplify the documentation and use more precise terminology for the
  supported device.

Jihong Min (2):
  usb: xhci-pci: add AMD Promontory 21 PCI glue
  hwmon: add AMD Promontory 21 xHCI temperature sensor support

 Documentation/hwmon/index.rst                 |   1 +
 Documentation/hwmon/prom21-xhci.rst           | 101 ++++++++
 drivers/hwmon/Kconfig                         |  10 +
 drivers/hwmon/Makefile                        |   1 +
 drivers/hwmon/prom21-xhci.c                   | 238 ++++++++++++++++++
 drivers/usb/host/Kconfig                      |  20 ++
 drivers/usb/host/Makefile                     |   1 +
 drivers/usb/host/xhci-pci-prom21.c            | 123 +++++++++
 drivers/usb/host/xhci-pci.c                   |  11 +
 drivers/usb/host/xhci-pci.h                   |   3 +
 include/linux/platform_data/usb-xhci-prom21.h |  22 ++
 11 files changed, 531 insertions(+)
 create mode 100644 Documentation/hwmon/prom21-xhci.rst
 create mode 100644 drivers/hwmon/prom21-xhci.c
 create mode 100644 drivers/usb/host/xhci-pci-prom21.c
 create mode 100644 include/linux/platform_data/usb-xhci-prom21.h

-- 
2.53.0
Re: [PATCH v5 0/2] AMD Promontory 21 xHCI temperature sensor support
Posted by Mario Limonciello 1 month ago

On 5/12/26 16:39, Jihong Min wrote:
> Hi,
> 
> This series adds temperature monitoring for AMD Promontory 21 (PROM21)
> xHCI PCI functions.
> 
> Patch 1 adds a small PROM21-specific xHCI PCI glue driver. USB host
> operation is delegated to the common xhci-pci code, while the PROM21 glue
> publishes an auxiliary device for optional sensor support.
> 
> Patch 2 adds an auxiliary-bus hwmon driver that binds to that auxiliary
> device and exposes the PROM21 xHCI temperature value as temp1_input.
> 
> The hwmon driver reads the sensor through a vendor index/data register pair
> in the xHCI PCI MMIO BAR. It does not wake the parent PCI device for hwmon
> reads; if the parent is suspended, the read returns -ENODATA.
> 
> Changes in v5:
> - Add support for AMD 1022:43fc PROM21 xHCI controllers and document the
>    new PCI ID.
> - Make USB_XHCI_PCI_PROM21 depend on X86 and default to USB_XHCI_PCI.
> - Keep the PROM21 PCI glue built-in-only when enabled, while allowing the
>    hwmon sensor driver to be built as a separate module.
> - Move PROM21 xHCI PCI device IDs to xhci-pci.h so xhci-pci.c and
>    xhci-pci-prom21.c use shared definitions.
> - Pass the parent PCI device, MMIO base, and resource length to the hwmon
>    driver through platform data defined in a common header, instead of
>    inspecting the parent driver's drvdata from the hwmon driver.
> - Remove the private hwmon mutex and rely on hwmon core serialization for
>    this driver's callbacks.
> - Clarify that the driver only serializes its own hwmon callbacks and does
>    not synchronize with firmware, SMM, ACPI AML, or other possible users of
>    the PROM21 vendor index/data register pair.
> - Use readb() for the temperature data register, validate the value before
>    writing the output pointer, and drop the 0xff invalid-value check.
> - Use pm_runtime_put() after successful reads with the parent device active
>    so the PM core can re-evaluate the parent device's idle state.
> - Simplify the documentation and use more precise terminology for the
>    supported device.
> 
> Jihong Min (2):
>    usb: xhci-pci: add AMD Promontory 21 PCI glue
>    hwmon: add AMD Promontory 21 xHCI temperature sensor support
> 
>   Documentation/hwmon/index.rst                 |   1 +
>   Documentation/hwmon/prom21-xhci.rst           | 101 ++++++++
>   drivers/hwmon/Kconfig                         |  10 +
>   drivers/hwmon/Makefile                        |   1 +
>   drivers/hwmon/prom21-xhci.c                   | 238 ++++++++++++++++++
>   drivers/usb/host/Kconfig                      |  20 ++
>   drivers/usb/host/Makefile                     |   1 +
>   drivers/usb/host/xhci-pci-prom21.c            | 123 +++++++++
>   drivers/usb/host/xhci-pci.c                   |  11 +
>   drivers/usb/host/xhci-pci.h                   |   3 +
>   include/linux/platform_data/usb-xhci-prom21.h |  22 ++
>   11 files changed, 531 insertions(+)
>   create mode 100644 Documentation/hwmon/prom21-xhci.rst
>   create mode 100644 drivers/hwmon/prom21-xhci.c
>   create mode 100644 drivers/usb/host/xhci-pci-prom21.c
>   create mode 100644 include/linux/platform_data/usb-xhci-prom21.h
> 

Thanks for the driver.  I think this looks good now, and thank you 
especially for documenting your reverse engineering efforts that led to 
it.  If there are problems in the future I'm supposing it's going to be 
based upon the calculations with the magic values to scale numbers.

There isn't a lot that can be done in the event that BIOS is accessing 
the same register pairs, but since you identified that this is exactly 
how Windows HWInfo64 does it too; this is 'probably' low risk.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Re: [PATCH v5 0/2] AMD Promontory 21 xHCI temperature sensor support
Posted by Jihong Min 1 month ago
One additional note about AI assistance and authorship:

I am adding this note because this series has been mentioned in some online
discussions as a newly written Linux driver carrying an AI assistance 
tag. I do
not want this to create confusion about authorship or responsibility, so 
I would
like to clarify the scope of the AI assistance.

The initial hardware investigation was my work. My starting assumption 
was that
the value was exposed through MMIO. I identified the paired MMIO 
registers, and
the empirical conversion formula was derived from my own testing, 
starting from
the assumption that the raw value could be mapped with a simple linear 
formula.
AI assistance was used for writing and refining test scripts around my own
probing library and existing tools such as pciutils, but the probing 
approach,
comparison with an existing tool (HWiNFO64), and interpretation of the 
results
were mine.

The first hwmon implementation, including the MMIO access sequence, was my
work. I used AI assistance while figuring out how to integrate the 
driver with
the existing xhci-pci infrastructure, especially around managed resource
handling and lifetime management.

After review feedback, the design moved toward an auxiliary-device 
model. That
direction came from the reviewers. Since I did not have prior experience 
with
the auxiliary bus, I used AI assistance extensively while implementing and
iterating on that part. I reviewed and tested the resulting code myself, and
also used AI-assisted review passes to look for mistakes.

In later revisions, the PROM21-specific PCI glue driver and the 
platform-data
handoff between the PCI glue and the hwmon auxiliary driver were implemented
based on reviewer feedback and my own PCIe driver experience. The runtime PM
policy was initially chosen by me and later refined through review feedback
from multiple reviewers. The implementation was structured by me based 
on that
feedback, with AI assistance used for additional code review and 
implementation
checks.

Runtime testing and validation were done by me, using the methods 
described in
the driver documentation. The decisions about which reviewer suggestions to
accept and how to revise the design were mine.

I am disclosing this because I want to follow the kernel project's 
guidance on
AI-assisted work and be transparent about the process. The Signed-off-by 
tag is
mine. I understand that this means I am responsible for the submitted 
code, the
design choices, the testing claims, and any mistakes in the patch series.

AI assistance was also used to review and polish some of my English email
replies and documentation wording. I reviewed those texts myself before 
sending
them.



P.S. Thanks to Yaroslav Isakov for testing the series on a B850 system and
reporting the additional 1022:43fc PCI ID variant.


Sincerely,
Jihong Min


On 5/13/26 06:39, Jihong Min wrote:
> Hi,
>
> This series adds temperature monitoring for AMD Promontory 21 (PROM21)
> xHCI PCI functions.
>
> Patch 1 adds a small PROM21-specific xHCI PCI glue driver. USB host
> operation is delegated to the common xhci-pci code, while the PROM21 glue
> publishes an auxiliary device for optional sensor support.
>
> Patch 2 adds an auxiliary-bus hwmon driver that binds to that auxiliary
> device and exposes the PROM21 xHCI temperature value as temp1_input.
>
> The hwmon driver reads the sensor through a vendor index/data register pair
> in the xHCI PCI MMIO BAR. It does not wake the parent PCI device for hwmon
> reads; if the parent is suspended, the read returns -ENODATA.
>
> Changes in v5:
> - Add support for AMD 1022:43fc PROM21 xHCI controllers and document the
>    new PCI ID.
> - Make USB_XHCI_PCI_PROM21 depend on X86 and default to USB_XHCI_PCI.
> - Keep the PROM21 PCI glue built-in-only when enabled, while allowing the
>    hwmon sensor driver to be built as a separate module.
> - Move PROM21 xHCI PCI device IDs to xhci-pci.h so xhci-pci.c and
>    xhci-pci-prom21.c use shared definitions.
> - Pass the parent PCI device, MMIO base, and resource length to the hwmon
>    driver through platform data defined in a common header, instead of
>    inspecting the parent driver's drvdata from the hwmon driver.
> - Remove the private hwmon mutex and rely on hwmon core serialization for
>    this driver's callbacks.
> - Clarify that the driver only serializes its own hwmon callbacks and does
>    not synchronize with firmware, SMM, ACPI AML, or other possible users of
>    the PROM21 vendor index/data register pair.
> - Use readb() for the temperature data register, validate the value before
>    writing the output pointer, and drop the 0xff invalid-value check.
> - Use pm_runtime_put() after successful reads with the parent device active
>    so the PM core can re-evaluate the parent device's idle state.
> - Simplify the documentation and use more precise terminology for the
>    supported device.
>
> Jihong Min (2):
>    usb: xhci-pci: add AMD Promontory 21 PCI glue
>    hwmon: add AMD Promontory 21 xHCI temperature sensor support
>
>   Documentation/hwmon/index.rst                 |   1 +
>   Documentation/hwmon/prom21-xhci.rst           | 101 ++++++++
>   drivers/hwmon/Kconfig                         |  10 +
>   drivers/hwmon/Makefile                        |   1 +
>   drivers/hwmon/prom21-xhci.c                   | 238 ++++++++++++++++++
>   drivers/usb/host/Kconfig                      |  20 ++
>   drivers/usb/host/Makefile                     |   1 +
>   drivers/usb/host/xhci-pci-prom21.c            | 123 +++++++++
>   drivers/usb/host/xhci-pci.c                   |  11 +
>   drivers/usb/host/xhci-pci.h                   |   3 +
>   include/linux/platform_data/usb-xhci-prom21.h |  22 ++
>   11 files changed, 531 insertions(+)
>   create mode 100644 Documentation/hwmon/prom21-xhci.rst
>   create mode 100644 drivers/hwmon/prom21-xhci.c
>   create mode 100644 drivers/usb/host/xhci-pci-prom21.c
>   create mode 100644 include/linux/platform_data/usb-xhci-prom21.h
>