The detach(9E) routine must not return DDI_SUCCESS while it has callback functions pending. This is critical only for callbacks registered for device instances that are not currently open, since the DDI_DETACH case is not entered if the device is open.
There are two types of callback routines of interest: callbacks that can be canceled, and callbacks that must run to completion. Callbacks that can be canceled do not pose a problem; the driver should cancel the callback before detach(9E) returns DDI_SUCCESS. Each of the callback cancellation routines in Table 5-2 atomically cancels callbacks so that a callback routine does not run while it is being canceled.
Table 5-2 Example of Functions With Cancelable Callbacks
Function |
Canceling Function |
---|---|
timeout(9F) |
untimeout(9F) |
bufcall(9F) |
unbufcall(9F) |
esbbcall(9F) |
unbufcall(9F) |
Some callbacks cannot be canceled--for these it is necessary to wait until the callback has been called. In some cases, such as ddi_dma_buf_bind_handle(9F), the callback must also be prevented from rescheduling itself. See "Canceling DMA Callbacks" for an example.
Following is a list of some functions that may establish callbacks that cannot be canceled:
esballoc(9F)
ddi_dma_addr_bind_handle(9F)
ddi_dma_buf_bind_handle(9F)
scsi_init_pkt(9F)