aboutsummaryrefslogtreecommitdiff
path: root/driver/gator_events_net.c
diff options
context:
space:
mode:
authorDrew Richardson <drew.richardson@arm.com>2012-07-31 12:00:00 -0700
committerDrew Richardson <drew.richardson@arm.com>2014-12-19 15:29:29 -0800
commit5f9955b9c65967a7a62f7860295d8ac187c9ec11 (patch)
treef5c3a2b6025bf9f3e436b8de9ae9f67131fe854d /driver/gator_events_net.c
parent3abe11d177c6c93fab66d04fd42d11452a0c508e (diff)
downloadgator-5f9955b9c65967a7a62f7860295d8ac187c9ec11.tar.gz
gator: Version 5.115.11
Signed-off-by: Drew Richardson <drew.richardson@arm.com>
Diffstat (limited to 'driver/gator_events_net.c')
-rw-r--r--driver/gator_events_net.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/driver/gator_events_net.c b/driver/gator_events_net.c
index 9298905..11282b5 100644
--- a/driver/gator_events_net.c
+++ b/driver/gator_events_net.c
@@ -23,6 +23,9 @@ static int rx_total, tx_total;
static ulong netPrev[TOTALNET];
static int netGet[TOTALNET * 4];
+static struct timer_list net_wake_up_timer;
+
+// Must be run in process context as the kernel function dev_get_stats() can sleep
static void get_network_stats(struct work_struct *wsptr) {
int rx = 0, tx = 0;
struct net_device *dev;
@@ -42,6 +45,12 @@ static void get_network_stats(struct work_struct *wsptr) {
}
DECLARE_WORK(wq_get_stats, get_network_stats);
+static void net_wake_up_handler(unsigned long unused_data)
+{
+ // had to delay scheduling work as attempting to schedule work during the context switch is illegal in kernel versions 3.5 and greater
+ schedule_work(&wq_get_stats);
+}
+
static void calculate_delta(int *rx, int *tx)
{
int rx_calc, tx_calc;
@@ -83,14 +92,16 @@ static int gator_events_net_create_files(struct super_block *sb, struct dentry *
static int gator_events_net_start(void)
{
- get_network_stats(NULL);
+ get_network_stats(0);
netPrev[NETRX] = rx_total;
netPrev[NETTX] = tx_total;
+ setup_timer(&net_wake_up_timer, net_wake_up_handler, 0);
return 0;
}
static void gator_events_net_stop(void)
{
+ del_timer_sync(&net_wake_up_timer);
netrx_enabled = 0;
nettx_enabled = 0;
}
@@ -106,11 +117,7 @@ static int gator_events_net_read(int **buffer)
if (!netrx_enabled && !nettx_enabled)
return 0;
- if (in_interrupt()){
- schedule_work(&wq_get_stats);
- } else {
- get_network_stats(NULL);
- }
+ mod_timer(&net_wake_up_timer, jiffies + 1);
calculate_delta(&rx_delta, &tx_delta);