
Recall first from Render nodes and how CUDA maps onto them
- DRM render nodes expose driver-supported GPU operations without KMS or DRM master.
- Typical udev rules assign primary nodes to video and render nodes to render.
- Jetson CPU and integrated GPU allocations draw from the same physical DRAM, while allocation APIs determine how each processor accesses them.
Identify the device and inspect its buffers
3 min readYou have the whole stack. This lesson answers how to inspect it at runtime and what firmware runs on the GPU.
A camera preview can open a DRM device and still fail to display a frame. The program might have opened a card without the connected display, or the display plane might reject the buffer layout. Start with the devices the kernel actually registered. A card number can change with probe order, so use the resolved device path and bound driver to identify it. Linux debugfs documentation
for node in /sys/class/drm/card* /sys/class/drm/renderD*; do
[ -r "$node/dev" ] || continue
printf '%s %s\n' "${node##*/}" "$(cat "$node/dev")"
readlink -f "$node/device"
if [ -L "$node/device/driver" ]; then
readlink -f "$node/device/driver"
fi
done
for status in /sys/class/drm/card*-*/status; do
[ -r "$status" ] || continue
printf '%s %s\n' "$(basename "$(dirname "$status")")" "$(cat "$status")"
done
The dev attribute gives the major and minor number of the node. It also filters connector entries out of the first loop. Matching resolved device paths let you associate a card node and a render node with the same kernel device. On a board where the rendering and display drivers register separate DRM devices, expect separate paths. The second loop shows which card owns each reported connector. A connected connector gives you a display candidate. The current modeset state determines whether it is active.
/sys/kernel/debug/dri contains diagnostic files registered by DRM and individual drivers when debugfs is available. List what your kernel exposes before choosing a file to read:
findmnt /sys/kernel/debug
sudo ls /sys/kernel/debug/dri
sudo find /sys/kernel/debug/dri -maxdepth 2 -type f
If debugfs is unmounted on your native test system, mount it with sudo mount -t debugfs debugfs /sys/kernel/debug. If the kernel or environment prevents the mount, record that limit and continue with sysfs and procfs. In the DRM directories, read name where present to identify the device, clients to inspect open DRM clients, and state to inspect atomic modeset state where the driver exposes it. Look for framebuffer and plane information in state, and inspect any buffer or memory accounting files your driver provides. The filenames and contents can vary by driver and kernel configuration.
For shared buffers, check sudo cat /sys/kernel/debug/dma_buf/bufinfo if that file exists. It provides a system-wide view of dma-buf objects, including fields such as exporter, size and inode, and can show device attachments. If the kernel was built with CONFIG_DMABUF_SYSFS_STATS, /sys/kernel/dmabuf/buffers/ provides per-inode entries with attributes such as exporter_name and size. The DRM class directory identifies devices and connectors. Use the dma-buf diagnostics or driver-specific files to inspect buffers. A buffer private to a driver can be absent from the dma-buf listing. Linux dma-buf statistics
Determine which firmware the GPU uses
2 min readA Firmware is code or data consumed by hardware or an embedded processor. A blob is a packaged binary image that the host handles as bytes. Depending on the GPU, firmware can initialize a controller, schedule GPU work, or manage power. Different controllers can use separate images. On Raspberry Pi 4, start4.elf is VideoCore boot firmware started before Linux. Seeing v3d bound under Linux identifies the rendering driver. By itself, that binding says nothing about the boot firmware version or files requested by Linux.
When a Linux driver uses request_firmware(), it supplies a filename. The kernel firmware loader can obtain the bytes from its firmware search paths, which include directories under /lib/firmware, or from built-in firmware when configured. Early requests can find files supplied in the initramfs. After obtaining the bytes, the driver may upload the image to a device controller and wait for initialization. Hardware selection, driver options and the requested feature can all affect which image is chosen.
sudo journalctl -k -b | grep -Ei 'drm|firmware|v3d|vc4'
Use the device identity from sysfs and the boot log together. Read surrounding log lines if the filter loses context. If the device's driver/module link exists, its basename gives the module name. Run modinfo -F firmware MODULE with that name to see any firmware filenames declared in the module metadata. If a filename appears there, check the firmware directory for it. A file on disk shows availability there. Its presence says nothing about whether the running device requested it. A log reporting a failed request establishes that the kernel attempted that lookup. Read subsequent messages for a successful retry, an alternate image or a controller initialization failure. Some drivers log few details on success. When the exact loaded image is unavailable from the evidence, record it as undetermined. Linux firmware search paths
GPU firmware secure boot means an enforcing component checks the firmware's authenticity before allowing it to execute. On hardware that implements it on the GPU, a device boot ROM or an already trusted controller can verify a signed image against a trusted key. The Linux driver can successfully obtain the file and still see initialization fail if the device rejects the image. Host Secure Boot establishes trust in the host boot sequence according to its own policy. To establish GPU firmware authentication, identify the verifier for that GPU image and find platform evidence that the policy is enforced. Keep an ordinary file lookup failure distinct from an explicit authentication failure. Module M16 covers secure boot and its chain of trust.
Trace camera buffers through GPU processing and display
4 min readGoing deeperExplore the mechanism
A camera can export a dma-buf, the GPU can read it as a texture, and KMS can scan out a GPU output buffer. A GPU color conversion writes a new output image. Zero-copy here means the two handoffs share their respective allocations without a CPU pixel copy. The capture and display buffers can therefore have different inode numbers. Review the display stack in module M6 and the capture queue setup in lesson M13-S06A.
On a native target, run the pipeline from a local console with access to the camera, the render device and the KMS display. A running compositor can already control the card. Use a free test display or an environment where kmssink can obtain KMS control. Check the installed elements with gst-inspect-1.0 and identify the display card with sysfs. Use a camera and mode that support V4L2 dma-buf export, an EGL implementation that can import the camera's layout and export a GPU texture, and a KMS plane that can scan out the exported layout.
GST_GL_PLATFORM=egl GST_DEBUG='glupload:6,gldownload:6,kmssink:6' \
gst-launch-1.0 -v \
v4l2src device=/dev/video0 io-mode=dmabuf \
! 'video/x-raw(memory:DMABuf)' \
! glupload ! glcolorconvert \
! 'video/x-raw(memory:GLMemory),format=RGBA' \
! gldownload ! 'video/x-raw(memory:DMABuf)' \
! kmssink > camera-drm.log 2>&1 &
pid=$!
printf 'Pipeline PID %s\n' "$pid"
Use the camera node on your board in place of /dev/video0 if needed. glupload is where EGL can import the camera image. glcolorconvert can convert a supported YUV input to RGBA on the GPU. gldownload can export a GL image as dma-buf on a compatible EGL implementation, despite its name. The caps require dma-buf at the camera and display handoffs and GL memory after conversion. They do not prove how each element implemented the operation. If negotiation fails, keep the log. The camera format, EGL import or export support, and the KMS plane's accepted formats and modifiers are separate constraints. The command is conditional on those capabilities.
While frames are displayed, use the printed PID in a second terminal. ls -l shows the open descriptors and their targets. For dma-buf descriptors, inspect the matching fdinfo file for fields such as ino, size and exp_name:
ls -l "/proc/$pid/fd"
for info in /proc/"$pid"/fdinfo/*; do
[ -r "$info" ] || continue
if grep -q '^exp_name:' "$info"; then
printf '\nFD %s\n' "${info##*/}"
cat "$info"
fi
done
These are snapshots. Descriptors can close or be reused while frames are in flight. Repeat the snapshot while streaming. A descriptor number identifies a slot in one process. Compare the dma-buf inode for the object while it is live, and use the exporter and size to support the identification. One image can use multiple dma-buf objects for its planes. Compare all objects involved in the handoff. proc_pid_fd(5)
For element-level attribution, use GStreamer debug messages where they identify the import and export paths. If they lack object identities, add pad probes to the same pipeline in a GStreamer application. At the v4l2src source and glupload sink, then at the gldownload source and kmssink sink, record each buffer's plane layout and dma-buf-backed memory. A probe can retrieve each GstMemory with gst_buffer_peek_memory(), check it with gst_is_dmabuf_memory(), and read its borrowed descriptor with gst_dmabuf_memory_get_fd(). Use fstat() on that descriptor while the buffer is live to obtain the inode without mapping its pixels. Match the same frame across each adjacent pair of pads, using its timestamp and trace order.
A matching inode at two pads establishes that both pads saw the same object. To confirm the claimed zero-copy route, also establish that GL imported the captured object and that KMS imported the exported texture for the framebuffer used by the active plane. Driver attachment information, KMS state and element traces can help establish those operations. An open FD can remain visible while an element uses a replacement buffer internally. If the available diagnostics stop at open FDs or negotiated caps, report the handoff evidence you actually have and leave the unobserved stage unconfirmed. Stop the background pipeline with kill -INT "$pid" from the shell that started it.
The next lesson, GEM buffers and dma-buf sharing, explains how DRM drivers represent these buffers and how another device gains access to a shared allocation.
Key takeaways
- Sysfs identifies DRM devices and connectors, while debugfs exposes diagnostics that depend on the kernel and driver.
- A firmware filename declared by a module establishes a candidate, while runtime messages can identify requests or initialization results.
- GPU firmware authentication depends on which component verifies the image and which trust policy it enforces.
- Matching dma-buf inode numbers support a shared handoff when paired with evidence that the receiving device used that buffer.
Reflect
- Explain to a colleague, in two sentences: match DRM nodes to their devices and bound drivers in sysfs.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Kernel documentationDebugFS: kernel debugging interfaces
- Kernel documentationBuffer Sharing and Synchronization: dma-buf statistics
- Kernel documentationDirect filesystem lookup: locating firmware files
- Man pageproc_pid_fd(5): open file descriptors
- DocumentationGStreamer dmabuf allocator API
Official documentation first. Links checked when the lesson was published.