Modify

Opened 10 years ago

Closed 6 years ago

#2774 closed defect (obsolete)

hotplug button event, $SEEN

Reported by: michu-at-neophobdotcom Owned by: nbd
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: Cc:

Description

I'm using atheros 2.6 latest svn version and want to use a wifitoggler. I created a debug file /etc/hotplug.d/button/10-wifitoggle with this content:

#!/bin/sh

. /lib/config/uci.sh
. /etc/functions.sh

config_load "wifitoggle"
local section="cfg1"
config_get "BUTTON_NAME" "$section" "button"

echo action: "$ACTION" >> /tmp/meep
echo Seen: "$SEEN" >> /tmp/meep
echo JIFFIES: "$JIFFIES" >> /tmp/meep
echo seenX: "$SEENX" >> /tmp/meep

as you see I added 2 additional variables (JIFFIES and seenX), I edited the file /target/linux/atheros/files/arch/mips/atheros/reset.c, here is the patch:

Index: reset.c
===================================================================
--- reset.c     (revision 9632)
+++ reset.c     (working copy)
@@ -15,14 +15,14 @@
 struct event_t {
        struct work_struct wq;
        int set;
-       long int jiffies;
+       unsigned long jiffies;
 };

 static struct ar531x_boarddata *bcfg;

 extern struct sock *uevent_sock;
 extern u64 uevent_next_seqnum(void);
-static int seen;
+static unsigned long seen;

 static inline void add_msg(struct sk_buff *skb, char *msg)
 {
@@ -62,9 +62,18 @@
        add_msg(skb, (event->set ? "ACTION=pressed" : "ACTION=released"));
        sprintf(buf, "SEEN=%ld", (event->jiffies - seen)/HZ);
        add_msg(skb, buf);
+
+       sprintf(buf, "HZ=%d", HZ);
+       add_msg(skb, buf);
+       sprintf(buf, "JIFFIES=%ld", jiffies);
+       add_msg(skb, buf);
+       sprintf(buf, "SEENX=%d", seen);
+       add_msg(skb, buf);
+
+
        snprintf(buf, 128, "SEQNUM=%llu", uevent_next_seqnum());
        add_msg(skb, buf);
-
+
        NETLINK_CB(skb).dst_group = 1;
        netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);

when I press the reset button, this is written to the debug file:

action: pressed
Seen: 0
JIFFIES: 945
seenX: 944
action: pressed
Seen: 0
JIFFIES: 1194
seenX: 1194
action: pressed
Seen: 0
JIFFIES: 1196
seenX: 1195
action: pressed
Seen: 0
JIFFIES: 1196
seenX: 1195
action: released
Seen: 0
JIFFIES: 1300
seenX: 1300
action: pressed
Seen: 0
JIFFIES: 1446
seenX: 1446
action: pressed
Seen: 0
JIFFIES: 1448
seenX: 1446
action: pressed
Seen: 0
JIFFIES: 1448
seenX: 1446

SEEN is almost ever 0, it is calculated as "seen = (jiffies - seen)/HZ". HZ is 100 and jiffies and seen differs max by 1 or 2 so i ask myself, is this calculation correct?

I saw it once when it was not zero:

action: pressed
Seen: 42949672
JIFFIES: -710
seenX: -710

here are the questions:
1) what is the exact purpose of the SEEN variable
2) is it ok that on the atheros platform the variables "seen" and "jiffies" are SIGNED while on the broadcom platform those variables are unsigned?
3) is the SEEN calculation right?

michu

Attachments (0)

Change History (4)

comment:1 Changed 10 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

added in r9721

comment:2 Changed 7 years ago by icarus75 <bart.vandermeerssche@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

min/max settings for button release events in ar231x still do not work as expected in 2.6.30.10. Adding some tracing to reset.c shows that $SEEN returns 0, even when the reset button is pressed for a prolonged period. The patch below produces correct behaviour:

--- /tmp/build_dir/linux-atheros/linux-2.6.30.10/arch/mips/ar231x/reset.c	2010-08-29 22:43:02.508208080 +0200
+++ build_dir/linux-atheros/linux-2.6.30.10/arch/mips/ar231x/reset.c	2010-08-30 10:02:11.682269327 +0200
@@ -19,6 +19,7 @@
 	struct work_struct wq;
 	int set;
 	unsigned long jiffies;
+	unsigned long jiffies_prev;
 };
 
 static struct timer_list rst_button_timer;
@@ -68,7 +69,7 @@
 	add_msg(skb, "SUBSYSTEM=button");
 	add_msg(skb, "BUTTON=reset");
 	add_msg(skb, (event->set ? "ACTION=pressed" : "ACTION=released"));
-	sprintf(buf, "SEEN=%ld", (event->jiffies - seen)/HZ);
+	sprintf(buf, "SEEN=%lu", (event->jiffies - event->jiffies_prev)/HZ);
 	add_msg(skb, buf);
 	snprintf(buf, 128, "SEQNUM=%llu", uevent_next_seqnum());
 	add_msg(skb, buf);
@@ -127,6 +128,7 @@
 		no_release_workaround = 0;
 
 	event->jiffies = jiffies;
+	event->jiffies_prev = seen;
 
 	INIT_WORK(&event->wq, hotplug_button);
 	schedule_work(&event->wq);

Here's a trace with the patch enabled:

Aug 30 07:52:21 OpenWrt user.notice root: action:pressed
Aug 30 07:52:21 OpenWrt user.notice root: jiffies_prev:391667
Aug 30 07:52:21 OpenWrt user.notice root: jiffies:392526
Aug 30 07:52:21 OpenWrt user.notice root: hz:100
Aug 30 07:52:21 OpenWrt user.notice root: seen:8
Aug 30 07:52:36 OpenWrt user.notice root: action:released
Aug 30 07:52:36 OpenWrt user.notice root: jiffies_prev:392526
Aug 30 07:52:36 OpenWrt user.notice root: jiffies:394004
Aug 30 07:52:36 OpenWrt user.notice root: hz:100
Aug 30 07:52:36 OpenWrt user.notice root: seen:14

comment:3 Changed 7 years ago by jow

  • Owner changed from developers to nbd
  • Status changed from reopened to assigned
  • Version set to Trunk

comment:4 Changed 6 years ago by nbd

  • Resolution set to obsolete
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.