All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH platform-next v4 0/3] platform/mellanox: Add nvsw core and SPC6 host driver
@ 2026-11-25 18:46 Felix Radensky
  2026-11-25 18:46 ` [PATCH v4 1/3] platform/mellanox: nvsw-core: Add core driver for Nvidia switches Felix Radensky
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Felix Radensky @ 2026-11-25 18:46 UTC (permalink / raw)
  To: Ilpo Järvinen, Hans de Goede, Vadim Pasternak
  Cc: Felix Radensky, platform-driver-x86

This series adds support for system control and monitoring on Nvidia
SPC6 based switches, through the CPLD/FPGA devices attached to the host
CPU.

Patch 1 adds nvsw-core, which implements the register map setup, the I2C
mux topology and the creation of the mlxreg-* platform devices shared by
all Nvidia switch board drivers. Patch 2 adds nvsw-host-spc6, the first
user of that core, covering the liquid cooled systems, along with
documentation for the register access attributes it exposes. Patch 3
adds the air cooled SPC6 systems, which unlike the liquid cooled ones
carry their own power supplies and fan drawers.

The functionality covered is component resets and reset cause
reporting, mux selection for hardware components, general purpose
registers, LED control, watchdog control, and fan control on the
systems that have fans. The core also creates an mlxreg-hotplug device
for boards that describe one; no SPC6 system does, and that path comes
into use with the BMC driver mentioned below.

Why a new core instead of extending mlx-platform
================================================

The obvious question is why this does not go into mlx-platform.c, which
already serves the existing Mellanox switch generations. There are two
reasons.

The first is that mlx-platform.c cannot reach this hardware. It is
built around a single memory mapped LPC window: it calls
devm_ioport_map() once, hands the resulting base to devm_regmap_init()
with its own ioread8()/iowrite8() callbacks, and every system it
supports is described in terms of offsets into that window. On SPC6 the
CPLD is not on the LPC bus at all, it is an I2C device, and the driver
reaches it with devm_regmap_init_i2c() through a client on the host I2C
tree. Supporting SPC6 in mlx-platform.c would mean giving it a second,
parallel register access path and making its register map setup
conditional, which is a larger and more invasive change than adding a
separate driver.

The same applies beyond SPC6. The identical CPLD register layout is
also managed from an ARM Baseboard Management Controller, where the
device is reached over I2C in the same way but is described in device
tree rather than discovered through DMI. nvsw-core holds only the parts
that do not depend on how the board was found, so the register
definitions and the mlxreg-* device descriptions are shared, and each
board driver supplies its own instantiation. mlx-platform.c is
inherently x86 and DMI bound and cannot serve the BMC side.

The second reason is structural. mlx-platform.c has grown to roughly
8600 lines covering 49 DMI matches, with the per-system description
data and the device creation logic interleaved in a single translation
unit. Adding another switch generation to it makes the file harder to
review and makes it impossible to build support for one system without
carrying the tables for all the others. nvsw splits the two concerns:
the core holds the logic (391 lines) and each board driver holds only
its own description data, so a kernel can be built with just the boards
it needs.

The core is not speculative generality. The SPC6 host driver in this
series is its first user, and we intend to submit a BMC driver and an
NVL7 host driver on top of it once the core has been reviewed.

Why the SPC6 driver is split over two patches
=============================================

Patches 2 and 3 add a single driver, split along a hardware line
rather than chopped into arbitrary pieces. Patch 2 is complete and
useful on its own: it covers the liquid cooled SPC6 systems, which
shipped first. Patch 3 adds the air cooled systems, which arrived
later and expose a different set of CPLD attributes because they carry
their own power supplies and fan drawers.

Most of both patches is register description data, and the two sets
are largely disjoint. Folding them together would give a single patch
of roughly 1700 lines in which two unrelated board descriptions are
interleaved, with nothing in the diff to indicate which attribute
belongs to which system.

Patch 3 is purely additive: it does not modify or remove a single line
introduced by patch 2. The per SKU description struct and the
driver_data based DMI dispatch are introduced in patch 2, so patch 3
adds only the new register definitions, the new board description and
the DMI entry that selects it.

On the shared "mlxplat" platform device name
============================================

nvsw-host-spc6 registers its platform device as "mlxplat", the same
name used by mlx-platform.c. This is deliberate. The mlxreg-io
attributes are a long standing userspace ABI documented in
Documentation/ABI/stable/sysfs-driver-mlxreg-io, and the management
software reads them from
/sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/. Keeping the name
keeps those paths stable across switch generations, so existing tooling
works unchanged on SPC6.

The two drivers cannot collide at runtime: each matches DMI and returns
-ENODEV before registering anything, and their DMI tables are disjoint,
so on any given system exactly one of them instantiates.
If you would still rather the new driver used a distinct name, we can
change it, but it would mean a new sysfs path and a userspace ABI break
for the affected systems.

Symbol namespace
================

The two symbols the core exports to its board drivers are exported as
EXPORT_SYMBOL_NS_GPL() in the NVSW namespace. They are still global
exported symbols, but a module can only use them after importing the
namespace with MODULE_IMPORT_NS(), which modpost and the module loader
enforce, so the dependency is explicit in each consumer.

Testing
=======

Built on x86_64 against pdx86/for-next with gcc W=1 and with clang 17
W=1 plus CONFIG_WERROR, both warning free, at every patch in the
series. Checked with sparse v0.6.5-rc1, smatch and the coccinelle
report mode scripts, all clean. checkpatch --strict reports
no errors and no checks. Module linkage and the namespace import were
verified with modpost and modinfo.

v3->v4
Comments pointed out by Ilpo:
- Stop fanning the matched board description out into module scope.
  The per SKU data is held in struct nvsw_host_spc6_cfg and reached
  through the driver_data of the DMI entry, so nvsw_host_init() now
  matches with dmi_first_match(), hands that description to the
  platform device as its platform data, and the probe path reads it
  back from there. A single pointer is carried over instead of ten
  copies, and the DMI match callback is gone with them.
- Keep the mux parent adapter and the mux client out of module scope
  too. The client lives in struct nvsw_core, which is already the
  drvdata, and the adapter is reached through client->adapter where
  it has to be released. Together with the above this removes every
  module scope pointer in nvsw-host-spc6 except the platform device
  itself, and with them the NULL stores on the error paths that the
  v2 review had already flagged. The board tables remain static.
- Update the ABI Date and KernelVersion in patches 2 and 3, as 7.4
  was missed. They now read November 2026 and 7.5.
Issues reported by a local sashiko review:
- Correct the patch 1 commit message, which said the core implements
  the I2C mux topology. The core only runs the board's mux_init and
  mux_exit callbacks, and the message and kernel-doc now say so.
- Stop calling set_reg_default from nvsw_core_exit(). It only wrote
  the probe-time defaults again, so the callback now runs once, from
  nvsw_core_init().
- Drop the nvsw.h definitions that no driver in the series uses,
  among them CURRENT_TEMP_RO and SWITCH_IC_QTY, which were missing
  from nvsw_readable_reg(), NVSW_REG_MIN, NVSW_NR_NONE and 37 masks.
- Drop the unused ASIC2 to ASIC4 health, event and mask registers,
  which on SPC6 hold thermal and VR signals rather than ASIC health,
  and say in a comment that 0x2550 packs the health of all four ASICs.
- Drop nvsw_volatile_reg(). With no register cache since v3 it was
  never consulted, and it listed every readable register, so a cache
  would have had nothing to hold either. Behaviour is unchanged.
- Stop setting .platform_data on the mux I2C board info in patch 2.
  i2c-mux-mlxcpld is a platform driver and takes its data from the mux
  platform devices, so nothing read it. The board info is now const.
- Update the existing asic_reset and asic2_reset ABI entry. On systems
  which provide asic1_reset to asic4_reset, asic_reset resets all the
  ASICs at once and the others reset one each.
- Stop creating 32 attributes over reserved bits, or over CPLDs that
  are not fitted, on the single ASIC liquid cooled systems. They now
  sit in a table of their own, appended at init to a copy of the
  common table for the four ASIC system.
- Drop the unused linux/i2c-mux.h include from nvsw-host-spc6.
- Add only the registers patch 3 uses to the nvsw-core register map.
  Thirteen registers, among them the power supply alarm group and
  TACHO13 to TACHO20, were made accessible with nothing using them.
- Restore the CPLD fan fault override when the air cooled driver is
  removed or fails to probe, through a new restore_reg_default core
  callback paired with set_reg_default. It was cleared at probe and
  never set again, leaving the fans without fault handling.
- Correct the patch 3 commit message, which said mlx-platform clears
  the same override. mlx-platform writes a different register, and the
  override bit, bit 0 of 0x252e, exists only on the air cooled CPLD.
  The NVSW_FAN_CONTROL_EN_MASK definition now says so.
- Correct the patch 1 commit message and the cover letter, which said
  the NVSW namespace keeps the core's exports out of the global symbol
  table. They are still global symbols, and the namespace only makes
  each user import it with MODULE_IMPORT_NS().
- Shorten the patch 2 commit message on the per SKU description, and
  describe the host I2C topology the probe relies on, with the CPLD on
  bus 2 and the deferral until host bus 3 exists.
- Report the bus 3 deferral in nvsw-host-spc6 with dev_err_probe(),
  and say in the patch 2 commit message that the fixed bus numbers
  rely on the host I2C controller driver registering first.
- Say in the patch 3 ABI that a write to the psu and fan event files
  reaches every bit of the register, clearing the bits written as 0
  and leaving those written as 1 unchanged.
- Make NVSW_CORE depend on I2C, which REGMAP_I2C and the core itself
  require, rather than relying on every selecting driver to depend
  on it.
- Keep the aggregation registers and the event and mask registers of
  every status register in the nvsw-core register map when dropping
  the unused registers, since mlxreg-hotplug programs them at probe
  and would otherwise fail on any board that describes hotplug items.
Additional fixes added by Felix:
- Make the ASIC reset attributes write only in patches 2 and 3, as
  asic_reset and asic2_reset are in mlx-platform and in the ABI. They
  were exposed with mode 0644.
- Drop the HI187 SKU, an intermediate system that will not be
  manufactured.
- Drop the 69 registers that no driver in the series uses from
  nvsw.h and from the nvsw-core register map, which now holds only
  the registers the SPC6 driver accesses and those mlxreg-hotplug
  programs for its status registers.
- Drop the cpu_mctp_ready attribute and its ABI entry from both
  tables, as the CPLD signal will be removed in future CPLD releases.
- Drop asic_pg_fail from the air cooled table, which the liquid
  cooled table does not have either.
Other:
- Rebase onto the current platform-drivers-x86 for-next.

On the one finding sashiko.dev reported against v3, the fan drawer
LEDs that patch 3 describes: it is valid, and it is now fixed, in the
LED tree rather than here. The capability register of these systems
reports a count of the fan drawers present rather than a bitmap, so
the LED entries carry a slot index and leave the capability bit at
zero, which mlxreg_led_config() did not understand. The same
description style is used by mlxplat_mlxcpld_xdr_led_data in
mlx-platform.c, which has been losing all twenty of its fan LEDs
since the table was introduced in v6.16, so the gap belongs to
leds-mlxreg. Lee has applied the fix, commit 68a2bfdf7b4d ("leds:
mlxreg: Fix missing fan LEDs on systems reporting a unit count"),
currently in for-leds-next and so queued for the same merge window as
this series. There is no build or apply dependency between the two
and the LED table here is unchanged.

v2->v3
Comments pointed out by Ilpo:
- Return directly from nvsw_core_init() when
  nvsw_core_mux_topology_init() fails, instead of jumping to a label
  that only does a return.
Issues reported by the sashiko.dev review, which Ilpo asked us to
check:
- Fix the shift for asic2_health..asic4_health. The four ASIC health
  fields share one register, two bits each, but all four entries
  carried .bit = 1, so only asic_health was right aligned and the
  other three reported their field still shifted up. Set .bit to the
  one based position of each mask's least significant bit.
- Drop nvsw_core_reg_def and the register cache configuration that
  went with it. The review pointed out that the array was unsorted
  and that its entries never reached the hardware. Neither register
  is relevant on SPC6, so the array is removed rather than sorted,
  which leaves the cache with nothing to hold. This also drops
  linux/bits.h from nvsw-core.c, whose only user there was the
  GENMASK in that array. The one default SPC6 does need is written by
  the board driver instead, see patch 3.
- Make pdb1_pwr_status..pdb4_pwr_status read only. They were exposed
  with mode 0644 over a register that is not in nvsw_writeable_reg(),
  so a write returned -EIO. The ABI documentation is updated to match.
- Correct the mode of the air cooled pwr_cycle attribute, which was
  0244 instead of 0200.
- Fix the documented polarity of fan_status and psu_status. The CPLD
  reports fan drawer and power supply presence active low, so bit
  value 0 means present. For fan_status that is what
  mlxreg_fan_read() already assumes when it reads the same register
  through .reg_prsnt, so only the ABI text was wrong. psu_status
  shares a description block with psu_ac_status and psu_dc_status,
  which are active high, so the polarity is now stated per attribute.
- Drop the claim that the air cooled system exposes power supply
  alarm indications from the patch 3 commit message, since no
  attribute is described over the alarm registers.
Additional fixes added by Felix:
- Describe jtag_enable as the single bit it is. It was given a two bit
  mask, but only the lower bit is defined in the CPLD register map, so
  values 2 and 3 were accepted and wrote a reserved bit.
- Drop the aux_pwr_cycle attribute from the air cooled table, as it is
  not supported on systems with power supply units.
- Drop the shutdown_unlock attribute. It was described over bit 5 of
  the general purpose register, which the CPLD register map lists as
  reserved. Thermal shutdown unlock is handled by the BMC on SPC6, so
  the attribute is removed rather than moved to the right bit.
- Clear the CPLD fan fault override enable bit on air cooled systems,
  so that the fan speed is left to the software. This is done from the
  board driver through the set_reg_default callback, which until now
  had no user.
- Drop NVSW_REG_FU_CAP_OFFSET from nvsw_writeable_reg(). It is read
  only in hardware and the only attribute over it is 0444, so the
  entry could never be reached. Found by checking every register in
  nvsw_writeable_reg() against the CPLD register map; it is the only
  mismatch.
- Rename the last remaining *_fail label in nvsw-core to err_*, for
  consistency with the rest of the file.

v1->v2
Comments pointed out by Ilpo:
- Add the direct includes for the macros the two drivers use rather
  than relying on them arriving transitively: linux/array_size.h for
  ARRAY_SIZE, linux/bits.h for BIT and GENMASK, linux/err.h for IS_ERR
  and PTR_ERR and linux/dev_printk.h for the dev_*() helpers, plus
  linux/export.h and linux/types.h in the core.
- Remove the redundant NULL assignments from the error paths. The
  registration helpers now return into a local variable, so a struct
  nvsw_core field is only ever assigned a valid pointer and never an
  ERR_PTR, which is what the NULL stores were papering over. 19 of the
  23 assignments are gone; the 4 that remain are on the two module
  scope pointers in nvsw-host-spc6, which outlive a failed probe.
- Rework the rollback in nvsw_core_platform_init() and
  nvsw_host_spc6_mux_topology_init() to be positional, and drop the
  defensive pointer tests from the matching exit paths, which can no
  longer see a partially initialised state.
Additional fixes added by Felix:
- Sort the include blocks in both drivers.
Link to v1: https://lore.kernel.org/platform-driver-x86/20261008061704.794379-1-fradensky@nvidia.com/
Link to v2: https://lore.kernel.org/platform-driver-x86/20261018101156.699575-1-fradensky@nvidia.com/
Link to v3: https://lore.kernel.org/platform-driver-x86/20261020172756.4160946-1-fradensky@nvidia.com/

Felix Radensky (3):
  platform/mellanox: nvsw-core: Add core driver for Nvidia switches
  platform/mellanox: nvsw-host-spc6: Add driver for Nvidia SPC6 switches
  platform/mellanox: nvsw-host-spc6: Add support for SPC6 air cooled
    switches

 .../ABI/stable/sysfs-driver-mlxreg-io         |  205 ++-
 drivers/platform/mellanox/Kconfig             |   20 +
 drivers/platform/mellanox/Makefile            |    2 +
 drivers/platform/mellanox/nvsw-core.c         |  391 +++++
 drivers/platform/mellanox/nvsw-host-spc6.c    | 1485 +++++++++++++++++
 drivers/platform/mellanox/nvsw.h              |  202 +++
 6 files changed, 2304 insertions(+), 1 deletion(-)
 create mode 100644 drivers/platform/mellanox/nvsw-core.c
 create mode 100644 drivers/platform/mellanox/nvsw-host-spc6.c
 create mode 100644 drivers/platform/mellanox/nvsw.h


base-commit: 2268d837dea13a78639fa3dad60472bb67478709
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-26 16:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 18:46 [PATCH platform-next v4 0/3] platform/mellanox: Add nvsw core and SPC6 host driver Felix Radensky
2026-11-25 18:46 ` [PATCH v4 1/3] platform/mellanox: nvsw-core: Add core driver for Nvidia switches Felix Radensky
2026-11-25 18:46 ` [PATCH v4 2/3] platform/mellanox: nvsw-host-spc6: Add driver for Nvidia SPC6 switches Felix Radensky
2026-11-25 21:17   ` Ilpo Järvinen
2026-11-26 16:07     ` Felix Radensky
2026-11-25 18:46 ` [PATCH v4 3/3] platform/mellanox: nvsw-host-spc6: Add support for SPC6 air cooled switches Felix Radensky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.