The driver reached the PCU function's config space by walking the ACPI MCFG
table and mapping the ECAM page itself. That is one leaf driver deciding
config-space policy, and no other driver in mainline does it, so it was the
single most likely reason for a NAK.
Move that decision where it belongs: the upstream series is now two patches,
a PCI/x86 accessor that forces the memory-mapped path with the core's
locking, and this driver on top of it. Reviewers on each side now get
something they can act on, and get_maintainer.pl selects the PCI and x86
people by itself.
Correctness work in the same pass:
- the completion bits are latched, so a command the engine never accepted
was indistinguishable from a completed one and returned the previous
transaction's data as valid. Require a positive sign that the engine
acted on the command;
- 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.
Stop attributing the dropped CF8/CFC write to System Management Mode. The
only evidence was a boot log line naming the access method, which says
nothing about who filters the write. tools/probe-cf8-write.sh is there to
settle it with an MSR_SMI_COUNT measurement.
Add Documentation/i2c/busses/i2c-imc-skylake.rst, which every other PC SMBus
driver has and which was explicitly asked for on the 2020 iMC thread, the
tools/ scripts for the hardware measurements the submission still owes, and
compat/pci-mmcfg-compat.h so the driver still builds out-of-tree against a
kernel without the new accessor while the source stays byte-identical to the
submitted patch.
78 lines
2.7 KiB
Makefile
78 lines
2.7 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)
|
|
|
|
# The driver calls pci_mmcfg_{read,write}_config(), added by patch 1/2 of the
|
|
# upstream series. Against a kernel that does not have them yet, force-include
|
|
# the out-of-tree shim so the driver source stays identical to the submitted
|
|
# patch. See compat/pci-mmcfg-compat.h.
|
|
IMC_NEED_COMPAT := $(shell grep -qs pci_mmcfg_read_config \
|
|
$(srctree)/include/linux/pci.h || echo y)
|
|
ifeq ($(IMC_NEED_COMPAT),y)
|
|
ccflags-y += -include $(src)/compat/pci-mmcfg-compat.h
|
|
$(warning i2c-imc-skylake: target kernel lacks pci_mmcfg_read_config(); building with the out-of-tree compat shim)
|
|
endif
|
|
|
|
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
|