Files
i2c-imc-skylake/Makefile
T
Simone 88a8b7eb27 i2c-imc-skylake: retract the CF8/CFC claim, harden the state machine
v2 said firmware filters CF8/CFC config writes to this function and that
the registers are reachable only through ECAM.  That was never tested; the
only evidence was the boot line "PCI: Using configuration type 1", which
names the accessor and says nothing about a write failing.

Measured on the board, driver unloaded:

  # setpci -s 16:1e.5 9c.L=20085002    # read SPD 0x50 register 0x02
  # setpci -s 16:1e.5 9c.L
  20005002                             # GO consumed by the engine
  # setpci -s 16:1e.5 a8.L
  0000500c                             # READ_DONE, no error
  # setpci -s 16:1e.5 b4.L
  0000000c                             # SPD byte 2, DDR4 type code

The command executes and returns correct data through the ordinary
accessors, and MSR_SMI_COUNT does not move across it.  So the driver now
uses pci_read_config_dword() and pci_write_config_dword(), the submission
is a single patch again, and nothing in it touches the PCI core.  The
cover letter retracts the claim explicitly rather than dropping it
quietly, because v2 was posted with it.

Correctness work in the same pass:

  - the completion bits are latched, so a command word that never reaches
    the register is indistinguishable from a completed transfer and the
    caller gets the previous transaction's data.  Read the command word
    back and require it to be the one just written; the engine only ever
    clears GO, which the measurement above shows directly;
  - compare the command registers after every transfer against what the
    driver left in them and fail with -EAGAIN on a mismatch.  The original
    iMC driver had this check and it is what makes an unarbitrated system
    detectable instead of silently wrong;
  - use the i2c core's suspended-adapter mechanism rather than a private
    flag and -EHOSTDOWN;
  - use devm_mutex_init(), drop the unnecessary pci_enable_device(), and
    return -ENODEV rather than -EPERM from the default-off gate, which was
    printing a driver-core error on every boot;
  - mask GO when restoring a saved command word.

An earlier version of the latched-DONE check required the GO bit to be
seen set or the status word to change.  That was wrong: repeated transfers
with the same outcome leave STATUS bit for bit identical, and GO is
consumed faster than a config read-back can observe it.  It produced false
positives on 3 of 15 smoke-test items before being replaced.

Add Documentation/i2c/busses/i2c-imc-skylake.rst, which every other PC
SMBus driver has and which was asked for on the 2020 iMC thread, and the
tools/ scripts for the hardware measurements: probe-cf8-write.sh and
probe-cf8-transaction.sh produced the result above, dump-pcu-config.sh is
the search for a TSOD polling control, watch-engine.sh is the firmware
activity measurement.

Smoke test on the X299 system with the current module: 15 checks, 0
failures, dmesg clean.
2026-07-26 19:51:44 +02:00

67 lines
2.2 KiB
Makefile

obj-m := i2c-imc-skylake.o
KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
INSTALL_MOD_PATH ?= $(DESTDIR)
INSTALL_MOD_DIR ?= updates
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
# Install through Kbuild so ownership, compression and destination follow the
# target kernel/distribution policy. Invoke this target with suitable privileges.
install: all
$(MAKE) -C $(KDIR) M=$(PWD) modules_install \
INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR)
# Remove a module installed in INSTALL_MOD_DIR. Invoke with suitable privileges.
uninstall:
rm -f $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/$(INSTALL_MOD_DIR)/i2c-imc-skylake.ko*
depmod -a -b $(INSTALL_MOD_PATH) $(KVER)
# Runtime helpers require explicit acknowledgement of the firmware-arbitration
# risk: make reload ALLOW_UNSAFE=1 (or make load ALLOW_UNSAFE=1).
reload: all
@test "$(ALLOW_UNSAFE)" = "1" || \
{ echo "Refusing: rerun with ALLOW_UNSAFE=1" >&2; exit 2; }
sudo rmmod i2c-imc-skylake 2>/dev/null || true
sudo insmod i2c-imc-skylake.ko allow_unsafe_access=1
# Load without build (use after install)
load:
@test "$(ALLOW_UNSAFE)" = "1" || \
{ echo "Refusing: rerun with ALLOW_UNSAFE=1" >&2; exit 2; }
sudo modprobe i2c-dev
sudo modprobe i2c-imc-skylake allow_unsafe_access=1
unload:
sudo rmmod i2c-imc-skylake 2>/dev/null || true
# Checkpatch (must be clean before submission)
checkpatch:
perl $(KDIR)/scripts/checkpatch.pl --strict --no-tree -f i2c-imc-skylake.c
# Sparse static analysis (requires sparse >= kernel version; may show header errors on old sparse)
sparse:
$(MAKE) -C $(KDIR) M=$(PWD) C=1 CF="-D__CHECK_ENDIAN__"
# Smoke test requires root or non-interactive sudo.
test: all
MODULE_PATH=$(PWD)/i2c-imc-skylake.ko bash test-smoke.sh
# Hardware measurements that the upstream submission still needs. Read-only
# unless explicitly asked otherwise; see tools/README.md.
measure:
@echo "Run the scripts under tools/ individually; see tools/README.md" >&2
@false
log:
sudo dmesg | grep i2c-imc-skylake | tail -80
.PHONY: all clean install uninstall reload load unload checkpatch sparse test measure log