* [PATCH net] bnx2: fix locking when netconsole is used
@ 2016-10-17 16:20 Ivan Vecera
2016-10-17 17:21 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Ivan Vecera @ 2016-10-17 16:20 UTC (permalink / raw)
To: netdev; +Cc: Sony Chacko, Dept-HSGLinuxNICDev
Functions bnx2_reg_rd_ind(), bnx2_reg_wr_ind() and bnx2_ctx_wr()
can be called with IRQs disabled when netconsole is enabled. So they
should use spin_{,un}lock_irq{save,restore} instead of _bh variants.
Example call flow:
bnx2_poll()
->bnx2_poll_link()
->bnx2_phy_int()
->bnx2_set_remote_link()
->bnx2_shmem_rd()
->bnx2_reg_rd_ind()
-> spin_lock_bh(&bp->indirect_lock);
spin_unlock_bh(&bp->indirect_lock);
...
-> __local_bh_enable_ip
static inline void __local_bh_enable_ip(unsigned long ip)
WARN_ON_ONCE(in_irq() || irqs_disabled()); <<<<<< WARN
Cc: Sony Chacko <sony.chacko@qlogic.com>
Cc: Dept-HSGLinuxNICDev@qlogic.com
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
drivers/net/ethernet/broadcom/bnx2.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 27f11a5..9c408413 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -272,21 +272,24 @@ static u32
bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
{
u32 val;
+ unsigned long flags;
- spin_lock_bh(&bp->indirect_lock);
+ spin_lock_irqsave(&bp->indirect_lock, flags);
BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
val = BNX2_RD(bp, BNX2_PCICFG_REG_WINDOW);
- spin_unlock_bh(&bp->indirect_lock);
+ spin_unlock_irqrestore(&bp->indirect_lock, flags);
return val;
}
static void
bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val)
{
- spin_lock_bh(&bp->indirect_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&bp->indirect_lock, flags);
BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
BNX2_WR(bp, BNX2_PCICFG_REG_WINDOW, val);
- spin_unlock_bh(&bp->indirect_lock);
+ spin_unlock_irqrestore(&bp->indirect_lock, flags);
}
static void
@@ -304,8 +307,10 @@ bnx2_shmem_rd(struct bnx2 *bp, u32 offset)
static void
bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
{
+ unsigned long flags;
+
offset += cid_addr;
- spin_lock_bh(&bp->indirect_lock);
+ spin_lock_irqsave(&bp->indirect_lock, flags);
if (BNX2_CHIP(bp) == BNX2_CHIP_5709) {
int i;
@@ -322,7 +327,7 @@ bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
BNX2_WR(bp, BNX2_CTX_DATA_ADR, offset);
BNX2_WR(bp, BNX2_CTX_DATA, val);
}
- spin_unlock_bh(&bp->indirect_lock);
+ spin_unlock_irqrestore(&bp->indirect_lock, flags);
}
#ifdef BCM_CNIC
--
2.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] bnx2: fix locking when netconsole is used
2016-10-17 16:20 [PATCH net] bnx2: fix locking when netconsole is used Ivan Vecera
@ 2016-10-17 17:21 ` David Miller
2016-10-18 6:16 ` Ivan Vecera
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2016-10-17 17:21 UTC (permalink / raw)
To: ivecera; +Cc: netdev, sony.chacko, Dept-HSGLinuxNICDev
From: Ivan Vecera <ivecera@redhat.com>
Date: Mon, 17 Oct 2016 18:20:31 +0200
> diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
> index 27f11a5..9c408413 100644
> --- a/drivers/net/ethernet/broadcom/bnx2.c
> +++ b/drivers/net/ethernet/broadcom/bnx2.c
> @@ -272,21 +272,24 @@ static u32
> bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
> {
> u32 val;
> + unsigned long flags;
>
Please order local variable declarations from longest to shortest
line.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] bnx2: fix locking when netconsole is used
2016-10-17 17:21 ` David Miller
@ 2016-10-18 6:16 ` Ivan Vecera
0 siblings, 0 replies; 3+ messages in thread
From: Ivan Vecera @ 2016-10-18 6:16 UTC (permalink / raw)
To: David Miller; +Cc: netdev, sony.chacko, Dept-HSGLinuxNICDev
Dne 17.10.2016 v 19:21 David Miller napsal(a):
> From: Ivan Vecera <ivecera@redhat.com>
> Date: Mon, 17 Oct 2016 18:20:31 +0200
>
>> diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
>> index 27f11a5..9c408413 100644
>> --- a/drivers/net/ethernet/broadcom/bnx2.c
>> +++ b/drivers/net/ethernet/broadcom/bnx2.c
>> @@ -272,21 +272,24 @@ static u32
>> bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
>> {
>> u32 val;
>> + unsigned long flags;
>>
>
> Please order local variable declarations from longest to shortest
> line.
Sure Dave, done.
Ivan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-18 6:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17 16:20 [PATCH net] bnx2: fix locking when netconsole is used Ivan Vecera
2016-10-17 17:21 ` David Miller
2016-10-18 6:16 ` Ivan Vecera
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).