Commit fda5fe19725edd6805f2fd742235d1a0d0ba93f5

Authored by Paul Parsons
Committed by Jiri Kosina
1 parent 81024fc41a

apm-emulation: apm_mutex breaks ACK; remove it

apm_mutex is locked by a process (e.g. apm -s) at the start of apm_ioctl() and
remains locked while pm_suspend() is called. Any subsequent process trying to
ACK the suspend (e.g. apmd) is then blocked at the start of apm_ioctl(),
causing the suspend to be delayed for 5 seconds in apm_suspend_notifier()
while the ACK times out. In short, ACKs don't work.

The driver's data structures are sufficiently protected by assorted locks. And
pm_suspend() has its own mutex to prevent reentrancy. Consequently there is no
obvious requirement for apm_mutex, which evolved from earlier BKL calls. So
let's remove it.

Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Showing 1 changed file with 0 additions and 5 deletions Side-by-side Diff

drivers/char/apm-emulation.c
... ... @@ -126,7 +126,6 @@
126 126 /*
127 127 * Local variables
128 128 */
129   -static DEFINE_MUTEX(apm_mutex);
130 129 static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
131 130 static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
132 131 static int apm_disabled;
... ... @@ -275,7 +274,6 @@
275 274 if (!as->suser || !as->writer)
276 275 return -EPERM;
277 276  
278   - mutex_lock(&apm_mutex);
279 277 switch (cmd) {
280 278 case APM_IOC_SUSPEND:
281 279 mutex_lock(&state_lock);
... ... @@ -336,7 +334,6 @@
336 334 mutex_unlock(&state_lock);
337 335 break;
338 336 }
339   - mutex_unlock(&apm_mutex);
340 337  
341 338 return err;
342 339 }
... ... @@ -371,7 +368,6 @@
371 368 {
372 369 struct apm_user *as;
373 370  
374   - mutex_lock(&apm_mutex);
375 371 as = kzalloc(sizeof(*as), GFP_KERNEL);
376 372 if (as) {
377 373 /*
... ... @@ -391,7 +387,6 @@
391 387  
392 388 filp->private_data = as;
393 389 }
394   - mutex_unlock(&apm_mutex);
395 390  
396 391 return as ? 0 : -ENOMEM;
397 392 }