]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pm / runtime: force memory allocation with no I/O during Runtime PM callbcack
authorMing Lei <ming.lei@canonical.com>
Wed, 20 Feb 2013 02:14:35 +0000 (13:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:52:43 +0000 (16:52 +1100)
Apply the introduced memalloc_noio_save() and memalloc_noio_restore() to
force memory allocation with no I/O during runtime_resume/runtime_suspend
callback on device with the flag of 'memalloc_noio' set.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Decotigny <david.decotigny@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Jiri Kosina <jiri.kosina@suse.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/base/power/runtime.c

index cd92e1c77cb72933d54c07bac49a86b240dfaab1..1244930e3d7a4ae73843afb7ecb34c356a5cc72b 100644 (file)
@@ -348,7 +348,24 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev)
        if (!cb)
                return -ENOSYS;
 
-       retval = __rpm_callback(cb, dev);
+       if (dev->power.memalloc_noio) {
+               unsigned int noio_flag;
+
+               /*
+                * Deadlock might be caused if memory allocation with
+                * GFP_KERNEL happens inside runtime_suspend and
+                * runtime_resume callbacks of one block device's
+                * ancestor or the block device itself. Network
+                * device might be thought as part of iSCSI block
+                * device, so network device and its ancestor should
+                * be marked as memalloc_noio too.
+                */
+               noio_flag = memalloc_noio_save();
+               retval = __rpm_callback(cb, dev);
+               memalloc_noio_restore(noio_flag);
+       } else {
+               retval = __rpm_callback(cb, dev);
+       }
 
        dev->power.runtime_error = retval;
        return retval != -EACCES ? retval : -EIO;