Skip to contentSkip to conversation

block: Remove deadlock in disk_clear_events

PATCH Applied Derek Basehore 2 participants 2 messages Oct 11, 2012 – Oct 12, 2012 Block layer

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: Remove deadlock in disk_clear_events

In disk_clear_events, do not put work on system_nrt_freezable_wq. Instead, put it on system_nrt_wq.

There is a race between probing a usb and suspending the device. Since probing a usb calls disk_clear_events, which puts work on a frozen workqueue, probing cannot finish after the workqueue is frozen. However, suspending cannot finish until the usb probe is finished, so we get a deadlock.

Change-Id I05bc8f608f1c86b7efaca5c12e544dbd08dfaba4
---
 block/genhd.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
block/genhd.c +7 -1
index 6cace66..4e700ee 100644
@@ -1571,7 +1571,13 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
 
 	/* uncondtionally schedule event check and wait for it to finish */
 	disk_block_events(disk);
-	queue_delayed_work(system_freezable_wq, &ev->dwork, 0);
+	/* We need to put the work on system_nrt_wq here since there is a
+	 * deadlock that happens while probing a usb device while suspending. If
+	 * we put work on a freezable worqueue here, a usb probe will wait here
+	 * until the workqueue is unfrozen during suspend. Since suspend waits
+	 * on all probes to complete, we have a deadlock
+	 */
+	queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
 	flush_delayed_work(&ev->dwork);
 	__disk_unblock_events(disk, false);
 
Signature · 1 line
1.7.7.3
maintainer Applied
#1 lore raw
Quoted 7 lines · Derek Basehore

In disk_clear_events, do not put work on system_nrt_freezable_wq. Instead, put it on system_nrt_wq.

There is a race between probing a usb and suspending the device. Since probing a usb calls disk_clear_events, which puts work on a frozen workqueue, probing cannot finish after the workqueue is frozen. However, suspending cannot finish until the usb probe is finished, so we get a deadlock.

Thanks, applied to later inclusion into 3.7. You did not mark this as stable, though it seems it should be?

Signature · 1 line
Jens Axboe