Commit d08749ea authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by David S. Miller

net: sunbmac: Replace in_interrupt() usage

bigmac_init_rings() has an argument signaling if it is called from the
interrupt handler. This is used to decide between GFP_KERNEL and GFP_ATOMIC
for memory allocations.

But it also checks in_interrupt() to handle invocations which come from the
timer callback bigmac_timer() via bigmac_hw_init(), which is invoked with
'in_irq = 0'. While the timer callback is clearly not in hard interrupt
context it is still not sleepable context.

Rename the argument to `non_blocking' and set it to true if invoked from
the timer callback or the interrupt handler which allows to remove the
in_interrupt() check and makes the code consistent.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent caa241f0
...@@ -209,13 +209,13 @@ static void bigmac_clean_rings(struct bigmac *bp) ...@@ -209,13 +209,13 @@ static void bigmac_clean_rings(struct bigmac *bp)
} }
} }
static void bigmac_init_rings(struct bigmac *bp, int from_irq) static void bigmac_init_rings(struct bigmac *bp, bool non_blocking)
{ {
struct bmac_init_block *bb = bp->bmac_block; struct bmac_init_block *bb = bp->bmac_block;
int i; int i;
gfp_t gfp_flags = GFP_KERNEL; gfp_t gfp_flags = GFP_KERNEL;
if (from_irq || in_interrupt()) if (non_blocking)
gfp_flags = GFP_ATOMIC; gfp_flags = GFP_ATOMIC;
bp->rx_new = bp->rx_old = bp->tx_new = bp->tx_old = 0; bp->rx_new = bp->rx_old = bp->tx_new = bp->tx_old = 0;
...@@ -489,7 +489,7 @@ static void bigmac_tcvr_init(struct bigmac *bp) ...@@ -489,7 +489,7 @@ static void bigmac_tcvr_init(struct bigmac *bp)
} }
} }
static int bigmac_init_hw(struct bigmac *, int); static int bigmac_init_hw(struct bigmac *, bool);
static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) static int try_next_permutation(struct bigmac *bp, void __iomem *tregs)
{ {
...@@ -549,7 +549,7 @@ static void bigmac_timer(struct timer_list *t) ...@@ -549,7 +549,7 @@ static void bigmac_timer(struct timer_list *t)
if (ret == -1) { if (ret == -1) {
printk(KERN_ERR "%s: Link down, cable problem?\n", printk(KERN_ERR "%s: Link down, cable problem?\n",
bp->dev->name); bp->dev->name);
ret = bigmac_init_hw(bp, 0); ret = bigmac_init_hw(bp, true);
if (ret) { if (ret) {
printk(KERN_ERR "%s: Error, cannot re-init the " printk(KERN_ERR "%s: Error, cannot re-init the "
"BigMAC.\n", bp->dev->name); "BigMAC.\n", bp->dev->name);
...@@ -617,7 +617,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp) ...@@ -617,7 +617,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp)
add_timer(&bp->bigmac_timer); add_timer(&bp->bigmac_timer);
} }
static int bigmac_init_hw(struct bigmac *bp, int from_irq) static int bigmac_init_hw(struct bigmac *bp, bool non_blocking)
{ {
void __iomem *gregs = bp->gregs; void __iomem *gregs = bp->gregs;
void __iomem *cregs = bp->creg; void __iomem *cregs = bp->creg;
...@@ -635,7 +635,7 @@ static int bigmac_init_hw(struct bigmac *bp, int from_irq) ...@@ -635,7 +635,7 @@ static int bigmac_init_hw(struct bigmac *bp, int from_irq)
qec_init(bp); qec_init(bp);
/* Alloc and reset the tx/rx descriptor chains. */ /* Alloc and reset the tx/rx descriptor chains. */
bigmac_init_rings(bp, from_irq); bigmac_init_rings(bp, non_blocking);
/* Initialize the PHY. */ /* Initialize the PHY. */
bigmac_tcvr_init(bp); bigmac_tcvr_init(bp);
...@@ -749,7 +749,7 @@ static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_st ...@@ -749,7 +749,7 @@ static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_st
} }
printk(" RESET\n"); printk(" RESET\n");
bigmac_init_hw(bp, 1); bigmac_init_hw(bp, true);
} }
/* BigMAC transmit complete service routines. */ /* BigMAC transmit complete service routines. */
...@@ -921,7 +921,7 @@ static int bigmac_open(struct net_device *dev) ...@@ -921,7 +921,7 @@ static int bigmac_open(struct net_device *dev)
return ret; return ret;
} }
timer_setup(&bp->bigmac_timer, bigmac_timer, 0); timer_setup(&bp->bigmac_timer, bigmac_timer, 0);
ret = bigmac_init_hw(bp, 0); ret = bigmac_init_hw(bp, false);
if (ret) if (ret)
free_irq(dev->irq, bp); free_irq(dev->irq, bp);
return ret; return ret;
...@@ -945,7 +945,7 @@ static void bigmac_tx_timeout(struct net_device *dev, unsigned int txqueue) ...@@ -945,7 +945,7 @@ static void bigmac_tx_timeout(struct net_device *dev, unsigned int txqueue)
{ {
struct bigmac *bp = netdev_priv(dev); struct bigmac *bp = netdev_priv(dev);
bigmac_init_hw(bp, 0); bigmac_init_hw(bp, true);
netif_wake_queue(dev); netif_wake_queue(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment