Re: [RFC PATCH 2/4] rust: usb: add usb host interface and endpoint abstractions
From: Oliver Neukum
Date: Tue Jul 14 2026 - 14:50:43 EST
On 14.07.26 19:53, Danilo Krummrich wrote:
Many APIs rely on this, as in they only guarantee valid behavior when called
from a scope where the device is guaranteed to be bound to a driver, or IOW
where a driver can prove that it actually operates the device.
Drivers must only acquire device resources when they are actually bound to the
corresponding device, and must hand them back before the device is unbound. The
devres API, for instance, exists for this fundamental reason.
For instance, we can't have drivers manage IRQs, mess with I/O memory, program
IOMMU page tables (e.g. through DMA APIs), etc. for devices they are not bound
to and hence are not allowed to operate (anymore).
Those device resources all have a lifetime that is tied to the lifetime of the
device being bound to a driver.
Understood. Unfortunately this does not map straightforwardly to the USB API.
Usbcore tells a driver via corresponding opeations when IO has to cease
(and other operations should be performed) and when it is allowed again.
Being probed and unbound is merely one of them. Nor does this really
tell you anything about the device driver.
Regards
Oliver