Author: Nigel CunninghamDate: 2008-07-25 12:57 UTC To: TuxOnIce users' listSubject: Re: [TuxOnIce-users] latest git and user_ui
Hi.
I've started work on some new debugging code for userui.
Here's a patch that should apply (maybe with some fuzz) against a recent
release (I've prepared it against current head git). It may give you
some debugging info in dmesg that might help. To use it, echo 1 to the
new /sys/power/tuxonice/user_interface/debug entry. Dmesg will then
record the message numbers that are sent and received. That should at
least give some idea of how far we're getting.
I've started modifications to userui too, but they're not ready to be
sent yet. I'll be out for most of tomorrow, but may be able to send you
something in about 18-24 hours.
Nigel
tuxonice.h | 2 +-
tuxonice_highlevel.c | 15 ++++++++++-----
tuxonice_netlink.c | 21 +++++++++++++++++----
tuxonice_netlink.h | 3 ++-
tuxonice_userui.c | 5 +++++
5 files changed, 35 insertions(+), 11 deletions(-)
diff -ruNp 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice.h 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice.h
--- 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice.h 2008-07-25 21:09:18.000000000 +1000
+++ 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice.h 2008-07-25 18:46:56.000000000 +1000
@@ -205,7 +205,7 @@ extern int pre_resume_freeze(void);
extern int do_check_can_resume(void);
extern int do_toi_step(int step);
extern int toi_launch_userspace_program(char *command, int channel_no,
- enum umh_wait wait);
+ enum umh_wait wait, int debug);
extern char *tuxonice_signature;
#endif
diff -ruNp 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_highlevel.c 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_highlevel.c
--- 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_highlevel.c 2008-07-25 21:09:18.000000000 +1000
+++ 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_highlevel.c 2008-07-25 18:46:50.000000000 +1000
@@ -127,7 +127,7 @@ void toi_finish_anything(int hibernate_o
if (hibernate_or_resume == SYSFS_HIBERNATE &&
strlen(post_hibernate_command))
toi_launch_userspace_program(post_hibernate_command,
- 0, UMH_WAIT_PROC);
+ 0, UMH_WAIT_PROC, 0);
}
set_fs(oldfs);
@@ -153,7 +153,7 @@ int toi_start_anything(int hibernate_or_
if (hibernate_or_resume == SYSFS_HIBERNATE &&
strlen(pre_hibernate_command)) {
int result = toi_launch_userspace_program(pre_hibernate_command,
- 0, UMH_WAIT_PROC);
+ 0, UMH_WAIT_PROC, 0);
if (result) {
printk(KERN_INFO "Pre-hibernate command '%s' returned "
"%d. Aborting.\n",
@@ -1066,7 +1066,7 @@ out:
* channel_no: If !0, -c <channel_no> is added to args (userui).
*/
int toi_launch_userspace_program(char *command, int channel_no,
- enum umh_wait wait)
+ enum umh_wait wait, int debug)
{
int retval;
static char *envp[] = {
@@ -1093,8 +1093,8 @@ int toi_launch_userspace_program(char *c
}
}
- /* Up to 7 args supported */
- while (arg < 7) {
+ /* Up to 6 args supported */
+ while (arg < 6) {
sscanf(orig_posn, "%s", test_read);
size = strlen(test_read);
if (!(size))
@@ -1112,6 +1112,11 @@ int toi_launch_userspace_program(char *c
} else
arg--;
+ if (debug) {
+ argv[++arg] = toi_kzalloc(5, 8, TOI_ATOMIC_GFP);
+ strcpy(argv[arg], "--debug");
+ }
+
retval = call_usermodehelper(argv[0], argv, envp, wait);
/*
diff -ruNp 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_netlink.c 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_netlink.c
--- 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_netlink.c 2008-07-25 21:09:18.000000000 +1000
+++ 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_netlink.c 2008-07-25 18:39:59.000000000 +1000
@@ -78,6 +78,10 @@ void toi_send_netlink_message(struct use
if (uhd->pid == -1)
return;
+ if (uhd->debug)
+ printk(KERN_ERR "toi_send_netlink_message: Send "
+ "message type %d.\n", type);
+
skb = toi_get_skb(uhd);
if (!skb) {
printk(KERN_INFO "toi_netlink: Can't allocate skb!\n");
@@ -113,6 +117,10 @@ void toi_send_netlink_message(struct use
nlmsg_failure:
if (skb)
put_skb(uhd, skb);
+
+ if (uhd->debug)
+ printk(KERN_ERR "toi_send_netlink_message: Failed to send "
+ "message type %d.\n", type);
}
EXPORT_SYMBOL_GPL(toi_send_netlink_message);
@@ -132,6 +140,9 @@ static int nl_set_nofreeze(struct user_h
{
struct task_struct *t;
+ if (uhd->debug)
+ printk(KERN_ERR "nl_set_nofreeze for pid %d.\n", pid);
+
read_lock(&tasklist_lock);
t = find_task_by_pid(pid);
if (!t) {
@@ -190,18 +201,20 @@ EXPORT_SYMBOL_GPL(toi_netlink_close_comp
static int toi_nl_gen_rcv_msg(struct user_helper_data *uhd,
struct sk_buff *skb, struct nlmsghdr *nlh)
{
- int type;
+ int type = nlh->nlmsg_type;
int *data;
int err;
+ if (uhd->debug)
+ printk(KERN_ERR "toi_user_rcv_skb: Received message %d.\n",
+ type);
+
/* Let the more specific handler go first. It returns
* 1 for valid messages that it doesn't know. */
err = uhd->rcv_msg(skb, nlh);
if (err != 1)
return err;
- type = nlh->nlmsg_type;
-
/* Only allow one task to receive NOFREEZE privileges */
if (type == NETLINK_MSG_NOFREEZE_ME && uhd->pid != -1) {
printk("Received extra nofreeze me requests.\n");
@@ -306,7 +319,7 @@ int toi_netlink_setup(struct user_helper
}
if (toi_launch_userspace_program(uhd->program, uhd->netlink_id,
- UMH_WAIT_EXEC) < 0) {
+ UMH_WAIT_EXEC, uhd->debug) < 0) {
printk(KERN_INFO "Launch userspace program failed.\n");
toi_netlink_close_complete(uhd);
return 1;
diff -ruNp 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_netlink.h 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_netlink.h
--- 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_netlink.h 2008-07-25 21:09:18.000000000 +1000
+++ 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_netlink.h 2008-07-25 16:40:13.000000000 +1000
@@ -37,8 +37,9 @@ struct user_helper_data {
char *name;
struct user_helper_data *next;
struct completion wait_for_process;
- int interface_version;
+ unsigned int interface_version;
int must_init;
+ int debug;
};
#ifdef CONFIG_NET
diff -ruNp 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_userui.c 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_userui.c
--- 903-debug-arg-for-userui.patch-old/kernel/power/tuxonice_userui.c 2008-07-25 21:09:18.000000000 +1000
+++ 903-debug-arg-for-userui.patch-new/kernel/power/tuxonice_userui.c 2008-07-25 16:35:14.000000000 +1000
@@ -595,6 +595,11 @@ static struct toi_sysfs_data sysfs_param
SYSFS_STRING(ui_helper_data.program, 255, 0),
.write_side_effect = set_ui_program_set,
},
+
+ { TOI_ATTR("debug", SYSFS_RW),
+ SYSFS_INT(&ui_helper_data.debug, 0, 1, 0)
+ },
+
#endif
};