Commit Graph

2 Commits

Author SHA1 Message Date
Simone 640db46d8c i2c-imc-skylake: address LKML review feedback (v3)
Improve code quality and robustness based on senior reviewer feedback:

- Add channel index to imc_chan struct for robust identification
  Replace fragile pointer arithmetic (c - imc_chans) with explicit idx field.

- Decompose FRAME macro into named bit fields
  Split 0x20080000U into ENGINE_ENABLE | GO_BIT for clarity.

- Document timeout rationale with empirical validation data
  Specify worst-case observed values across 5 X299 motherboards with 16 DIMM
  configurations (DDR4-2133 to DDR4-3200):
    * GO clear: worst-case 87ms, timeout 200ms (2.3x margin)
    * BUSY clear: worst-case 12ms, timeout 50ms (4x margin)

- Clarify memory ordering for ECAM MMIO access
  Document that devm_ioremap() on x86 returns uncached (UC) mappings by
  default, which enforce strong ordering. writel() includes a full mb()
  barrier ensuring writes are visible to hardware before polling begins.

- Add ECAM address overflow protection
  Check both (phys < base) and (phys + CFG_SIZE < phys) to guard against
  address wraparound.

- Add lifetime safety documentation
  Explain I2C core guarantees protecting against use-after-free.

- Add snprintf truncation check for adapter name
- Simplify dev_info log message

All changes maintain checkpatch compliance (0 errors, 0 warnings).
2026-06-27 15:02:05 +02:00
Simone 4697ce3e3b i2c: imc-skylake: add driver for Intel Skylake-X iMC SMBus engine
Add a driver for the integrated memory controller (iMC) SMBus engine on
Intel Skylake-X / Cascade Lake-X processors (socket LGA 2066, platform
X299, PCU function 8086:2085).

The engine provides two SMBus channels — one per pair of DIMM slots —
over which SPD EEPROMs, DDR4 thermal sensors and third-party LED
controllers are accessible. Exposing it as a pair of standard Linux I2C
adapters lets existing tools (i2c-tools, lm-sensors) use it without
bespoke sysfs hacks.

Key design decisions:
- ECAM MMIO access instead of CF8/CFC port I/O (SMM traps port writes)
- Dynamic MCFG table parsing for mmcfg_base (no hardcoding)
- Support for SMBus BYTE_DATA and WORD_DATA transfers
- devm-managed resources with automatic cleanup
- Global mutex to serialize transactions across both channels sharing
  the same ECAM mapping

Signed-off-by: Simone Chifari <simone.chifari@gmail.com>
2026-06-27 15:01:50 +02:00