From 709babb97c9fa97109d3b35f37e211d77b4556cc Mon Sep 17 00:00:00 2001 From: nimlgen <138685161+nimlgen@users.noreply.github.com> Date: Fri, 17 Jul 2026 00:15:32 +0300 Subject: [PATCH] system: remove sibling functions of PCIDevice (#17052) --- tinygrad/runtime/support/system.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tinygrad/runtime/support/system.py b/tinygrad/runtime/support/system.py index d3eb573ba2..44e5606186 100644 --- a/tinygrad/runtime/support/system.py +++ b/tinygrad/runtime/support/system.py @@ -165,6 +165,10 @@ class PCIDevice: FileIOInterface(f"/sys/bus/pci/devices/{self.pcibus}/driver/unbind", os.O_WRONLY).write(self.pcibus) if FileIOInterface.exists(f"/sys/bus/pci/devices/{self.pcibus}/driver"): raise RuntimeError(f"Driver is bound to {pcibus}") + # remove sibling functions of the gpu, if any + for fn in range(1, 8): + if FileIOInterface.exists(sib:=f"/sys/bus/pci/devices/{self.pcibus[:-1]}{fn}"): FileIOInterface(f"{sib}/remove", os.O_WRONLY).write("1") + if getenv("VFIO", 0) and (vfio_fd:=System.vfio) is not None: FileIOInterface(f"/sys/bus/pci/devices/{self.pcibus}/driver_override", os.O_WRONLY).write("vfio-pci") FileIOInterface("/sys/bus/pci/drivers_probe", os.O_WRONLY).write(self.pcibus)