Re: [RFC PATCH 2/9] rust: usb: add synchronous control transfer support
From: Oliver Neukum
Date: Mon Jun 22 2026 - 05:54:50 EST
On 17.06.26 16:59, Mike Lothian wrote:
+ to_result(unsafe {
+ bindings::usb_control_msg_send(
+ self.as_raw(),
+ 0,
+ request,
+ request_type,
+ value,
+ index,
+ data.as_ptr().cast::<kernel::ffi::c_void>(),
+ data.len().try_into()?,
+ timeout.as_millis().try_into()?,
+ bindings::GFP_KERNEL,
No, you cannot do this. You cannot just blindly resort to GFP_KERNEL.
These parameters exist for a reason.
Basically USB devices share error handling among the drivers for
all interfaces. That means that all drivers for the purpose of
error handling (and power management) are block drivers.
As such they are restricted in how they can allocate memory. In particular
you cannot do paging. That means that a USB driver must be able
to specify whether GFP_KERNEL, GFP_NOIO or GFP_NOFS are to be passed
to the USB layer.
You must include them in the API exposed to drivers.
Regards
Oliver