DriverKit CompleteAsyncIO callback

I'm trying to make an asynchronous bulk data read using AsyncIO/CompleteAsyncIO. The problem I'm facing is that the AsyncIO succeeds but CompleteAsyncIO/ReadComplete doesn't get called when the AsyncIO's completion timeout is set to 0.

Changing the completion timeout to a non-zero would trigger ReadComplete but I keep getting the (0x2d6) "I/O Timeout" error

Any idea what I'm doing wrong? Also, is there any limit for the maximum buffer length the callback can accept?

Thanks.

struct MyDriver_IVars {
    OSAction* callbackAction = nullptr;     // registered callback action by app
    IOUSBHostInterface* interface;
    IOUSBHostPipe* pipe;
    IOBufferMemoryDescriptor* inDataBuffer;
    OSAction* ioCompleteCallback = nullptr; // read complete callback action
    uint32_t MAX_LENGTH = 1024;
};

kern_return_t IMPL(MyDriver, Start){
//...........
ret = ivars->interface->CopyPipe(endpoint->bEndpointAddress, &ivars->pipe);
ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionInOut, ivars->MAX_LENGTH, &ivars->inDataBuffer);
ret = CreateActionReadComplete(ivars->MAX_LENGTH, &ivars->ioCompleteCallback);
//...........
}

kern_return_t MyDriver::ReadData(int nbytes, int timeout)
{
//...........
    kern_return_t ret = ivars->pipe->AsyncIO(ivars->inDataBuffer, ivars->MAX_LENGTH, ivars->ioCompleteCallback, 0);
//...........
}


void IMPL(MyDriver, ReadComplete)
{
Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount);

    //AsyncCompletion(ivars->callbackAction, ..................

}
    virtual void ReadComplete(OSAction* action, IOReturn status, uint32_t actualByteCount, uint64_t completionTimestamp) TYPE(IOUSBHostPipe::CompleteAsyncIO);

A timeout value of 0 means "never" (https://developer.apple.com/documentation/usbdriverkit/iousbhostpipe/3182647-asyncio). Your request is either never being delivered to the bus, or is being ignored by your device.

In circumstances like these, I like to hang a USB analyzer on the bus to see what the device is actually doing. Also check all the return values from your calls.

DriverKit CompleteAsyncIO callback
 
 
Q