The patch titled Subject: usb: forbid memory allocation with I/O during bus reset has been added to the -mm tree. Its filename is usb-forbid-memory-allocation-with-i-o-during-bus-reset.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ming Lei <ming.lei@xxxxxxxxxxxxx> Subject: usb: forbid memory allocation with I/O during bus reset If one storage interface or usb network interface(iSCSI case) exists in current configuration, memory allocation with GFP_KERNEL during usb_device_reset() might trigger I/O transfer on the storage interface itself and cause deadlock because the 'us->dev_mutex' is held in .pre_reset() and the storage interface can't do I/O transfer when the reset is triggered by other interface, or the error handling can't be completed if the reset is triggered by the storage itself (error handling path). Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxxxxx> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: Eric Dumazet <eric.dumazet@xxxxxxxxx> Cc: David Decotigny <david.decotigny@xxxxxxxxxx> Cc: Tom Herbert <therbert@xxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> Cc: Oliver Neukum <oneukum@xxxxxxx> Cc: Jiri Kosina <jiri.kosina@xxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: "Rafael J. Wysocki" <rjw@xxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/usb/core/hub.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff -puN drivers/usb/core/hub.c~usb-forbid-memory-allocation-with-i-o-during-bus-reset drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c~usb-forbid-memory-allocation-with-i-o-during-bus-reset +++ a/drivers/usb/core/hub.c @@ -5144,6 +5144,7 @@ int usb_reset_device(struct usb_device * { int ret; int i; + unsigned int noio_flag; struct usb_host_config *config = udev->actconfig; if (udev->state == USB_STATE_NOTATTACHED || @@ -5153,6 +5154,17 @@ int usb_reset_device(struct usb_device * return -EINVAL; } + /* + * Don't allocate memory with GFP_KERNEL in current + * context to avoid possible deadlock if usb mass + * storage interface or usbnet interface(iSCSI case) + * is included in current configuration. The easist + * approach is to do it for every device reset, + * because the device 'memalloc_noio' flag may have + * not been set before reseting the usb device. + */ + noio_flag = memalloc_noio_save(); + /* Prevent autosuspend during the reset */ usb_autoresume_device(udev); @@ -5197,6 +5209,7 @@ int usb_reset_device(struct usb_device * } usb_autosuspend_device(udev); + memalloc_noio_restore(noio_flag); return ret; } EXPORT_SYMBOL_GPL(usb_reset_device); _ Patches currently in -mm which might be from ming.lei@xxxxxxxxxxxxx are origin.patch linux-next.patch mm-teach-mm-by-current-context-info-to-not-do-i-o-during-memory-allocation.patch pm-runtime-introduce-pm_runtime_set_memalloc_noio.patch block-genhdc-apply-pm_runtime_set_memalloc_noio-on-block-devices.patch net-core-apply-pm_runtime_set_memalloc_noio-on-network-devices.patch pm-runtime-force-memory-allocation-with-no-i-o-during-runtime-pm-callbcack.patch usb-forbid-memory-allocation-with-i-o-during-bus-reset.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html