Skip to content

driver: preserve device identity across PCI hotplug - #170

Open
amd-vserbu wants to merge 1 commit into
devfrom
feature/stable-chardev
Open

driver: preserve device identity across PCI hotplug#170
amd-vserbu wants to merge 1 commit into
devfrom
feature/stable-chardev

Conversation

@amd-vserbu

Copy link
Copy Markdown
Collaborator

Summary

This enables long-running Docker containers to keep using a V80 across SLASH remove/rescan and reset cycles when the device is passed through with docker run --device.

Docker records a device's major/minor number when the container is created. The previous miscdevice implementation allocated a new dynamic minor whenever PF1 or PF2 was reprobed. After a PCI remove/rescan, the same /dev path could therefore return on the host with a different device number, while the container retained the old device node and device-cgroup permission. Restarting the container was the only way to pass the replacement device through.

The driver now reserves one character-device range for the lifetime of slash.ko and assigns deterministic minors:

  • minor 0: slash_hotplug
  • minor 2*N+1: slash_ctl<N>
  • minor 2*N+2: slash_qdma_ctl<N>

PF1 and PF2 are paired by their board BDF and retain the same N until the module is unloaded. Reprobed devices consequently return with the same /dev path and dev_t, so a device node already present in a container opens the new device instance without recreating the container.

For example, a container can be started once with:

docker run \
  --device=/dev/slash_hotplug \
  --device=/dev/slash_ctl0 \
  --device=/dev/slash_qdma_ctl0 \
  ...

and continue using those paths after a host-side remove/rescan.

Other changes

  • Move SLASH devices from /sys/class/misc to a dedicated /sys/class/slash class.
  • Add safe character-device lifetime handling: an fd opened before removal remains tied to the removed instance and returns ENODEV; it never silently rebinds to the rescanned device.
  • Report the PF1 BDF through SLASH_QDMA_IOCTL_INFO, allowing userspace to verify CTL/QDMA pairing without depending on sysfs naming.
  • Simplify vrtd and v80-smi discovery around the stable slash_ctl<N>/slash_qdma_ctl<N> pairing.
  • Support old and new kernel signatures for class_create() and the class devnode callback.
  • Update the kernel ABI documentation and driver, libslash, vrtd, and v80-smi tests for the new class and device-number layout.

…r number

Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
@amd-vserbu
amd-vserbu requested a review from quetric July 31, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant