Kernel & Device Drivers8 min readLinux 6.12 LTS

Debugging Linux Device Tree bindings, -EPROBE_DEFER & gpiod polarity failures

Why your driver compiled cleanly, loaded without errors, and never called .probe() — plus the exact runtime files in sysfs and debugfs that settle what happened.

1. When .probe() never runs, stop recompiling and inspect the live FDT

The single most common board bring-up time sink looks like this: you edit a .dts file, rebuild, reboot, run insmod my_sensor.ko, see zero errors in dmesg, and discover your driver's .probe() callback never executed. Before touching C code again, verify that the Flattened Device Tree (FDT) U-Boot actually handed to the kernel matches what you think you compiled.

Linux exposes the exact unflattened tree in /sys/firmware/devicetree/base:

# 1. Confirm the node exists and its status is "okay" (or absent), not "disabled"
ls -la /sys/firmware/devicetree/base/soc/bus@2100000/i2c@21a0000/
tr '\0' '\n' < /sys/firmware/devicetree/base/soc/bus@2100000/i2c@21a0000/sensor@1e/compatible
tr '\0' '\n' < /sys/firmware/devicetree/base/soc/bus@2100000/i2c@21a0000/sensor@1e/status

# 2. Or decompile the live running tree back into readable DTS syntax
dtc -I fs -O dts /sys/firmware/devicetree/base -o /tmp/running.dts

Nine times out of ten, a forgotten Device Tree overlay, a stale FIT image partition, or a later .dtsi include overriding status = "disabled"; shows up in five seconds here.

2. Triage silent probe deferral with devices_deferred

When your node is okay and its compatible string matches your of_device_id table byte-for-byte, the next suspect is -EPROBE_DEFER. If your device references a regulator, clock, DMA channel, pinctrl provider, IOMMU, or GPIO controller whose own driver has not probed yet (or was left out of .config), the driver core parks your device on the deferred list without printing a fatal error.

# List every device stuck waiting on an unmet supplier dependency
cat /sys/kernel/debug/devices_deferred

# Inspect supplier -> consumer device links for a specific platform/I2C device
ls -la /sys/bus/i2c/devices/0-001e/supplier:*

On Linux 6.12+, fw_devlink=on parses Device Tree phandles (clocks, vdd-supply, pinctrl-0, iommus, OF-graph remote-endpoint) into explicit kernel device links before driver probe even starts. If devices_deferred prints a reason string next to your device, follow that phandle directly to the missing Kconfig option for the supplier driver.

3. Validate YAML schemas with dt_binding_check before booting

Misspelled property names (reset-gpio vs reset-gpios, or wrong cell counts under #interrupt-cells = <2>) compile cleanly under plain dtc because dtc only checks syntax, not subsystem semantics. Run the kernel's JSON-Schema validator against both your YAML binding and your board DTB:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
  DT_SCHEMA_FILES=Documentation/devicetree/bindings/iio/imu/ksa,imu6.yaml \
  dt_binding_check dtbs_check

4. Active-low GPIO polarity in gpiod vs raw hardware levels

Legacy integer GPIO APIs (of_get_named_gpio + gpio_set_value) operated on raw electrical pin levels and are deprecated. Modern Linux 6.12 drivers use descriptor-based gpiod, which operates on logical assertion states:

/* Device Tree: reset pin is wired active-low to an RC pull-up */
reset-gpios = <&gpio1 18 GPIO_ACTIVE_LOW>;
/* Driver C code: pass logical 1 = "assert reset", 0 = "deassert reset" */
priv->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(priv->reset))
    return dev_err_probe(&client->dev, PTR_ERR(priv->reset), "missing reset-gpios\n");

fsleep(5000);
gpiod_set_value_cansleep(priv->reset, 0); /* drives physical pin HIGH (out of reset) */

Two rules prevent days of oscilloscope confusion:

  • Because the DTS declares GPIO_ACTIVE_LOW, calling gpiod_set_value_cansleep(desc, 1) drives the physical pad 0 V (asserted). Inverting the value a second time in C double-negates the signal and holds the chip permanently in reset.
  • Always wrap probe-time errors in dev_err_probe(): it suppresses noisy log spam during legitimate -EPROBE_DEFER retries while recording the exact human-readable reason string inside /sys/kernel/debug/devices_deferred!

5. Checking pinmux contention in debugfs

If .probe() succeeds and /sys/kernel/debug/gpio shows the right logical state, yet the physical pad never toggles on a scope, check whether the SoC pin controller actually muxed that ball to the GPIO or bus block rather than leaving it claimed by UART or JTAG:

cat /sys/kernel/debug/pinctrl/*/pinmux-pins | grep -E "pin 18|21a0000"

Questions engineers ask

Why did insmod succeed with exit code 0 when my driver never probed?

module_init() registers your platform_driver or i2c_driver struct with the kernel bus list and returns 0 immediately. The .probe() callback only runs when the bus matches a registered device whose compatible string and status='okay' match, and whose fw_devlink suppliers are ready.

What does dev_err_probe() do that dev_err() does not?

When the error code is -EPROBE_DEFER, dev_err_probe() avoids spamming the kernel ring buffer during normal boot ordering and instead saves your formatted message into debugfs (/sys/kernel/debug/devices_deferred) so you can see exactly which clock, regulator, or GPIO deferred the probe.

Why is gpiod_set_value_cansleep() preferred over gpiod_set_value() in most drivers?

If a board revision moves a reset or enable line from an MMIO SoC bank onto an I2C or SPI GPIO expander, gpiod_set_value_cansleep() continues working safely from process/threaded-IRQ context, whereas gpiod_set_value() triggers a kernel warning because bus transfers sleep.

Hands-on courses covering this stack

More technical articles

Want a practitioner to look at your trace or board?

Book a free 60-minute technical session for your engineering team, or scope a private cohort adapted to your kernel tree and hardware.

Free technical session