Re: [linux-pm] [RFC][PATCH] PM: Rework disabling of user mode helpers during suspend/hibernation

From: Pavel Machek
Date: Thu Aug 14 2008 - 07:05:43 EST


Hi!

> PM: Rework disabling of user mode helpers during suspend/hibernation
>
> We currently use a PM notifier to disable user mode helpers before
> suspend and hibernation and to re-enable them during the resume.
> However, this is not an ideal solution, because if any drivers want
> to upolad firmware into memory before suspend, they have to use a
> PM notifier for this purpose and there is not guarantee that the
> ordering of PM notifiers will be as expected (ie. the notifier that
> disables user mode helpers has to be run after the driver's notifier
> used for uploading the firmware).
>
> For this reason, it seems better to move the disabling and enabling
> of user mode helpers to separate functions that will be called by the
> PM core as necessary.
>
> Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>

ACK.

> Index: linux-2.6/include/linux/kmod.h
> ===================================================================
> --- linux-2.6.orig/include/linux/kmod.h
> +++ linux-2.6/include/linux/kmod.h
> @@ -99,4 +99,9 @@ struct file;
> extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
> struct file **filp);
>
> +#ifdef CONFIG_PM_SLEEP
> +extern int usermodehelper_disable(void);
> +extern void usermodehelper_enable(void);
> +#endif

No #ifdef needed for prototypes?


> #endif /* __LINUX_KMOD_H__ */
> Index: linux-2.6/kernel/power/main.c
> ===================================================================
> --- linux-2.6.orig/kernel/power/main.c
> +++ linux-2.6/kernel/power/main.c
> @@ -21,6 +21,7 @@
> #include <linux/freezer.h>
> #include <linux/vmstat.h>
> #include <linux/syscalls.h>
> +#include <linux/kmod.h>
>
> #include "power.h"
>
> @@ -236,6 +237,10 @@ static int suspend_prepare(void)
> if (error)
> goto Finish;
>
> + error = usermodehelper_disable();
> + if (error)
> + goto Finish;
> +
> if (suspend_freeze_processes()) {
> error = -EAGAIN;
> goto Thaw;

Could this be moved into suspend_freeze_processes? It is related
(usermode helper is disabled when no userland), and you will not have
to call it from 3 places...?

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/