fix TinyEnclosure transport

This commit is contained in:
firestar5683
2026-08-01 18:07:21 -05:00
parent 7e9e6c9f67
commit 7de5bdc557
2 changed files with 6 additions and 2 deletions
@@ -220,7 +220,7 @@ class USBPCIDevice(PCIDevice):
def __init__(self, devpref:str, dev, pcibus):
self.pcibus, self.peer_group = pcibus, f"USBPCIDevice_{pcibus}"
self.lock_fd = System.flock_acquire(f"{devpref.lower()}_{pcibus.lower()}.lock")
usb = USB3(dev, 0x81, 0x83, 0x02, 0x04, use_bot=True)
usb = USB3(dev, 0x81, 0x83, 0x02, 0x04)
if DEBUG >= 1: print(f"am {self.pcibus}: product string: {usb.product!r}")
self.usb: CustomASM24Controller | ASM24Controller = CustomASM24Controller(usb) if usb.is_custom else ASM24Controller(usb)
self._bar_info = System.pci_setup_usb_bars(self.usb, gpu_bus=4, mem_base=0x10000000, pref_mem_base=(32 << 30))
@@ -5,6 +5,10 @@ from tinygrad.helpers import DEBUG, DEV, to_mv, round_up, OSX, getenv, ceildiv
from tinygrad.runtime.support.hcq import MMIOInterface
from tinygrad.runtime.support import c
CUSTOM_ASM24_PRODUCT_PREFIXES = ("custom", "USB 3.2 PCIe TinyEnclosure")
def is_custom_asm24_product(product:str) -> bool: return product.startswith(CUSTOM_ASM24_PRODUCT_PREFIXES)
def alloc_cbuffer(sz:int) -> tuple[ctypes.Array, memoryview]: return (buf:=(ctypes.c_ubyte * sz)()), to_mv(ctypes.addressof(buf), sz)
def checked(fn, msg=None):
@functools.wraps(fn)
@@ -63,7 +67,7 @@ class USB3:
checked(libusb.libusb_get_device_descriptor)(libusb.libusb_get_device(self.handle), ctypes.byref(_desc))
_ret = checked(libusb.libusb_get_string_descriptor_ascii)(self.handle, _desc.iProduct, _buf, 256)
self.product = bytes(_buf[:_ret]).decode("ascii", errors="replace")
self.is_custom = self.product.startswith("custom")
self.is_custom = is_custom_asm24_product(self.product)
if self.is_custom: self.use_bot = use_bot = True
# Detach kernel driver if needed