benet: Wait f/w POST until timeout
Subsystems (3)
PATCH 1/2 benet: Wait f/w POST until timeout
While PCI card faces EEH errors, reset (usually hot reset) is expected to recover from the EEH errors. After EEH core finishes the reset, the driver callback (be_eeh_reset) is called and wait the firmware to complete POST successfully. The original code would return with error once detecting failure during POST stage. That seems not enough.
The patch forces the driver (be_eeh_reset) to wait the firmware completes POST until timeout, instead of returning error upon detection POST failure immediately. Also, it would improve the reliability of the EEH funtionality of the driver.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 27 ++++++++++----------------- 1 files changed, 10 insertions(+), 17 deletions(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +10 -17
@@ -473,7 +473,7 @@ static int be_mbox_notify_wait(struct be_adapter *adapter)return 0 ; } -static int be_POST_stage_get (struct be_adapter *adapter,u16 *stage) +static void be_POST_stage_get (struct be_adapter *adapter,u16 *stage) {u32 sem; u32 reg = skyhawk_chip(adapter) ? SLIPORT_SEMAPHORE_OFFSET_SH :
@@ -481,11 +481,6 @@ static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage)pci_read_config_dword (adapter->pdev, reg, &sem); *stage = sem &POST_STAGE_MASK ; - -if ((sem >>POST_ERR_SHIFT ) &POST_ERR_MASK ) -return -1 ; -else -return 0 ; }int lancer_wait_ready (struct be_adapter *adapter)
@@ -579,19 +574,17 @@ int be_fw_wait_ready(struct be_adapter *adapter) }do { - status =be_POST_stage_get (adapter, &stage); -if (status) { -dev_err (dev,"POST error; stage=0x%x\n" , stage); -return -1 ; - }else if (stage !=POST_STAGE_ARMFW_RDY ) { -if (msleep_interruptible (2000 )) { -dev_err (dev,"Waiting for POST aborted\n" ); -return -EINTR ; - } - timeout +=2 ; - }else { +be_POST_stage_get (adapter, &stage); +if (stage ==POST_STAGE_ARMFW_RDY )return 0 ; + +dev_info (dev,"Waiting for POST, %ds elapsed\n" , + timeout); +if (msleep_interruptible (2000 )) { +dev_err (dev,"Waiting for POST aborted\n" ); +return -EINTR ; } + timeout +=2 ; }while (timeout <60 );dev_err (dev,"POST timeout; stage=0x%x\n" , stage);
Signature · 1 line
1.7.5.4
PATCH 2/2 benet: Wait I/O while resuming device
After resetting the adapter, the config space register (0x7c) might give fake information to indicate the f/w is ready. In turn, 0xFF's is always returned while accessing on I/O space registers. The patch adds more check to make sure the I/O space is ready for access before accessing that region.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 29 +++++++++++++++++++++++++++ drivers/net/ethernet/emulex/benet/be_cmds.h | 1 + drivers/net/ethernet/emulex/benet/be_main.c | 5 ++++ 3 files changed, 35 insertions(+), 0 deletions(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +29 -0
@@ -696,6 +696,35 @@ static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)return wrb; } +int be_cmd_fw_wait_io (struct be_adapter *adapter) +{ +void __iomem *db = adapter->db +MPU_MAILBOX_DB_OFFSET ; +int timeout =0 ; +u32 val; + +if (lancer_chip (adapter)) +return 0 ; + +do { + val =ioread32 (db); +if (val !=0xffffffff ) +return 0 ; + +dev_info (&adapter->pdev->dev, +"Wating for I/O (0x%08x), %ds elapsed\n" , + val, timeout); +if (msleep_interruptible (2000 )) { +dev_err (&adapter->pdev->dev, +"Waiting for I/O aborted\n" ); +return -EIO ; + } + timeout +=2 ; + }while (timeout <60 ); + +dev_err (&adapter->pdev->dev,"Timeout waiting for I/O (%d)\n" , timeout); +return -1 ; +} +/* Tell fw we're about to start firing cmds by writing a * special pattern across the wrb hdr; uses mbox */
drivers/net/ethernet/emulex/benet/be_cmds.h +1 -0
@@ -1888,6 +1888,7 @@ int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, int offset);extern int be_cmd_enable_magic_wol (struct be_adapter *adapter,u8 *mac,struct be_dma_mem *nonemb_cmd); +extern int be_cmd_fw_wait_io (struct be_adapter *adapter);extern int be_cmd_fw_init (struct be_adapter *adapter);extern int be_cmd_fw_clean (struct be_adapter *adapter);extern void be_async_mcc_enable (struct be_adapter *adapter);
drivers/net/ethernet/emulex/benet/be_main.c +5 -0
@@ -4347,6 +4347,11 @@ static void be_eeh_resume(struct pci_dev *pdev)pci_save_state (pdev); +/* Wating for I/O ready */ + status =be_cmd_fw_wait_io (adapter); +if (status) + goto err; +/* tell fw we're ready to fire cmds */ status =be_cmd_fw_init (adapter);if (status)
Signature · 1 line
1.7.5.4
RE: [PATCH 2/2] benet: Wait I/O while resuming device
Quoted 8 lines
-----Original Message-----
From: Gavin Shan [mailto:[email protected]]After resetting the adapter, the config space register (
0x7c) might give fake information to indicate the f/w is ready. In turn, 0xFF's is always returned while accessing on I/O space registers. The patch adds more check to make sure the I/O space is ready for access before accessing that region.
...
drivers/net/ethernet/emulex/benet/be_cmds.c static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) · line 711
Quoted 13 lines
drivers/net/ethernet/emulex/benet/be_cmds.c +12
-0+int be_cmd_fw_wait_io (struct be_adapter *adapter) { +void __iomem *db = adapter->db +MPU_MAILBOX_DB_OFFSET ; +int timeout =0 ; +u32 val; + +if (lancer_chip (adapter)) +return 0 ; + + do { + val = ioread32(db); + if (val != 0xffffffff) + return 0;
Wouldn't reading 0xffffffff from a register cause a new EEH flow to be triggered?
Anyway, the SLIPORT_SEMAPHORE register that returns a valid POST state *always* is available in the CSR BAR space. This will be for BE2 and BE3 chips. For Skyhawk-R chips config-space/0x7c will work fine.
I can give a patch with these changes in a few days if that works for you....
Quoted 17 lines
drivers/net/ethernet/emulex/benet/be_cmds.c +13
-0+ +dev_info (&adapter->pdev->dev, +"Wating for I/O (0x%08x), %ds elapsed\n" , + val, timeout); +if (msleep_interruptible (2000 )) { +dev_err (&adapter->pdev->dev, +"Waiting for I/O aborted\n" ); +return -EIO ; + } + timeout +=2 ; + }while (timeout <60 ); + + dev_err(&adapter->pdev->dev, "Timeout waiting for I/O (%d)\n",timeout);
drivers/net/ethernet/emulex/benet/be_cmds.c +3
-0+return -1 ; +} +
A message that is not in the archive (sent off-list or not yet received): 20130304101841.GA20882@shangw.(null)
RE: [PATCH 2/2] benet: Wait I/O while resuming device
Quoted 35 lines
-----Original Message-----
From: Gavin Shan [mailto:[email protected]]Quoted 7 lines · Sathya
Quoted 7 lines
-----Original Message-----
From: Gavin Shan [mailto:[email protected]]After resetting the adapter, the config space register (
0x7c) might give fake information to indicate the f/w is ready. In turn, 0xFF's is always returned while accessing on I/O space registers. The patch adds more check to make sure the I/O space is ready for access beforeaccessing that region.
Quoted 16 lines
Quoted 1 line
...
drivers/net/ethernet/emulex/benet/be_cmds.c static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) · line 711
Quoted 13 lines
drivers/net/ethernet/emulex/benet/be_cmds.c +12
-0+int be_cmd_fw_wait_io (struct be_adapter *adapter) { +void __iomem *db = adapter->db +MPU_MAILBOX_DB_OFFSET ; +int timeout =0 ; +u32 val; + +if (lancer_chip (adapter)) +return 0 ; + + do { + val = ioread32(db); + if (val != 0xffffffff) + return 0;Wouldn't reading
0xfffffffffrom a register cause a new EEH flow to betriggered?
Quoted 1 line
I don't think
0xffffffffhere indicates a new EEH error and the adapter was recovering from EEH error, which already happened before.
Quoted 6 lines
Actually, I'm developing new feature to support EEH for PowerNV (PPC) platform. While the benet adapter detected EEH error and tried to resume, the I/O access always returned
0xffffffffeven through I could get correct values from the config space. Since I don't have the specification, I would guess the config space becomes ready prior to I/O space after resetting the adapter and its firmware.
The root-cause here is that the config-space/0x7c register is incorrectly reflecting the POST state to be FW_READY. This causes the driver to go ahead and read I/O space "prematurely" causing a 0xffffffff read.
The config-space/0x7c register reflects the correct
value a little later. This happens only for BE2/3 chips.
I propose to fix this by polling instead on CSR-BAR/0xac register for POST status for BE2/3 chips.
thanks,
-Sathya
A message that is not in the archive (sent off-list or not yet received): 20130305072126.GA19947@shangw.(null)
RE: [PATCH 2/2] benet: Wait I/O while resuming device
Quoted 14 lines
-----Original Message-----
From: Gavin Shan [mailto:[email protected]]Quoted 9 lines · Sathya
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
After resetting the adapter, the config space register (
0x7c) might give fake information to indicate the f/w is ready. In turn, 0xFF's is always returned while accessing on I/O space registers. The patch adds more check to make sure the I/O space is ready for access beforeaccessing that region.
Quoted 3 lines
Quoted 1 line
...
Quoted 1 line
....
Quoted 22 lines
Quoted 13 lines
Quoted 6 lines
Quoted 1 line
I don't think
0xffffffffhere indicates a new EEH error and the adapter was recovering from EEH error, which already happened before.Quoted 6 lines
Actually, I'm developing new feature to support EEH for PowerNV (PPC) platform. While the benet adapter detected EEH error and tried to resume, the I/O access always returned
0xffffffffeven through I could get correct values from the config space. Since I don't have the specification, I would guess the config space becomes ready prior to I/O space after resetting the adapter and its firmware.Quoted 6 lines
The root-cause here is that the config-space/0x7c register is incorrectly reflecting the POST state to be
FW_READY. This causes the driver to go ahead and read I/O space "prematurely" causing a0xffffffffread. The config-space/0x7c register reflects the correct value a little later. This happens only for BE2/3 chips.Yes, Sathya. It's exactly the case happened on BE3.
Quoted 8 lines
Quoted 3 lines
I propose to fix this by polling instead on CSR-BAR/0xac register for POST status for BE2/3 chips.
Do you mean to poll CSR-BAR/0xac (
adapter->db+0xac) for POST status? I just had one experiment. It seems that CSR-BAR/0xac always returns0x0even though the firmware have been ready completely. Could you please double- check on it?
Gavin, The CSR-BAR is not being mapped in the current code. That should be done as a part of the fix....
Would it be possible for you to test this patch.
I have it working on my setup but I feel it still needs some regression testing...
--- drivers/net/ethernet/emulex/benet/be.h | 1 + drivers/net/ethernet/emulex/benet/be_cmds.c | 10 ++++++---- drivers/net/ethernet/emulex/benet/be_hw.h | 4 ++-- drivers/net/ethernet/emulex/benet/be_main.c | 9 +++++++++ 4 files changed, 18 insertions(+), 6 deletions(-)
drivers/net/ethernet/emulex/benet/be.h +1 -0
@@ -349,6 +349,7 @@ struct be_adapter {struct pci_dev *pdev;struct net_device *netdev; +u8 __iomem *csr;u8 __iomem *db;/* Door Bell */ struct mutex mbox_lock;/* For serializing mbox cmds to BE card */
drivers/net/ethernet/emulex/benet/be_cmds.c +6 -4
@@ -476,12 +476,14 @@ static int be_mbox_notify_wait(struct be_adapter *adapter)static int be_POST_stage_get (struct be_adapter *adapter,u16 *stage) {u32 sem; -u32 reg =skyhawk_chip (adapter) ?SLIPORT_SEMAPHORE_OFFSET_SH : -SLIPORT_SEMAPHORE_OFFSET_BE ; -pci_read_config_dword (adapter->pdev, reg, &sem); - *stage = sem &POST_STAGE_MASK ; +if (BEx_chip (adapter)) + sem =ioread32 (adapter->csr + SLIPORT_SEMAPHORE_OFFSET_BEx); +else +pci_read_config_dword (adapter->pdev, +SLIPORT_SEMAPHORE_OFFSET_SH , &sem); + *stage = sem &POST_STAGE_MASK ;if ((sem >>POST_ERR_SHIFT ) &POST_ERR_MASK )return -1 ;else
drivers/net/ethernet/emulex/benet/be_hw.h +2 -2
@@ -32,8 +32,8 @@#define MPU_EP_CONTROL 0/********** MPU semphore: used for SH & BE *************/ -#define SLIPORT_SEMAPHORE_OFFSET_BE 0x7c -#define SLIPORT_SEMAPHORE_OFFSET_SH 0x94 +#define SLIPORT_SEMAPHORE_OFFSET_BEx 0xac/* CSR BAR offset */ +#define SLIPORT_SEMAPHORE_OFFSET_SH 0x94/* PCI-CFG offset */ #define POST_STAGE_MASK 0x0000FFFF#define POST_ERR_MASK 0x1#define POST_ERR_SHIFT 31
drivers/net/ethernet/emulex/benet/be_main.c +9 -0
@@ -3688,6 +3688,8 @@ static void be_netdev_init(struct net_device *netdev)static void be_unmap_pci_bars (struct be_adapter *adapter) { +if (adapter->csr) +pci_iounmap (adapter->pdev, adapter->csr);if (adapter->db)pci_iounmap (adapter->pdev, adapter->db); }
@@ -3721,6 +3723,13 @@ static int be_map_pci_bars(struct be_adapter *adapter) adapter->if_type = (sli_intf &SLI_INTF_IF_TYPE_MASK ) >>SLI_INTF_IF_TYPE_SHIFT ; +if (be_physfn (adapter) &&BEx_chip (adapter)) { + addr =pci_iomap (adapter->pdev,2 ,0 ); +if (addr ==NULL ) +return -ENOMEM ; + adapter->csr = addr; + } + addr =pci_iomap (adapter->pdev,db_bar (adapter),0 );if (addr ==NULL ) goto pci_map_err;
Signature · 1 line
1.7.1
David Miller
maintainerFrom: Gavin Shan <[email protected]>
Date: Mon, 4 Mar 2013 15:48:46 +0800
Quoted 7 lines
While PCI card faces EEH errors, reset (usually hot reset) is expected to recover from the EEH errors. After EEH core finishes the reset, the driver callback (
be_eeh_reset) is called and wait the firmware to complete POST successfully. The original code would return with error once detecting failure during POST stage. That seems not enough.
Quoted 6 lines
The patch forces the driver (
be_eeh_reset) to wait the firmware completes POST until timeout, instead of returning error upon detection POST failure immediately. Also, it would improve the reliability of the EEH funtionality of the driver.Signed-off-by Gavin Shan <[email protected]>
I know that patch #2 of this series needs to be implemented differently, but this patch seems fine.
So can I get an ACK from one of the benet driver folks?
Thanks.
Perla, Sathya
Acked-byQuoted 17 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]From: Gavin Shan <[email protected]>
Date: Mon, 4 Mar 2013 15:48:46 +0800Quoted 11 lines
While PCI card faces EEH errors, reset (usually hot reset) is expected to recover from the EEH errors. After EEH core finishes the reset, the driver callback (
be_eeh_reset) is called and wait the firmware to complete POST successfully. The original code would return with error once detecting failure during POST stage. That seems not enough.The patch forces the driver (
be_eeh_reset) to wait the firmware completes POST until timeout, instead of returning error upon detection POST failure immediately. Also, it would improve the reliability of the EEH funtionality of the driver.
Quoted 6 lines
Quoted 1 line
Signed-off-by Gavin Shan <[email protected]>I know that patch #2 of this series needs to be implemented differently, but this patch seems fine.
So can I get an ACK from one of the benet driver folks?
thanks!
From: "Perla, Sathya" <[email protected]>
Date: Wed, 6 Mar 2013 04:45:03 +0000
Quoted 17 lines
Quoted 17 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]From: Gavin Shan <[email protected]>
Date: Mon, 4 Mar 2013 15:48:46 +0800Quoted 11 lines
While PCI card faces EEH errors, reset (usually hot reset) is expected to recover from the EEH errors. After EEH core finishes the reset, the driver callback (
be_eeh_reset) is called and wait the firmware to complete POST successfully. The original code would return with error once detecting failure during POST stage. That seems not enough.The patch forces the driver (
be_eeh_reset) to wait the firmware completes POST until timeout, instead of returning error upon detection POST failure immediately. Also, it would improve the reliability of the EEH funtionality of the driver.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Gavin Shan <[email protected]>I know that patch #2 of this series needs to be implemented differently, but this patch seems fine.
So can I get an ACK from one of the benet driver folks?
Acked-by Sathya Perla <[email protected]>
Applied, thanks for reviewing.