c++ – DriverKit USB driver (dext) course of does not terminate after gadget is unplugged


I am engaged on a USB driver utilizing DriverKit for macOS (later iPadOS as nicely). The motive force matches, hundreds, and is ready to talk with my gadget. Nonetheless, I’ve seen that once I unplug the gadget, the motive force course of continues to be operating (as seen in Exercise Monitor). If I plug it again in once more, a second course of begins up (and a 3rd, and fourth, and so forth). I’ve applied the Cease() technique like so:

kern_return_t
IMPL(MyDriver, Cease)
{
    kern_return_t ret = kIOReturnSuccess;

    os_log(OS_LOG_DEFAULT, "Stopping");
    ret = ivars->device->Shut(this, 0);
    if (ret != kIOReturnSuccess) {
        os_log(OS_LOG_DEFAULT, "Error closing gadget: 0xpercent08x", ret);
    }
    
    ret = Cease(supplier, SUPERDISPATCH);
    if (ret != kIOReturnSuccess) {
        os_log(OS_LOG_DEFAULT, "Error closing gadget: 0xpercent08x", ret);
    }
    
    os_log(OS_LOG_DEFAULT, "Cease completed.");

    return ret;
}

I’ve confirmed that the Cease technique is certainly being known as, and the return worth is kIOReturnSuccess. My driver class’s free() technique can be being known as. May also be price noting that no shopper app is speaking with the motive force (have not gotten that far but).

Is there one thing else I must do to inform the system it is OK to cease operating the motive force course of? Is it regular for it to not terminate?

Leave a Reply