From 3e005ca0c2f147a99b28cb744970989f7a6492fd Mon Sep 17 00:00:00 2001 From: nimlgen <138685161+nimlgen@users.noreply.github.com> Date: Mon, 10 Feb 2025 16:48:44 +0300 Subject: [PATCH] am: resize bar0 to max supported (#9006) --- tinygrad/runtime/ops_amd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tinygrad/runtime/ops_amd.py b/tinygrad/runtime/ops_amd.py index 7171883e9b..7f6606d4d1 100644 --- a/tinygrad/runtime/ops_amd.py +++ b/tinygrad/runtime/ops_amd.py @@ -446,7 +446,9 @@ class PCIIface: # Unbind the device from the kernel driver if HWInterface.exists(f"/sys/bus/pci/devices/{self.pcibus}/driver"): HWInterface(f"/sys/bus/pci/devices/{self.pcibus}/driver/unbind", os.O_WRONLY).write(self.pcibus) - HWInterface(f"/sys/bus/pci/devices/{self.pcibus}/resource0_resize", os.O_RDWR).write("15") + + supported_sizes = int(HWInterface(f"/sys/bus/pci/devices/{self.pcibus}/resource0_resize", os.O_RDONLY).read(), 16) + HWInterface(f"/sys/bus/pci/devices/{self.pcibus}/resource0_resize", os.O_RDWR).write(str(supported_sizes.bit_length() - 1)) # Try to init vfio. Use it if success. if PCIIface.vfio: