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>
 /*
  * Local variables
  */
-static DEFINE_MUTEX(apm_mutex);
 static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
 static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
 static int apm_disabled;
        if (!as->suser || !as->writer)
                return -EPERM;
 
-       mutex_lock(&apm_mutex);
        switch (cmd) {
        case APM_IOC_SUSPEND:
                mutex_lock(&state_lock);
                mutex_unlock(&state_lock);
                break;
        }
-       mutex_unlock(&apm_mutex);
 
        return err;
 }
 {
        struct apm_user *as;
 
-       mutex_lock(&apm_mutex);
        as = kzalloc(sizeof(*as), GFP_KERNEL);
        if (as) {
                /*
 
                filp->private_data = as;
        }
-       mutex_unlock(&apm_mutex);
 
        return as ? 0 : -ENOMEM;
 }