DriverKit: ReadAsyncIOBundled completion returns error 0xe0005000 (UNDEFINED)

Hello! I'm trying to get data (like audio) stream from custom vendor usb device with bulk endpoint. When I use AsyncIO in cycle some data was lost. And I saw that AsyncIOBundled can help me with this issue. I've trying to use it:

  1. Create memory buffers
    for (int i = 0; i < DEFAULT_BUF_NUMBER; i++) {
        kern_return_t ret = IOBufferMemoryDescriptor::Create(
                                                             kIOMemoryDirectionInOut,
                                                             DEFAULT_BUF_LENGTH,
                                                             0,
                                                             &ivars->buffers[i]
                                                             );
    }
  1. Create MemoryDescriptorRing and set MemoryDescriptor for each index
kern_return_t MyDriver::SetupRingBuffer(IOMemoryDescriptor** memoryDescriptors, uint16_t length)
{
    kern_return_t ret = kIOReturnSuccess;

    ret = ivars->inPipe->CreateMemoryDescriptorRing(length);
    if (ret != kIOReturnSuccess) {
        IOLog("CreateMemoryDescriptorRing failed %s", StringFromReturn(ret));
        return ret;
    }

    for (int i = 0; i < length; i++) {
        ret = ivars->inPipe->SetMemoryDescriptor(memoryDescriptors[i], i);

        if (ret != kIOReturnSuccess) {
            IOLog("SetMemoryDescriptor failed %s", StringFromReturn(ret));
            break;
        }
    }

    return ret;
}
  1. Create completion

  2. Run AsyncIOBundled for only 1 index

ret = ivars->inPipe->AsyncIOBundled(
                                          i,
                                          1,
                                          &transferAccepted,
                                          (const unsigned int *)&ivars->dataBufferLengthArray,
                                          DEFAULT_BUF_NUMBER,
                                          ivars->readBundledCompletion,
                                          0
                                          );

  1. In completion i'm always get the error 0xe0005000 (UNDEFINED)

But if I use AsyncIO with same buffer - it's success.

What am I doing wrong? There are no differences btw AsyncIOBundled and AsyncIO requests in wireshark

DriverKit: ReadAsyncIOBundled completion returns error 0xe0005000 (UNDEFINED)
 
 
Q