On Wed, Oct 10, 2012 at 4:39 PM, Oliver Neukum [off-list ref] wrote:
On Wednesday 10 October 2012 16:17:25 Ming Lei wrote:
quoted
On Wed, Oct 10, 2012 at 1:51 PM, Oliver Neukum [off-list ref] wrote:
quoted
quoted
We need to use GFP_NOIO in situations the helper cannot know about.
Please add a gfp_t parameter. Then the caller will solve that.
Considered that most of drivers call the helpers in different context, I think
it is better to switch the gpf_t flag runtime inside helpers, like below:
if (dev->power.runtime_status == RPM_RESUMING)
gfp = GFP_NOIO;
else
gfp = GFP_KERNEL;
You are admirably persistent ;-)
I am only trying to solve the problem more generally, :-)
If you extended the check to RPM_SUSPENDING it might work,
but still the problem with error handling exists.
Could you describe the error handling case in a bit detail so
that callers of these helpers can know when GFP_KERNEL
is to be passed and when GFP_NOIO is taken if the gfp
patamerer has to be added?
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wednesday 10 October 2012 17:48:54 Ming Lei wrote:
On Wed, Oct 10, 2012 at 4:39 PM, Oliver Neukum [off-list ref] wrote:
quoted
On Wednesday 10 October 2012 16:17:25 Ming Lei wrote:
quoted
On Wed, Oct 10, 2012 at 1:51 PM, Oliver Neukum [off-list ref] wrote:
quoted
quoted
We need to use GFP_NOIO in situations the helper cannot know about.
Please add a gfp_t parameter. Then the caller will solve that.
Considered that most of drivers call the helpers in different context, I think
it is better to switch the gpf_t flag runtime inside helpers, like below:
if (dev->power.runtime_status == RPM_RESUMING)
gfp = GFP_NOIO;
else
gfp = GFP_KERNEL;
You are admirably persistent ;-)
I am only trying to solve the problem more generally, :-)
The most generic solution is passing the parameter.
quoted
If you extended the check to RPM_SUSPENDING it might work,
but still the problem with error handling exists.
Could you describe the error handling case in a bit detail so
that callers of these helpers can know when GFP_KERNEL
is to be passed and when GFP_NOIO is taken if the gfp
patamerer has to be added?
A reset always applies to the whole device. Resets are used in error
handling of block devices (storage and uas). If you reset a device,
pre_reset() and post_reset() of all interfaces need to be called. So they
are part of the SCSI error handler. SCSI error handlers can allocate memory
only with GFP_NOIO (or GFP_ATOMIC) because any IO for paging
can cause the SCSI layer to wait for the error handling to finish. The error
handling can only finish when pre/post_reset() have finished. Catch-22
So any control messages in block error handling need to use GFP_NOIO.
If you look at the control message helpers in usbcore you will find a lot
of GFP_NOIO. That is the reason.
Regards
Oliver
On Wed, Oct 10, 2012 at 6:08 PM, Oliver Neukum [off-list ref] wrote:
A reset always applies to the whole device. Resets are used in error
handling of block devices (storage and uas). If you reset a device,
pre_reset() and post_reset() of all interfaces need to be called. So they
are part of the SCSI error handler. SCSI error handlers can allocate memory
only with GFP_NOIO (or GFP_ATOMIC) because any IO for paging
can cause the SCSI layer to wait for the error handling to finish. The error
handling can only finish when pre/post_reset() have finished. Catch-22
IMO, it is not practical to obey the rule for drivers, because driver may
call many other kernel component API which may allocate memory
via GFP_KERNEL in the path easily.
Same with runtime PM case.
So any control messages in block error handling need to use GFP_NOIO.
If you look at the control message helpers in usbcore you will find a lot
of GFP_NOIO. That is the reason.
If one driver has no .pre_reset or .post_reset, usb_reset_device() will
try to unbind&bind the interface, so you mean these usb drivers have
to use GFP_NOIO to allocate memory in its probe() and disconnect()?
Unfortunately, that is not true, and no way to make sure all memory
allocations in the path via GFP_NOIO, IMO.
Also, only very few drivers have implemented .pre_reset and .post_reset.
Thanks,
--
Ming Lei