Introduce Cray ClusterStor E1000 NVMe slot LED driver
PATCH v7 1/1 Introduce Cray ClusterStor E1000 NVMe slot LED driver
Add driver to control the NVMe slot LEDs on the Cray ClusterStor E1000. The driver provides hotplug attention status callbacks for the 24 NVMe slots on the E1000. This allows users to access the E1000's locate and fault LEDs via the normal /sys/bus/pci/slots/<slot>/attention sysfs entries. This driver uses IPMI to communicate with the E1000 controller to toggle the LEDs.
---
Changes in v7:
- Update sysfs-bus-pci text from feedback.
- Add DMI dependency to Kconfig.
- Refactor pciehp_core.c to remove CONFIG_HOTPLUG_PCI_PCIE_CRAY_E1000 code blocks.
- Move errno.h #include into correct alphabetical order.
- Add comment describing the reasoning for the debugfs counters.
- Move craye1k_init() call from pcie_hp_init() to init_slot().
- Make craye1k mutex global rather than in craye1k->lock. This enables handling of craye1k_[get|set]_attention_status() calls before the craye1k driver is initialized.
- Do driver cleanup on craye1k_smi_gone().
Changes in v6:
- Change some dev_info_ratelimited() calls to dev_info().
- Don't call craye1k_init() if pcie_port_service_register() fails.
- Fix stray indent in #define CRAYE1K_POST_CMD_WAIT_MS
Changes in v5:
- Removed unnecessary ipmi_smi.h #include.
- Added WARN_ON() to craye1k_do_message() to sanity check that craye1k->lock is held.
- Added additional comments for when craye1k->lock should be held.
Changes in v4:
- Fix typo in Kconfig: "is it" -> "it is"
- Rename some #defines to CRAYE1K_SUBCMD_*
- Use IS_ERR() check in craye1k_debugfs_init()
- Return -EIO instead of -EINVAL when LED value check fails
Changes in v3:
- Add 'attention' values in Documentation/ABI/testing/sysfs-bus-pci.
- Remove ACPI_PCI_SLOT dependency.
- Cleanup craye1k_do_message() error checking.
- Skip unneeded memcpy() on failure in __craye1k_do_command().
- Merge craye1k_do_command_and_netfn() code into craye1k_do_command().
- Make craye1k_is_primary() return boolean.
- Return negative error code on failure in craye1k_set_primary().
Changes in v2:
- Integrated E1000 code into the pciehp driver as an built-in extention rather than as a standalone module.
- Moved debug tunables and counters to debugfs.
- Removed forward declarations.
- Kept the /sys/bus/pci/slots/<slot>/attention interface rather than using NPEM/_DSM or led_classdev as suggested. The "attention" interface is more beneficial for our site, since it allows us to control the NVMe slot LEDs agnostically across different enclosure vendors and kernel versions using the same scripts. It is also nice to use the same /sys/bus/pci/slots/<slot>/ sysfs directory for both slot LED toggling ("attention") and slot power control ("power").
--- Documentation/ABI/testing/sysfs-bus-pci | 21 + MAINTAINERS | 5 + drivers/pci/hotplug/Kconfig | 10 + drivers/pci/hotplug/Makefile | 3 + drivers/pci/hotplug/pciehp.h | 20 + drivers/pci/hotplug/pciehp_core.c | 16 + drivers/pci/hotplug/pciehp_craye1k.c | 690 ++++++++++++++++++++++++ 7 files changed, 765 insertions(+) create mode 100644 drivers/pci/hotplug/pciehp_craye1k.c
Documentation/ABI/testing/sysfs-bus-pci +21 -0
@@ -231,6 +231,27 @@ Description: - scXX contains the device subclass; - iXX contains the device class programming interface. +What: /sys/bus/pci/slots/.../attention +Date: February 2025 +Contact: [email protected] +Description: + The attention attribute is used to read or write the attention + status for an enclosure slot. This is often used to set the + slot LED value on a NVMe storage enclosure. + + Common values: + 0 = OFF + 1 = ON + 2 = blink + + Using the Cray ClusterStor E1000 extensions: + 0 = fault LED OFF, locate LED OFF + 1 = fault LED ON, locate LED OFF + 2 = fault LED OFF, locate LED ON + 3 = fault LED ON, locate LED ON + + Other values are no-op, OFF, or ON depending on the driver. + What: /sys/bus/pci/slots/.../module Date: June 2009 Contact: [email protected]
MAINTAINERS +5 -0
@@ -6543,6 +6543,11 @@ S: Maintained F: Documentation/filesystems/cramfs.rst F: fs/cramfs/ +CRAY CLUSTERSTOR E1000 NVME SLOT LED DRIVER EXTENSIONS +M: Tony Hutter <[email protected]> +S: Maintained +F: drivers/pci/hotplug/pciehp_craye1k.c + CRC LIBRARY M: Eric Biggers <[email protected]> R: Ard Biesheuvel <[email protected]>
drivers/pci/hotplug/Kconfig +10 -0
@@ -183,4 +183,14 @@ config HOTPLUG_PCI_S390 When in doubt, say Y. +config HOTPLUG_PCI_PCIE_CRAY_E1000 + bool "PCIe Hotplug extensions for Cray ClusterStor E1000" + depends on DMI && HOTPLUG_PCI_PCIE && IPMI_HANDLER=y + help + Say Y here if you have a Cray ClusterStor E1000 and want to control + your NVMe slot LEDs. Without this driver it is not possible + to control the fault and locate LEDs on the E1000's 24 NVMe slots. + + When in doubt, say N. + endif # HOTPLUG_PCI
drivers/pci/hotplug/Makefile +3 -0
@@ -66,6 +66,9 @@ pciehp-objs := pciehp_core.o \ pciehp_ctrl.o \ pciehp_pci.o \ pciehp_hpc.o +ifdef CONFIG_HOTPLUG_PCI_PCIE_CRAY_E1000 +pciehp-objs += pciehp_craye1k.o +endif shpchp-objs := shpchp_core.o \ shpchp_ctrl.o \
drivers/pci/hotplug/pciehp.h +20 -0
@@ -199,6 +199,17 @@ int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status);int pciehp_slot_reset (struct pcie_device *dev); +#ifdef CONFIG_HOTPLUG_PCI_PCIE_CRAY_E1000 +int craye1k_init (void ); +bool is_craye1k_board (void ); +int craye1k_get_attention_status (struct hotplug_slot *hotplug_slot,u8 *status); +int craye1k_set_attention_status (struct hotplug_slot *hotplug_slot,u8 status); +#else +#define craye1k_init () (0) +#define craye1k_get_attention_status NULL +#define craye1k_set_attention_status NULL +#endif +static inline const char *slot_name (struct controller *ctrl) {return hotplug_slot_name (&ctrl->hotplug_slot);
@@ -209,4 +220,13 @@ static inline struct controller *to_ctrl(struct hotplug_slot *hotplug_slot) return container_of(hotplug_slot, struct controller, hotplug_slot); } +static inline bool is_craye1k_slot (struct controller *ctrl) +{ +#ifdef CONFIG_HOTPLUG_PCI_PCIE_CRAY_E1000 +return (PSN (ctrl) >=1 &&PSN (ctrl) <=24 &&is_craye1k_board ()); +#else +return false; +#endif +} +#endif /* _PCIEHP_H */
drivers/pci/hotplug/pciehp_core.c +16 -0
@@ -72,6 +72,22 @@ static int init_slot(struct controller *ctrl) }else if (ctrl->pcie->port->hotplug_user_indicators) { ops->get_attention_status = pciehp_get_raw_indicator_status; ops->set_attention_status = pciehp_set_raw_indicator_status; + }else if (is_craye1k_slot (ctrl)) { +/* +* The Cray E1000 driver controls slots 1-24. Initialize the +* Cray E1000 driver when slot 1 is seen. +*/ +if (PSN (ctrl) ==1 ) { + retval =craye1k_init (); +if (retval) { +ctrl_err (ctrl, +"Error loading Cray E1000 extensions" ); +kfree (ops); +return retval; + } + } + ops->get_attention_status = craye1k_get_attention_status; + ops->set_attention_status = craye1k_set_attention_status; }/* register this slot with the hotplug pci core */
drivers/pci/hotplug/pciehp_craye1k.c new file +690 -0
690 lines not on this page · raw message
Signature · 1 line
2.43.7
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Tony,
kernel test robot noticed the following build warnings:
[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v6.18 next-20251209] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tony-Hutter/Introduce-Cray-ClusterStor-E1000-NVMe-slot-LED-driver/20251209-094846 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/d422a22c-a6fe-4543-ae16-67d64260e0cf%40llnl.gov patch subject: [PATCH v7] Introduce Cray ClusterStor E1000 NVMe slot LED driver config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20251210/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251210/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/pci/hotplug/pciehp_craye1k.c: In function 'craye1k_get_attention_status':
>> drivers/pci/hotplug/pciehp_craye1k.c:570:25: warning: variable 'craye1k' set but not used [-Wunused-but-set-variable]
570 | struct craye1k *craye1k;
| ^~~~~~~vim +/craye1k +570 drivers/pci/hotplug/pciehp_craye1k.c
565
566 int craye1k_get_attention_status(struct hotplug_slot *hotplug_slot,
567 u8 *status)
568 {
569 int rc;
> 570 struct craye1k *craye1k;
571
572 if (mutex_lock_interruptible(&craye1k_lock) != 0)
573 return -EINTR;
574
575 if (!craye1k_global) {
576 /* Driver isn't initialized yet */
577 mutex_unlock(&craye1k_lock);
578 return -EOPNOTSUPP;
579 }
580
581 craye1k = craye1k_global;
582
583 rc = __craye1k_get_attention_status(hotplug_slot, status, true);
584
585 mutex_unlock(&craye1k_lock);
586 return rc;
587 }
588
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki