Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41508
b: refs/heads/master
c: 08c3103
h: refs/heads/master
v: v3
  • Loading branch information
Larry Finger authored and Jeff Garzik committed Dec 2, 2006
1 parent 75c1e66 commit 4059ffe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1494a81410d8c53fa6c800be1e22b6b6f64180e6
refs/heads/master: 08c3103a562ed83c4f9ac8fad6f5cb1ebb1f29a0
41 changes: 7 additions & 34 deletions trunk/drivers/net/wireless/bcm43xx/bcm43xx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3209,55 +3209,27 @@ static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)

static void do_periodic_work(struct bcm43xx_private *bcm)
{
unsigned int state;

state = bcm->periodic_state;
if (state % 8 == 0)
if (bcm->periodic_state % 8 == 0)
bcm43xx_periodic_every120sec(bcm);
if (state % 4 == 0)
if (bcm->periodic_state % 4 == 0)
bcm43xx_periodic_every60sec(bcm);
if (state % 2 == 0)
if (bcm->periodic_state % 2 == 0)
bcm43xx_periodic_every30sec(bcm);
if (state % 1 == 0)
bcm43xx_periodic_every15sec(bcm);
bcm->periodic_state = state + 1;
bcm43xx_periodic_every15sec(bcm);

schedule_delayed_work(&bcm->periodic_work, HZ * 15);
}

/* Estimate a "Badness" value based on the periodic work
* state-machine state. "Badness" is worse (bigger), if the
* periodic work will take longer.
*/
static int estimate_periodic_work_badness(unsigned int state)
{
int badness = 0;

if (state % 8 == 0) /* every 120 sec */
badness += 10;
if (state % 4 == 0) /* every 60 sec */
badness += 5;
if (state % 2 == 0) /* every 30 sec */
badness += 1;
if (state % 1 == 0) /* every 15 sec */
badness += 1;

#define BADNESS_LIMIT 4
return badness;
}

static void bcm43xx_periodic_work_handler(void *d)
{
struct bcm43xx_private *bcm = d;
struct net_device *net_dev = bcm->net_dev;
unsigned long flags;
u32 savedirqs = 0;
int badness;
unsigned long orig_trans_start = 0;

mutex_lock(&bcm->mutex);
badness = estimate_periodic_work_badness(bcm->periodic_state);
if (badness > BADNESS_LIMIT) {
if (unlikely(bcm->periodic_state % 4 == 0)) {
/* Periodic work will take a long time, so we want it to
* be preemtible.
*/
Expand Down Expand Up @@ -3289,7 +3261,7 @@ static void bcm43xx_periodic_work_handler(void *d)

do_periodic_work(bcm);

if (badness > BADNESS_LIMIT) {
if (unlikely(bcm->periodic_state % 4 == 0)) {
spin_lock_irqsave(&bcm->irq_lock, flags);
tasklet_enable(&bcm->isr_tasklet);
bcm43xx_interrupt_enable(bcm, savedirqs);
Expand All @@ -3300,6 +3272,7 @@ static void bcm43xx_periodic_work_handler(void *d)
net_dev->trans_start = orig_trans_start;
}
mmiowb();
bcm->periodic_state++;
spin_unlock_irqrestore(&bcm->irq_lock, flags);
mutex_unlock(&bcm->mutex);
}
Expand Down

0 comments on commit 4059ffe

Please sign in to comment.