cnic: Fix occasional NULL pointer dereference during reboot.
Subsystems (3)
PATCH 2/4 cnic: Read bnx2x function number from internal register
In reply to Michael ChanFrom: Eddie Wai <[email protected]>
so that it will work on any hypervisor.
--- drivers/net/ethernet/broadcom/cnic.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +7 -1
@@ -4988,8 +4988,14 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) cp->port_mode =CHIP_PORT_MODE_NONE ;if (BNX2X_CHIP_IS_E2_PLUS (cp->chip_id)) { -u32 val =CNIC_RD (dev,MISC_REG_PORT4MODE_EN_OVWR ); +u32 val; + +pci_read_config_dword (dev->pcidev,PCICFG_ME_REGISTER , &val); + cp->func = (u8) ((val &ME_REG_ABS_PF_NUM ) >> +ME_REG_ABS_PF_NUM_SHIFT ); + func =CNIC_FUNC (cp); + val =CNIC_RD (dev,MISC_REG_PORT4MODE_EN_OVWR );if (!(val &1 )) val =CNIC_RD (dev,MISC_REG_PORT4MODE_EN );else
Signature · 1 line
1.7.1
PATCH 4/4 cnic: Handle RAMROD_CMD_ID_CLOSE error.
In reply to Michael ChanFrom: Eddie Wai <[email protected]>
If firmware returns error status, proceed to close the iSCSI connection. Update version to 2.5.11.
--- drivers/net/ethernet/broadcom/cnic.c | 9 +++++++++ drivers/net/ethernet/broadcom/cnic_if.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +9 -0
@@ -3953,6 +3953,15 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)cnic_cm_upcall (cp, csk, opcode);break ; +case L5CM_RAMROD_CMD_ID_CLOSE : +if (l4kcqe->status !=0 ) { +netdev_warn (dev->netdev,"RAMROD CLOSE compl with " +"status 0x%x\n" , l4kcqe->status); + opcode =L4_KCQE_OPCODE_VALUE_CLOSE_COMP ; +/* Fall through */ + }else { +break ; + }case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED :case L4_KCQE_OPCODE_VALUE_CLOSE_COMP :case L4_KCQE_OPCODE_VALUE_RESET_COMP :
drivers/net/ethernet/broadcom/cnic_if.h +2 -2
@@ -14,8 +14,8 @@#include "bnx2x/bnx2x_mfw_req.h" -#define CNIC_MODULE_VERSION "2.5.10" -#define CNIC_MODULE_RELDATE "March 21, 2012" +#define CNIC_MODULE_VERSION "2.5.11" +#define CNIC_MODULE_RELDATE "June 27, 2012"#define CNIC_ULP_RDMA 0#define CNIC_ULP_ISCSI 1
Signature · 1 line
1.7.1
PATCH 1/4 cnic: Fix occasional NULL pointer dereference during reboot.
We register with bnx2x before we allocate ctx_tbl structure, so it is possible for bnx2x to call cnic_ctl before the structure is allocated. This can sometimes cause NULL pointer dereference of cp->ctx_tbl. We fix this by adding simple checking for valid state before proceeding. The cnic_ctl call is RCU protected so we don't have to deal with race conditions.
Because of the additional checking, we need to finish the shutdown before clearing the CNIC_UP flag.
--- drivers/net/ethernet/broadcom/cnic.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +7 -2
@@ -291,6 +291,9 @@ static int cnic_get_l5_cid(struct cnic_local *cp, u32 cid, u32 *l5_cid) {u32 i; +if (!cp->ctx_tbl) +return -EINVAL ; +for (i =0 ; i < cp->max_cid_space; i++) {if (cp->ctx_tbl[i].cid == cid) { *l5_cid = i;
@@ -3220,6 +3223,9 @@ static int cnic_ctl(void *data, struct cnic_ctl_info *info)u32 l5_cid;struct cnic_local *cp = dev->cnic_priv; +if (!test_bit (CNIC_F_CNIC_UP , &dev->flags)) +break ; +if (cnic_get_l5_cid (cp, cid, &l5_cid) ==0 ) {struct cnic_context *ctx = &cp->ctx_tbl[l5_cid];
@@ -4253,8 +4259,6 @@ static int cnic_cm_shutdown(struct cnic_dev *dev)struct cnic_local *cp = dev->cnic_priv;int i; - cp->stop_cm (dev); -if (!cp->csk_tbl)return 0 ;
@@ -5290,6 +5294,7 @@ static void cnic_stop_hw(struct cnic_dev *dev) i++; }cnic_shutdown_rings (dev); + cp->stop_cm (dev);clear_bit (CNIC_F_CNIC_UP , &dev->flags);RCU_INIT_POINTER (cp->ulp_ops[CNIC_ULP_L4 ],NULL );synchronize_rcu ();
Signature · 1 line
1.7.1
PATCH 3/4 cnic: Remove uio mem[0].
In reply to Michael ChanThis memory region is no longer used. Userspace gets the BAR address directly from sysfs.
--- drivers/net/ethernet/broadcom/cnic.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +1 -4
@@ -1063,10 +1063,7 @@ static int cnic_init_uio(struct cnic_dev *dev) uinfo = &udev->cnic_uinfo; - uinfo->mem[0 ].addr = dev->netdev->base_addr; - uinfo->mem[0 ].internal_addr = dev->regview; - uinfo->mem[0 ].size = dev->netdev->mem_end - dev->netdev->mem_start; - uinfo->mem[0 ].memtype =UIO_MEM_PHYS ; + uinfo->mem[0 ].memtype =UIO_MEM_NONE ;if (test_bit (CNIC_F_BNX2_CLASS , &dev->flags)) { uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen &
Signature · 1 line
1.7.1
PATCH 1/2 bnx2: Add "fall through" comments
In reply to Michael Chanto indicate that the mising break statements are intended.
--- drivers/net/ethernet/broadcom/bnx2.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +4 -0
@@ -1972,22 +1972,26 @@ bnx2_remote_phy_event(struct bnx2 *bp)switch (speed) {case BNX2_LINK_STATUS_10HALF : bp->duplex =DUPLEX_HALF ; +/* fall through */ case BNX2_LINK_STATUS_10FULL : bp->line_speed =SPEED_10 ;break ;case BNX2_LINK_STATUS_100HALF : bp->duplex =DUPLEX_HALF ; +/* fall through */ case BNX2_LINK_STATUS_100BASE_T4 :case BNX2_LINK_STATUS_100FULL : bp->line_speed =SPEED_100 ;break ;case BNX2_LINK_STATUS_1000HALF : bp->duplex =DUPLEX_HALF ; +/* fall through */ case BNX2_LINK_STATUS_1000FULL : bp->line_speed =SPEED_1000 ;break ;case BNX2_LINK_STATUS_2500HALF : bp->duplex =DUPLEX_HALF ; +/* fall through */ case BNX2_LINK_STATUS_2500FULL : bp->line_speed =SPEED_2500 ;break ;
Signature · 1 line
1.7.1
PATCH 2/2 bnx2: Add missing netif_tx_disable() in bnx2_close()
to stop all tx queues. Update version to 2.2.3.
--- drivers/net/ethernet/broadcom/bnx2.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +3 -2
@@ -58,8 +58,8 @@#include "bnx2_fw.h" #define DRV_MODULE_NAME "bnx2" -#define DRV_MODULE_VERSION "2.2.2" -#define DRV_MODULE_RELDATE "June 16, 2012" +#define DRV_MODULE_VERSION "2.2.3" +#define DRV_MODULE_RELDATE "June 27, 2012"#define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-6.2.3.fw"#define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-6.0.15.fw"#define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-6.2.1b.fw"
@@ -6703,6 +6703,7 @@ bnx2_close(struct net_device *dev)bnx2_disable_int_sync (bp);bnx2_napi_disable (bp); +netif_tx_disable (dev);del_timer_sync (&bp->timer);bnx2_shutdown_chip (bp);bnx2_free_irq (bp);
Signature · 1 line
1.7.1
Re: [PATCH net-next 1/2] bnx2: Add "fall through" comments
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:23 -0700
Quoted 3 lines
to indicate that the mising break statements are intended.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 2/2] bnx2: Add missing netif_tx_disable() in bnx2_close()
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:24 -0700
Quoted 3 lines
to stop all tx queues. Update version to 2.2.3.
Signed-off-by Michael Chan <[email protected]>
Applied.
From: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:19 -0700
Quoted 11 lines
We register with bnx2x before we allocate
ctx_tblstructure, so it is possible for bnx2x to callcnic_ctlbefore the structure is allocated. This can sometimes cause NULL pointer dereference ofcp->ctx_tbl. We fix this by adding simple checking for valid state before proceeding. Thecnic_ctlcall is RCU protected so we don't have to deal with race conditions.Because of the additional checking, we need to finish the shutdown before clearing the
CNIC_UPflag.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 2/4] cnic: Read bnx2x function number from internal register
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:20 -0700
Quoted 6 lines
From: Eddie Wai <[email protected]>
so that it will work on any hypervisor.
Signed-off-by Eddie Wai <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 3/4] cnic: Remove uio mem[0].
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:21 -0700
Quoted 4 lines
This memory region is no longer used. Userspace gets the BAR address directly from sysfs.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 4/4] cnic: Handle RAMROD_CMD_ID_CLOSE error.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Wed, 27 Jun 2012 18:08:22 -0700
Quoted 7 lines
From: Eddie Wai <[email protected]>
If firmware returns error status, proceed to close the iSCSI connection. Update version to 2.5.11.
Signed-off-by Eddie Wai <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.