AMD Promontory 21 xHCI temperature sensor support
Subsystems (5)
v6 cover AMD Promontory 21 xHCI temperature sensor support
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 v6:
- Make USB_XHCI_PCI_PROM21 a hidden tristate that follows USB_XHCI_PCI, so the PROM21 PCI glue is built in with a built-in xhci-pci core and built as a module with a modular xhci-pci core.
- Use an IDA-allocated auxiliary device id instead of encoding the PCI domain/BDF into the auxiliary id.
- Use a 32-bit read for the PROM21 vendor data register and mask the low byte instead of using readb().
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 | 239 ++++++++++++++++++ drivers/usb/host/Kconfig | 7 + drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-pci-prom21.c | 136 ++++++++++ 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, 532 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
Signature · 1 line
2.53.0
PATCH v6 1/2 usb: xhci-pci: add AMD Promontory 21 PCI glue
AMD Promontory 21 (PROM21) xHCI controllers use generic xHCI operation, but the PCI function also exposes optional controller-specific sensor functionality. Add a small PROM21 PCI glue driver for AMD 1022:43fc and 1022:43fd controllers.
The driver delegates USB host operation to the common xhci-pci core, collects the parent-provided MMIO resource data, and creates a "hwmon" auxiliary device for optional child drivers. Failure to create the auxiliary device is logged but does not fail the xHCI probe, since the auxiliary device is only needed for sensor support.
Make the PROM21 PCI glue a hidden Kconfig tristate that follows USB_XHCI_PCI. This keeps the glue built in with a built-in xhci-pci core and builds it as a module with a modular xhci-pci core. A built-in xhci-pci core must not hand PROM21 controllers to a PROM21 glue driver that is only available as a module, otherwise USB behind those controllers can be unavailable during initramfs and PROM21 temperature sensor support may not appear until the controller is rebound after the module loads.
--- drivers/usb/host/Kconfig | 7 + drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-pci-prom21.c | 136 ++++++++++++++++++ drivers/usb/host/xhci-pci.c | 11 ++ drivers/usb/host/xhci-pci.h | 3 + include/linux/platform_data/usb-xhci-prom21.h | 22 +++ 6 files changed, 180 insertions(+) create mode 100644 drivers/usb/host/xhci-pci-prom21.c create mode 100644 include/linux/platform_data/usb-xhci-prom21.h
drivers/usb/host/Kconfig +7 -0
@@ -42,6 +42,13 @@ config USB_XHCI_PCI depends on USB_PCI default y +config USB_XHCI_PCI_PROM21 + tristate + depends on X86 + depends on USB_XHCI_PCI + default USB_XHCI_PCI + select AUXILIARY_BUS + config USB_XHCI_PCI_RENESAS tristate "Support for additional Renesas xHCI controller with firmware" depends on USB_XHCI_PCI
drivers/usb/host/Makefile +1 -0
@@ -71,6 +71,7 @@ obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o +obj-$(CONFIG_USB_XHCI_PCI_PROM21) += xhci-pci-prom21.o obj-$(CONFIG_USB_XHCI_PCI_RENESAS) += xhci-pci-renesas.o obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o obj-$(CONFIG_USB_XHCI_HISTB) += xhci-histb.o
drivers/usb/host/xhci-pci-prom21.c new file +136 -0
136 lines not on this page · raw message
drivers/usb/host/xhci-pci.c +11 -0
@@ -696,12 +696,23 @@ static const struct pci_device_id pci_ids_renesas[] = { {/* end: all zeroes */ } }; +/* handled by xhci-pci-prom21 if enabled */ +static const struct pci_device_id pci_ids_prom21[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD ) }, + {/* end: all zeroes */ } +}; +static int xhci_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) {if (IS_ENABLED (CONFIG_USB_XHCI_PCI_RENESAS ) &&pci_match_id (pci_ids_renesas, dev))return -ENODEV ; +if (IS_ENABLED (CONFIG_USB_XHCI_PCI_PROM21 ) && +pci_match_id (pci_ids_prom21, dev)) +return -ENODEV ; +return xhci_pci_common_probe (dev, id); }
drivers/usb/host/xhci-pci.h +3 -0
@@ -4,6 +4,9 @@#ifndef XHCI_PCI_H #define XHCI_PCI_H +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC 0x43fc +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD 0x43fd +int xhci_pci_common_probe (struct pci_dev *dev,const struct pci_device_id *id);void xhci_pci_remove (struct pci_dev *dev);
include/linux/platform_data/usb-xhci-prom21.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* AMD Promontory 21 xHCI auxiliary device platform data. +* +* Copyright (C) 2026 Jihong Min <[email protected]> +*/ + +#ifndef _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H +#define _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H + +#include <linux/compiler_types.h> +#include <linux/types.h> + +struct pci_dev ; + +struct prom21_xhci_pdata { +struct pci_dev *pdev; +void __iomem *regs; +resource_size_t rsrc_len; +}; + +#endif
Signature · 1 line
2.53.0
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 39 lines · Jihong Min
AMD Promontory 21 (PROM21) xHCI controllers use generic xHCI operation, but the PCI function also exposes optional controller-specific sensor functionality. Add a small PROM21 PCI glue driver for AMD 1022:43fc and 1022:43fd controllers.
The driver delegates USB host operation to the common xhci-pci core, collects the parent-provided MMIO resource data, and creates a "hwmon" auxiliary device for optional child drivers. Failure to create the auxiliary device is logged but does not fail the xHCI probe, since the auxiliary device is only needed for sensor support.
Make the PROM21 PCI glue a hidden
Kconfigtristate that followsUSB_XHCI_PCI. This keeps the glue built in with a built-in xhci-pci core and builds it as a module with a modular xhci-pci core. A built-in xhci-pci core must not hand PROM21 controllers to a PROM21 glue driver that is only available as a module, otherwise USB behind those controllers can be unavailable during initramfs and PROM21 temperature sensor support may not appear until the controller is rebound after the module loads.Assisted-by Codex:gpt-5.5Signed-off-by Jihong Min <[email protected]>Reviewed-by Mario Limonciello (AMD) <[email protected]>Tested-by Yaroslav Isakov <[email protected]>--- drivers/usb/host/Kconfig | 7 + drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-pci-prom21.c | 136 ++++++++++++++++++ drivers/usb/host/xhci-pci.c | 11 ++ drivers/usb/host/xhci-pci.h | 3 + include/linux/platform_data/usb-xhci-prom21.h | 22 +++ 6 files changed, 180 insertions(+) create mode 100644 drivers/usb/host/xhci-pci-prom21.c create mode 100644 include/linux/platform_data/usb-xhci-prom21.hdrivers/usb/host/Kconfig +0
-0
drivers/usb/host/Kconfig config USB_XHCI_PCI · line 51
Quoted 10 lines
drivers/usb/host/Kconfig +7
-0@@ -42,6 +42,13 @@ config USB_XHCI_PCI depends on USB_PCI default y +config USB_XHCI_PCI_PROM21 + tristate + depends on X86 + depends on USB_XHCI_PCI + default USB_XHCI_PCI + select AUXILIARY_BUS +
Instead of the X86 heuristic, would it be possible to build glue code if and only if SENSORS_PROM21_XHCI is enabled?
This seems to work:
config SENSORS_PROM21_XHCI
tristate "AMD Promontory 21 xHCI temperature sensor"
- depends on USB_XHCI_PCI_PROM21
+ depends on USB_XHCI_PCI
config USB_XHCI_PCI_PROM21
tristate
- depends on X86
depends on USB_XHCI_PCI
- default USB_XHCI_PCI
+ default USB_XHCI_PCI if SENSORS_PROM21_XHCI != 'n'
select AUXILIARY_BUS
I don't know if it's the best way, perhaps it would be preferable for the hwmon driver to select the glue, but then I'm not sure how to force glue to become 'y' when xhci-pci is 'y'.
Quoted 56 lines
drivers/usb/host/Kconfig +0
-0config USB_XHCI_PCI_RENESAS tristate "Support for additional Renesas xHCI controller with firmware" depends on USB_XHCI_PCIdrivers/usb/host/Makefile +1
-0@@ -71,6 +71,7 @@ obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o +obj-$(CONFIG_USB_XHCI_PCI_PROM21) += xhci-pci-prom21.o obj-$(CONFIG_USB_XHCI_PCI_RENESAS) += xhci-pci-renesas.o obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o obj-$(CONFIG_USB_XHCI_HISTB) += xhci-histb.odrivers/usb/host/xhci-pci-prom21.c new file +35
-0@@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* AMD Promontory 21 xHCI host controller PCI Bus Glue. +* +* This does not add any PROM21-specific USB or xHCI operation. It exists only +* to publish an auxiliary device for integrated temperature sensor support. +* +* Copyright (C) 2026 Jihong Min <[email protected]> +*/ + +#include <linux/auxiliary_bus.h> +#include <linux/device/devres.h> +#include <linux/errno.h> +#include <linux/idr.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/platform_data/usb-xhci-prom21.h> +#include <linux/usb.h> +#include <linux/usb/hcd.h> + +#include "xhci-pci.h" + +struct prom21_xhci_auxdev { +struct auxiliary_device *auxdev; +struct prom21_xhci_pdata pdata; +int id; +}; + +static DEFINE_IDA (prom21_xhci_auxdev_ida); + +static void prom21_xhci_auxdev_release (struct device *dev,void *res) +{ +struct prom21_xhci_auxdev *prom21_auxdev = res; + +auxiliary_device_destroy (prom21_auxdev->auxdev);
drivers/usb/host/xhci-pci-prom21.c line 45
Quoted 10 lines
drivers/usb/host/xhci-pci-prom21.c new file +10
-0+ida_free (&prom21_xhci_auxdev_ida, prom21_auxdev->id); +} + +static int prom21_xhci_create_auxdev (struct pci_dev *pdev) +{ +struct prom21_xhci_auxdev *prom21_auxdev; +struct usb_hcd *hcd =pci_get_drvdata (pdev); + +if (!hcd) +return -ENODEV ;
Shouldn't be necessary after successful xhci_pci_common_probe().
Quoted 16 lines
drivers/usb/host/xhci-pci-prom21.c new file +16
-0+ + prom21_auxdev =devres_alloc (prom21_xhci_auxdev_release, +sizeof (*prom21_auxdev),GFP_KERNEL ); +if (!prom21_auxdev) +return -ENOMEM ; + + prom21_auxdev->pdata.pdev = pdev; + prom21_auxdev->pdata.regs = hcd->regs; + prom21_auxdev->pdata.rsrc_len = hcd->rsrc_len; + + prom21_auxdev->id =ida_alloc (&prom21_xhci_auxdev_ida,GFP_KERNEL ); +if (prom21_auxdev->id <0 ) { +int ret = prom21_auxdev->id; + +devres_free (prom21_auxdev); +return ret;
drivers/usb/host/xhci-pci-prom21.c line 71
Quoted 10 lines
drivers/usb/host/xhci-pci-prom21.c new file +10
-0+ } + + prom21_auxdev->auxdev =auxiliary_device_create (&pdev->dev, +KBUILD_MODNAME ,"hwmon" , + &prom21_auxdev->pdata, + prom21_auxdev->id); +if (!prom21_auxdev->auxdev) { +ida_free (&prom21_xhci_auxdev_ida, prom21_auxdev->id); +devres_free (prom21_auxdev); +return -ENOMEM ;
The usual "goto error" pattern could be used instead of increasingly long sequences of xxx_free() calls.
drivers/usb/host/xhci-pci-prom21.c line 82
Quoted 11 lines
drivers/usb/host/xhci-pci-prom21.c new file +11
-0+ } + +devres_add (&pdev->dev, prom21_auxdev); +return 0 ; +} + +static void prom21_xhci_destroy_auxdev (struct pci_dev *pdev) +{ +devres_release (&pdev->dev, prom21_xhci_auxdev_release,NULL ,NULL ); +} +
It seems that these three functions above are everything that you truly want to add; the rest is boilerplate required by this two-module scheme to work, plus ID tables which must be duplicated and kept in sync.
I wonder if a separate module is really justified, as opposed to simply linking this file into xhci_pci.ko when directed by Kconfig.
The downside would be slightly higher memory usage on systems where the hwmon driver is enabled but not needed. OTOH, same systems would likely see reduced disk waste.
Quoted 127 lines
drivers/usb/host/xhci-pci-prom21.c new file +54
-0+static int prom21_xhci_probe (struct pci_dev *dev, +const struct pci_device_id *id) +{ +int retval; + + retval =xhci_pci_common_probe (dev, id); +if (retval) +return retval; + + retval =prom21_xhci_create_auxdev (dev); +if (retval) { +/* +* The auxiliary device only provides optional temperature sensor +* support. Keep the xHCI controller usable if it fails. +*/ +dev_err (&dev->dev, +"failed to create PROM21 hwmon auxiliary device: %d\n" , + retval); + } + +return 0 ; +} + +static void prom21_xhci_remove (struct pci_dev *dev) +{ +prom21_xhci_destroy_auxdev (dev); +xhci_pci_remove (dev); +} + +static const struct pci_device_id pci_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD ) }, + {/* end: all zeroes */ } +}; +MODULE_DEVICE_TABLE (pci, pci_ids); + +static struct pci_driver prom21_xhci_driver = { + .name ="xhci-pci-prom21" , + .id_table = pci_ids, + + .probe = prom21_xhci_probe, + .remove = prom21_xhci_remove, + + .shutdown = usb_hcd_pci_shutdown, + .driver = { + .pm =pm_ptr (&usb_hcd_pci_pm_ops), + }, +}; +module_pci_driver (prom21_xhci_driver); + +MODULE_AUTHOR ("Jihong Min <[email protected]>" ); +MODULE_DESCRIPTION ("AMD Promontory 21 xHCI PCI Host Controller Driver" ); +MODULE_IMPORT_NS ("xhci" ); +MODULE_LICENSE ("GPL" );drivers/usb/host/xhci-pci.c +11
-0@@ -696,12 +696,23 @@ static const struct pci_device_id pci_ids_renesas[] = { {/* end: all zeroes */ } }; +/* handled by xhci-pci-prom21 if enabled */ +static const struct pci_device_id pci_ids_prom21[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD ) }, + {/* end: all zeroes */ } +}; +static int xhci_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) {if (IS_ENABLED (CONFIG_USB_XHCI_PCI_RENESAS ) &&pci_match_id (pci_ids_renesas, dev))return -ENODEV ; +if (IS_ENABLED (CONFIG_USB_XHCI_PCI_PROM21 ) && +pci_match_id (pci_ids_prom21, dev)) +return -ENODEV ; +return xhci_pci_common_probe (dev, id); }drivers/usb/host/xhci-pci.h +3
-0@@ -4,6 +4,9 @@#ifndef XHCI_PCI_H #define XHCI_PCI_H +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC 0x43fc +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD 0x43fd +int xhci_pci_common_probe (struct pci_dev *dev,const struct pci_device_id *id);void xhci_pci_remove (struct pci_dev *dev);include/linux/platform_data/usb-xhci-prom21.h new file +22
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* AMD Promontory 21 xHCI auxiliary device platform data. +* +* Copyright (C) 2026 Jihong Min <[email protected]> +*/ + +#ifndef _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H +#define _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H + +#include <linux/compiler_types.h> +#include <linux/types.h> + +struct pci_dev ; + +struct prom21_xhci_pdata { +struct pci_dev *pdev; +void __iomem *regs; +resource_size_t rsrc_len; +}; + +#endif Signature · 1 line
2.53.0
Guenter Roeck
maintainerRe: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 69 lines · Michal Pecio
Quoted 39 lines · Jihong Min
AMD Promontory 21 (PROM21) xHCI controllers use generic xHCI operation, but the PCI function also exposes optional controller-specific sensor functionality. Add a small PROM21 PCI glue driver for AMD 1022:43fc and 1022:43fd controllers.
The driver delegates USB host operation to the common xhci-pci core, collects the parent-provided MMIO resource data, and creates a "hwmon" auxiliary device for optional child drivers. Failure to create the auxiliary device is logged but does not fail the xHCI probe, since the auxiliary device is only needed for sensor support.
Make the PROM21 PCI glue a hidden
Kconfigtristate that followsUSB_XHCI_PCI. This keeps the glue built in with a built-in xhci-pci core and builds it as a module with a modular xhci-pci core. A built-in xhci-pci core must not hand PROM21 controllers to a PROM21 glue driver that is only available as a module, otherwise USB behind those controllers can be unavailable during initramfs and PROM21 temperature sensor support may not appear until the controller is rebound after the module loads.Assisted-by Codex:gpt-5.5Signed-off-by Jihong Min <[email protected]>Reviewed-by Mario Limonciello (AMD) <[email protected]>Tested-by Yaroslav Isakov <[email protected]>--- drivers/usb/host/Kconfig | 7 + drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-pci-prom21.c | 136 ++++++++++++++++++ drivers/usb/host/xhci-pci.c | 11 ++ drivers/usb/host/xhci-pci.h | 3 + include/linux/platform_data/usb-xhci-prom21.h | 22 +++ 6 files changed, 180 insertions(+)create mode 100644
drivers/usb/host/xhci-pci-prom21.ccreate mode 100644include/linux/platform_data/usb-xhci-prom21.hdrivers/usb/host/Kconfig +0
-0drivers/usb/host/Kconfig config USB_XHCI_PCI · line 51
Quoted 10 lines
drivers/usb/host/Kconfig +7
-0@@ -42,6 +42,13 @@ config USB_XHCI_PCI depends on USB_PCI default y +config USB_XHCI_PCI_PROM21 + tristate + depends on X86 + depends on USB_XHCI_PCI + default USB_XHCI_PCI + select AUXILIARY_BUS +Instead of the X86 heuristic, would it be possible to build glue code if and only if
SENSORS_PROM21_XHCIis enabled?This seems to work:
config
SENSORS_PROM21_XHCI
tristate "AMD Promontory 21 xHCI temperature sensor"(quoted diff) +2
-3- depends on USB_XHCI_PCI_PROM21 + depends on USB_XHCI_PCI config USB_XHCI_PCI_PROM21 tristate - depends on X86 depends on USB_XHCI_PCI - default USB_XHCI_PCI + default USB_XHCI_PCI if SENSORS_PROM21_XHCI != 'n' select AUXILIARY_BUS
Quoted 4 lines
I don't know if it's the best way, perhaps it would be preferable for the hwmon driver to select the glue, but then I'm not sure how to force glue to become 'y' when xhci-pci is 'y'.
Unless I am missing something, that would disable the entire controller if the hwmon device is not enabled. That seems a bit draconian to me.
Guenter
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 19 lines · Guenter Roeck
Quoted 18 lines · Michal Pecio
Instead of the X86 heuristic, would it be possible to build glue code if and only if
SENSORS_PROM21_XHCIis enabled?This seems to work:
config
SENSORS_PROM21_XHCI
tristate "AMD Promontory 21 xHCI temperature sensor"(quoted diff) +2
-3- depends on USB_XHCI_PCI_PROM21 + depends on USB_XHCI_PCI config USB_XHCI_PCI_PROM21 tristate - depends on X86 depends on USB_XHCI_PCI - default USB_XHCI_PCI + default USB_XHCI_PCI if SENSORS_PROM21_XHCI != 'n' select AUXILIARY_BUS
Quoted 7 lines
Quoted 4 lines
I don't know if it's the best way, perhaps it would be preferable for the hwmon driver to select the glue, but then I'm not sure how to force glue to become 'y' when xhci-pci is 'y'.
Unless I am missing something, that would disable the entire controller if the hwmon device is not enabled. That seems a bit draconian to me.
I haven't tested (I don't have this chipset), but it should work like the similar xhci-pci-renesas module, which I'm familiar with.
When the special unicorn module is disabled by Kconfig, xhci-pci no longer rejects its devices and works with them normally, like it always did before the unicorn module even existed.
It should be the same with xhci-pci-prom21. You don't need to enable this module to use USB, only for the special functions. So if hwmon is disabled then you can disable it too.
I always found this dual-driver solution (for Renesas) rather ugly and confusing, but so far it's the least bad option tried. Hmm, maybe the next iteration should be an aux bus interface for FW loaders...
Regards,
Michal
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
In reply to Michal PecioQuoted 18 lines · Michal Pecio
Instead of the X86 heuristic, would it be possible to build glue code if and only if
SENSORS_PROM21_XHCIis enabled?This seems to work:
config
SENSORS_PROM21_XHCI
tristate "AMD Promontory 21 xHCI temperature sensor"(quoted diff) +2
-3- depends on USB_XHCI_PCI_PROM21 + depends on USB_XHCI_PCI config USB_XHCI_PCI_PROM21 tristate - depends on X86 depends on USB_XHCI_PCI - default USB_XHCI_PCI + default USB_XHCI_PCI if SENSORS_PROM21_XHCI != 'n' select AUXILIARY_BUS
Quoted 3 lines
I don't know if it's the best way, perhaps it would be preferable for the hwmon driver to select the glue, but then I'm not sure how to force glue to become 'y' when xhci-pci is 'y'.
I think I should keep the current hidden glue option for now.
The PROM21 PCI glue is part of the PCI binding path for the xHCI controller when enabled, while SENSORS_PROM21_XHCI is only the optional user-visible hwmon driver. Tying the glue to the hwmon option would make the sensor option affect which driver binds the USB controller. As Guenter pointed out, that would be too strong; the USB controller should not depend on whether the optional hwmon driver is enabled.
So I would prefer to keep USB_XHCI_PCI_PROM21 as hidden plumbing that follows USB_XHCI_PCI, and keep SENSORS_PROM21_XHCI as the user-visible sensor option.
Quoted 9 lines
drivers/usb/host/xhci-pci-prom21.c new file +7
-0+static int prom21_xhci_create_auxdev (struct pci_dev *pdev) +{ +struct prom21_xhci_auxdev *prom21_auxdev; +struct usb_hcd *hcd =pci_get_drvdata (pdev); + +if (!hcd) +return -ENODEV ;Shouldn't be necessary after successful
xhci_pci_common_probe().
Agreed. I removed the unnecessary NULL check fromprom21_xhci_create_auxdev() locally for v7.
Quoted 17 lines
drivers/usb/host/xhci-pci-prom21.c new file +16
-0+ prom21_auxdev->id =ida_alloc (&prom21_xhci_auxdev_ida,GFP_KERNEL ); +if (prom21_auxdev->id <0 ) { +int ret = prom21_auxdev->id; + +devres_free (prom21_auxdev); +return ret; + } + + prom21_auxdev->auxdev =auxiliary_device_create (&pdev->dev, +KBUILD_MODNAME ,"hwmon" , + &prom21_auxdev->pdata, + prom21_auxdev->id); +if (!prom21_auxdev->auxdev) { +ida_free (&prom21_xhci_auxdev_ida, prom21_auxdev->id); +devres_free (prom21_auxdev); +return -ENOMEM ;
Quoted 2 lines
The usual "goto error" pattern could be used instead of increasingly long sequences of
xxx_free()calls.
Agreed. I changed prom21_xhci_create_auxdev() to use a goto-based cleanup path locally for v7.
Quoted 10 lines
It seems that these three functions above are everything that you truly want to add; the rest is boilerplate required by this two-module scheme to work, plus ID tables which must be duplicated and kept in sync.
I wonder if a separate module is really justified, as opposed to simply linking this file into xhci_pci.ko when directed by
Kconfig.The downside would be slightly higher memory usage on systems where the hwmon driver is enabled but not needed. OTOH, same systems would likely see reduced disk waste.
I understand the concern. Linking the PROM21 auxiliary-device publisher into xhci_pci.ko would reduce some boilerplate and avoid the extra PCI driver, while still keeping the hwmon driver itself separate.
The reason I kept the current split is that the earlier review direction was to keep the hwmon functionality out of xhci-pci and bind a drivers/hwmon driver through an auxiliary device. The current PROM21 PCI glue keeps the PROM21-specific auxiliary-device lifetime handling outside the common xhci-pci driver and leaves xhci-pci.c with only the PCI ID handoff, similar in spirit to the Renesas handoff path.
That said, I agree this is a tradeoff. If Mathias or the USB maintainers prefer the PROM21 auxiliary-device publisher to be linked into xhci_pci.ko instead of being a separate PCI glue driver, I can rework it in that direction while still keeping the hwmon driver under drivers/hwmon and bound through the auxiliary bus.
Sincerely,
Jihong Min
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 23 lines · Jihong Min
Quoted 18 lines · Michal Pecio
Instead of the X86 heuristic, would it be possible to build glue code if and only if
SENSORS_PROM21_XHCIis enabled?This seems to work:
config
SENSORS_PROM21_XHCI
tristate "AMD Promontory 21 xHCI temperature sensor"(quoted diff) +2
-3- depends on USB_XHCI_PCI_PROM21 + depends on USB_XHCI_PCI config USB_XHCI_PCI_PROM21 tristate - depends on X86 depends on USB_XHCI_PCI - default USB_XHCI_PCI + default USB_XHCI_PCI if SENSORS_PROM21_XHCI != 'n' select AUXILIARY_BUSQuoted 3 lines
I don't know if it's the best way, perhaps it would be preferable for the hwmon driver to select the glue, but then I'm not sure how to force glue to become 'y' when xhci-pci is 'y'.
Quoted 7 lines
I think I should keep the current hidden glue option for now.
The PROM21 PCI glue is part of the PCI binding path for the xHCI controller when enabled, while
SENSORS_PROM21_XHCIis only the optional user-visible hwmon driver. Tying the glue to the hwmon option would make the sensor option affect which driver binds the USB controller.
That's true.
Making this possible is the whole purpose of "if IS_ENABLED" here:
drivers/usb/host/xhci-pci.c static const struct pci_device_id pci_ids_renesas[] = { · line 717
Quoted 12 lines
static int
xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id){drivers/usb/host/xhci-pci.c +4
-0if (IS_ENABLED (CONFIG_USB_XHCI_PCI_RENESAS ) &&pci_match_id (pci_ids_renesas, dev))return -ENODEV ; +if (IS_ENABLED (CONFIG_USB_XHCI_PCI_PROM21 ) && +pci_match_id (pci_ids_prom21, dev)) +return -ENODEV ; +return xhci_pci_common_probe (dev, id); }
Currently, you have a weird situation where xhci-pci-prom21 always binds on x86 and xhci-pci on other platforms (with the unofficial PCIe card you mentioned), plus the sensor cannot work on other platforms.
Quoted 2 lines
As Guenter pointed out, that would be too strong; the USB controller should not depend on whether the optional hwmon driver is enabled.
One could further argue that neither should it care whether some hwmon driver exists at all, or which kernel releases it exists in :)
Regards,
Michal
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 2 lines · Michal Pecio
That's true.
Making this possible is the whole purpose of "ifIS_ENABLED" here:
I re-checked the Kconfig cases, and I think you are right here.
The two cases I was trying to avoid are:
1. the sensor driver is built as a module, or loads only after the initramfs stage, but the PROM21 controller has already been bound by the generic xhci-pci driver, so no auxiliary device exists for the sensor driver to bind to;
2. the built-in generic xhci-pci driver rejects the PROM21 controller, but xhci-pci-prom21 is only available as a module and is not present during initramfs, leaving USB behind that controller unavailable at that
stage.
Looking at your proposed Kconfig shape again, it handles both cases.
If SENSORS_PROM21_XHCI=n, then no sensor support is requested and USB_XHCI_PCI_PROM21 can stay disabled. In that case generic xhci-pci binds the controller, which is fine because there is no sensor driver that needs an
auxiliary device.
If SENSORS_PROM21_XHCI=m or y and USB_XHCI_PCI=y, then USB_XHCI_PCI_PROM21 follows USB_XHCI_PCI and becomes y. That means the PROM21
glue is available during early boot, creates the auxiliary device, and the hwmon driver can still bind later if it is built as a module.
If USB_XHCI_PCI=m, then xhci-pci itself is modular. In that case needing the PROM21 glue module in initramfs is not a PROM21-specific built-in/module split
problem; it is the normal requirement for a modular xHCI PCI setup.
So I agree that tying the hidden glue option to whether SENSORS_PROM21_XHCI is enabled is reasonable.
Quoted 3 lines
Currently, you have a weird situation where xhci-pci-prom21 always binds on x86 and xhci-pci on other platforms (with the unofficial PCIe card you mentioned), plus the sensor cannot work on other platforms.
Agreed. I also agree that the X86 dependency is only a heuristic and is not a
good restriction for a PCI ID based driver. PROM21 is mainly used on AMD x86 desktop platforms today, but the unofficial PCIe card example shows that the device can exist outside the normal AMD x86 chipset topology.
I do not know whether other PROM21-related functionality is supported on non-x86 platforms, but this driver does not need to prevent the xHCI temperature sensor path from being built there.
Quoted 2 lines
One could further argue that neither should it care whether some hwmon driver exists at all, or which kernel releases it exists in :)
Right. I think the cleanest result is:
- generic xhci-pci handles PROM21 when no sensor support is requested;
- xhci-pci-prom21 handles PROM21 only when the sensor path is enabled;
- the hwmon driver remains the user-visible option.
Unless Guenter or the USB maintainers object, I plan to change the next revision in that direction and test the Kconfig combinations locally.
Sincerely,
Jihong Min
Guenter Roeck
maintainerRe: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Quoted 59 lines · Jihong Min
Quoted 2 lines · Michal Pecio
That's true.
Making this possible is the whole purpose of "ifIS_ENABLED" here:I re-checked the
Kconfigcases, and I think you are right here.The two cases I was trying to avoid are:
1. the sensor driver is built as a module, or loads only after the initramfs stage, but the PROM21 controller has already been bound by the generic xhci-pci driver, so no auxiliary device exists for the sensor driver to bind to;
2. the built-in generic xhci-pci driver rejects the PROM21 controller, but xhci-pci-prom21 is only available as a module and is not present during initramfs, leaving USB behind that controller unavailable at that
stage.Looking at your proposed
Kconfigshape again, it handles both cases.If SENSORS_PROM21_XHCI=n, then no sensor support is requested and
USB_XHCI_PCI_PROM21can stay disabled. In that case generic xhci-pci binds the controller, which is fine because there is no sensor driver that needs an
auxiliary device.If SENSORS_PROM21_XHCI=m or y and USB_XHCI_PCI=y, then
USB_XHCI_PCI_PROM21followsUSB_XHCI_PCIand becomes y. That means the PROM21
glue is available during early boot, creates the auxiliary device, and the hwmon driver can still bind later if it is built as a module.If USB_XHCI_PCI=m, then xhci-pci itself is modular. In that case needing the PROM21 glue module in initramfs is not a PROM21-specific built-in/module split
problem; it is the normal requirement for a modular xHCI PCI setup.So I agree that tying the hidden glue option to whether
SENSORS_PROM21_XHCIis enabled is reasonable.Quoted 3 lines
Currently, you have a weird situation where xhci-pci-prom21 always binds on x86 and xhci-pci on other platforms (with the unofficial PCIe card you mentioned), plus the sensor cannot work on other platforms.
Agreed. I also agree that the X86 dependency is only a heuristic and is not a
good restriction for a PCI ID based driver. PROM21 is mainly used on AMD x86 desktop platforms today, but the unofficial PCIe card example shows that the device can exist outside the normal AMD x86 chipset topology.I do not know whether other PROM21-related functionality is supported on non-x86 platforms, but this driver does not need to prevent the xHCI temperature sensor path from being built there.
Quoted 2 lines
One could further argue that neither should it care whether some hwmon driver exists at all, or which kernel releases it exists in :)
Quoted 9 lines
Right. I think the cleanest result is:
- generic xhci-pci handles PROM21 when no sensor support is requested;
- xhci-pci-prom21 handles PROM21 only when the sensor path is enabled;
- the hwmon driver remains the user-visible option.Unless Guenter or the USB maintainers object, I plan to change the next revision in that direction and test the
Kconfigcombinations locally.
Ok with me if you are sure that it works. When you send a new revision, you might want to also change the error path as suggested.
Thanks,
Guenter
Re: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
In reply to Jihong MinQuoted 10 lines · Jihong Min
It seems that these three functions above are everything that you truly want to add; the rest is boilerplate required by this two-module scheme to work, plus ID tables which must be duplicated and kept in sync.
I wonder if a separate module is really justified, as opposed to simply linking this file into xhci_pci.ko when directed by
Kconfig.The downside would be slightly higher memory usage on systems where the hwmon driver is enabled but not needed. OTOH, same systems would likely see reduced disk waste.
One clarification about this part:
In my previous reply I said that I could rework this either way depending on the USB maintainer preference. After thinking about it again, I think the current direction is the better one.
Mathias's earlier review pushed this series away from adding PROM21-specific hwmon support directly into the common xhci-pci path. I agree with that direction. The common xhci-pci driver should not grow PROM21-specific sensor logic.
The current split keeps the PROM21-specific auxiliary-device lifetime handling
in xhci-pci-prom21.c, keeps the hwmon implementation in drivers/hwmon, and leaves xhci-pci.c with only the PCI ID handoff. That is also the closest match
to the existing Renesas handoff approach.
So, while I previously phrased this as something I would leave entirely to the
USB maintainers, my current preference is to keep the separate PROM21 PCI glue
driver unless Mathias or another USB maintainer specifically asks for a different structure.
Sincerely,
Jihong Min
PATCH v6 2/2 hwmon: add AMD Promontory 21 xHCI temperature sensor support
In reply to Jihong MinAdd an auxiliary-bus hwmon driver for the temperature sensor exposed by AMD Promontory 21 (PROM21) xHCI PCI functions. The driver binds to the "hwmon" auxiliary device published by the PROM21 xHCI PCI glue and exposes the sensor as temp1_input under the prom21_xhci hwmon device.
The sensor is accessed through a PROM21 vendor index/data register pair in the xHCI PCI MMIO BAR. The driver consumes parent-provided MMIO data from the PROM21 PCI glue instead of inspecting the parent PCI driver's drvdata. The read path restores the previous vendor index value after sampling and does not runtime-resume the parent PCI device; reads from a suspended parent return -ENODATA.
Document the supported device, register access, runtime PM behavior, and sysfs lookup method. The documentation also records the observation method used to identify the register pair and derive the conversion formula.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/prom21-xhci.rst | 101 ++++++++++++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/prom21-xhci.c | 239 ++++++++++++++++++++++++++++ 5 files changed, 352 insertions(+) create mode 100644 Documentation/hwmon/prom21-xhci.rst create mode 100644 drivers/hwmon/prom21-xhci.c
Documentation/hwmon/index.rst +1 -0
@@ -216,6 +216,7 @@ Hardware Monitoring Kernel Drivers pmbus powerz powr1220 + prom21-xhci pt5161l pxe1610 pwm-fan
Documentation/hwmon/prom21-xhci.rst new file +101 -0
101 lines not on this page · raw message
drivers/hwmon/Kconfig +10 -0
@@ -951,6 +951,16 @@ config SENSORS_POWR1220 This driver can also be built as a module. If so, the module will be called powr1220. +config SENSORS_PROM21_XHCI + tristate "AMD Promontory 21 xHCI temperature sensor" + depends on USB_XHCI_PCI_PROM21 + help + If you say yes here you get support for the AMD Promontory 21 + (PROM21) xHCI temperature sensor. + + This driver can also be built as a module. If so, the module + will be called prom21-xhci. + config SENSORS_LAN966X tristate "Microchip LAN966x Hardware Monitoring" depends on SOC_LAN966 || COMPILE_TEST
drivers/hwmon/Makefile +1 -0
@@ -196,6 +196,7 @@ obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_POWERZ) += powerz.o obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o +obj-$(CONFIG_SENSORS_PROM21_XHCI) += prom21-xhci.o obj-$(CONFIG_SENSORS_PT5161L) += pt5161l.o obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o
drivers/hwmon/prom21-xhci.c new file +239 -0
239 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v6 2/2] hwmon: add AMD Promontory 21 xHCI temperature sensor support
Quoted 17 lines · Jihong Min
Add an auxiliary-bus hwmon driver for the temperature sensor exposed by AMD Promontory 21 (PROM21) xHCI PCI functions. The driver binds to the "hwmon" auxiliary device published by the PROM21 xHCI PCI glue and exposes the sensor as
temp1_inputunder theprom21_xhcihwmon device.The sensor is accessed through a PROM21 vendor index/data register pair in the xHCI PCI MMIO BAR. The driver consumes parent-provided MMIO data from the PROM21 PCI glue instead of inspecting the parent PCI driver's drvdata. The read path restores the previous vendor index value after sampling and does not runtime-resume the parent PCI device; reads from a suspended parent return
-ENODATA.Document the supported device, register access, runtime PM behavior, and sysfs lookup method. The documentation also records the observation method used to identify the register pair and derive the conversion formula.
Quoted 4 lines
Assisted-by Codex:gpt-5.5Signed-off-by Jihong Min <[email protected]>Reviewed-by Mario Limonciello (AMD) <[email protected]>Tested-by Yaroslav Isakov <[email protected]>
For my reference:
I'll need an Acked-by: from a maintainer on the first patch to apply both patches, or this patch can be applied through some other tree. I am fine with both.
Thanks,
Guenter