Troubleshooting Linux PCI Driver: Loaded but Unable to Access Device Tree Information
This article addresses a common issue faced by Linux kernel developers and users: a PCI driver is loaded, but unable to access the device tree information.
Background on PCI Drivers in Linux
The Linux kernel uses Plug-and-Play (PnP) to manage and configure devices, automatically detecting and associating drivers with their respective devices. This system relies on device tree data to provide information about the system's hardware. The PCI (Peripheral Component Interconnect) standard is a widely-used interface for connecting peripherals to computers, smartphones, and tablets.
Identifying the Problem
When a PCI driver fails to access the device tree information, an error message similar to the following might be observed in the kernel logs:
pci_dev->dev->of_node == NULL
Debugging Steps
To troubleshoot this issue, the following steps can be taken:
Check if the device tree node for the PCI device exists.
Determine if the PCI driver matches the device tree node.
Verifying Device Tree Node Existence
Utilize the finddevtree utility to find the device tree node’s path:
$ finddevtree
Replace device-ID with the ID of the PCI device.
Matching PCI Drivers to Device Tree Nodes
When the device tree node is present, verify that the PCI driver is compatible with the device tree node via the compatible property:
compatible = "vendor-name,device-ID”;
Ensure that the compatible property is present in both the device tree node and PCI driver.
Adding a Device Tree Overlay
Should the device tree lack a required node, adding a device tree overlay can be used to resolve the issue. A device tree overlay supplements the main device tree, allowing for easy customization and expansion.
Tips for Addressing the Issue
Ensure the main device tree has the required nodes for the PCI device.
Verify that the
compatibleproperty matches the PCI device driver.Consider adding a device tree overlay if the issue persists.
- The issue of a Linux PCI driver being loaded but unable to access device tree information arises due to incompatible or absent device tree nodes.
- Debugging steps include checking if the device tree node for the PCI device exists and if the PCI driver matches the device tree node.
- Creating a device tree overlay can supplement main device tree limitations or inconsistencies.