NetXen: Bug fixes for multiport and blade adapters
Subsystems (2)
cover NetXen: Bug fixes for multiport and blade adapters
Sending reworked patches based on Michael's feedback (originally sent by Mithlesh Thukral). These patches address interrupt mask issues on multiport adapters, as well as stability issues on powerpc blades.
Signature · 10 lines
Dhananjay Phadke NetXen Inc. drivers/net/netxen/netxen_nic.h | 176 +++++++++++++++++++++++++++--- drivers/net/netxen/netxen_nic_hdr.h | 2 + drivers/net/netxen/netxen_nic_hw.c | 33 ++++-- drivers/net/netxen/netxen_nic_init.c | 56 ++++++---- drivers/net/netxen/netxen_nic_main.c | 176 +++++++++++++++++++----------- drivers/net/netxen/netxen_nic_phan_reg.h | 14 +++ 6 files changed, 341 insertions(+), 116 deletions(-)
PATCH 1/3 NetXen: Fix issue of MSI not working correctly
NetXen driver uses PCI function 0 to provide the functionality of MSI. The patch makes driver check the bus master bit for function 0 and enable it after the card initialization.
drivers/net/netxen/netxen_nic_main.c +13 -16
@@ -336,11 +336,9 @@ netxen_nic_probe(struct pci_dev *pdev, cif (pci_using_dac) netdev->features |=NETIF_F_HIGHDMA ; -if (pci_enable_msi (pdev)) { +if (pci_enable_msi (pdev)) adapter->flags &= ~NETXEN_NIC_MSI_ENABLED ; -printk (KERN_WARNING "%s: unable to allocate MSI interrupt" -" error\n" , netxen_nic_driver_name); - }else +else adapter->flags |=NETXEN_NIC_MSI_ENABLED ; netdev->irq = pdev->irq;
@@ -355,13 +353,6 @@ netxen_nic_probe(struct pci_dev *pdev, c/* initialize the adapter */ netxen_initialize_adapter_hw (adapter); -#ifdef CONFIG_PPC -if ((adapter->ahw.boardcfg.board_type == -NETXEN_BRDTYPE_P2_SB31_10G_IMEZ ) && - (pci_func_id ==2 )) - goto err_out_free_adapter; -#endif /* CONFIG_PPC */ -/* * Adapter in our case is quad port so initialize it before * initializing the ports
@@ -509,16 +500,22 @@ netxen_nic_probe(struct pci_dev *pdev, c NETXEN_CAM_RAM(0x1fc)));if (val ==0x55555555 ) {/* This is the first boot after power up */ +netxen_nic_read_w0 (adapter,NETXEN_PCIE_REG (0x4 ), &val); +if (!(val &0x4 )) { + val |=0x4 ; +netxen_nic_write_w0 (adapter,NETXEN_PCIE_REG (0x4 ), val); +netxen_nic_read_w0 (adapter,NETXEN_PCIE_REG (0x4 ), &val); + } val =readl (NETXEN_CRB_NORMALIZE (adapter,NETXEN_ROMUSB_GLB_SW_RESET ));printk (KERN_INFO "NetXen: read 0x%08x for reset reg.\n" ,val);if (val !=0x80000f ) {/* clear the register for future unloads/loads */ -writel (0 ,NETXEN_CRB_NORMALIZE (adapter, -NETXEN_CAM_RAM (0x1fc ))); -printk (KERN_ERR "ERROR in NetXen HW init sequence.\n" ); - err = -ENODEV ; - goto err_out_free_dev; +writel (0 ,NETXEN_CRB_NORMALIZE (adapter, +NETXEN_CAM_RAM (0x1fc ))); +printk (KERN_ERR "ERROR in NetXen HW init sequence.\n" ); + err = -ENODEV ; + goto err_out_free_dev; }/* clear the register for future unloads/loads */
PATCH 2/3 NetXen: Support per PCI-function interrupt mask registers
In reply to [email protected]This patch updates the various access routines to access different control and status settings present in different register locations. This will fix problems related to working of different ports in multi Port card.
Signed-off by: Dhananjay Phadke <[email protected]> Signed-off by: Milan Bag <[email protected]>
drivers/net/netxen/netxen_nic.h +82 -16
@@ -937,6 +937,7 @@ struct netxen_adapter {struct netxen_ring_ctx *ctx_desc;struct pci_dev *ctx_desc_pdev;dma_addr_t ctx_desc_phys_addr; +int intr_scheme;int (*enable_phy_interrupts) (struct netxen_adapter *);int (*disable_phy_interrupts) (struct netxen_adapter *);void (*handle_phy_intr) (struct netxen_adapter *);
@@ -1080,37 +1081,102 @@ struct net_device_stats *netxen_nic_get_static inline void netxen_nic_disable_int (struct netxen_adapter *adapter) { -/* -* ISR_INT_MASK: Can be read from window 0 or 1. -*/ -writel (0x7ff ,PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_MASK )); +uint32_t mask =0x7ff ; +int count =0 ; +DPRINTK (1 ,INFO ,"Entered ISR Disable \n" ); + +switch (adapter->portnum) { +case 0 : +writel (0x0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_0 )); +break ; +case 1 : +writel (0x0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_1 )); +break ; +case 2 : +writel (0x0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_2 )); +break ; +case 3 : +writel (0x0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_3 )); +break ; + } + +if (adapter->intr_scheme !=-1 && + adapter->intr_scheme !=INTR_SCHEME_PERPORT ) { +writel (mask, + (void *)(PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_MASK ))); + } + +/* Window = 0 or 1 */ +if (!(adapter->flags &NETXEN_NIC_MSI_ENABLED )) { +do { +writel (0xffffffff , (void *) + (PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_TARGET_STATUS ))); + mask =readl ((void *) + (pci_base_offset (adapter,ISR_INT_VECTOR ))); + }while (((mask &0x80 ) !=0 ) && (++count <32 )); + +if ((mask &0x80 ) !=0 ) { +printk (KERN_NOTICE "Could not disable interrupt completely\n" ); + } + } + +DPRINTK (1 ,INFO ,"Done with Disable Int\n" ); + +return ; }static inline void netxen_nic_enable_int (struct netxen_adapter *adapter) {u32 mask; -switch (adapter->ahw.board_type) { -case NETXEN_NIC_GBE : - mask =0x77b ; +DPRINTK (1 ,INFO ,"Entered ISR Enable \n" ); + +if (adapter->intr_scheme !=-1 && + adapter->intr_scheme !=INTR_SCHEME_PERPORT ) { +switch (adapter->ahw.board_type) { +case NETXEN_NIC_GBE : + mask =0x77b ; +break ; +case NETXEN_NIC_XGBE : + mask =0x77f ; +break ; +default : + mask =0x7ff ; +break ; + } + +writel (mask, + (void *)(PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_MASK ))); + } +switch (adapter->portnum) { +case 0 : +writel (0x1 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_0 )); +break ; +case 1 : +writel (0x1 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_1 ));break ; -case NETXEN_NIC_XGBE : - mask =0x77f ; +case 2 : +writel (0x1 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_2 ));break ; -default : - mask =0x7ff ; +case 3 : +writel (0x1 ,NETXEN_CRB_NORMALIZE (adapter,CRB_SW_INT_MASK_3 ));break ; } -writel (mask,PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_MASK )); -if (!(adapter->flags &NETXEN_NIC_MSI_ENABLED )) { mask =0xbff ; -writel (0X0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_INT_VECTOR )); -writel (mask,PCI_OFFSET_SECOND_RANGE (adapter, -ISR_INT_TARGET_MASK )); +if (adapter->intr_scheme !=-1 && + adapter->intr_scheme !=INTR_SCHEME_PERPORT ) { +writel (0X0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_INT_VECTOR )); + } +writel (mask, + (void *)(PCI_OFFSET_SECOND_RANGE (adapter,ISR_INT_TARGET_MASK ))); } + +DPRINTK (1 ,INFO ,"Done with enable Int\n" ); + +return ; }/*
drivers/net/netxen/netxen_nic_hw.c +5 -1
@@ -392,7 +392,11 @@ int netxen_nic_hw_resources(struct netxereturn err; } } -DPRINTK (INFO ,"Recieve Peg ready too. starting stuff\n" ); + adapter->intr_scheme =readl ( +NETXEN_CRB_NORMALIZE (adapter,CRB_NIC_CAPABILITIES_FW )); +printk (KERN_NOTICE "%s: FW capabilities:0x%x\n" , netdev->name, + adapter->intr_scheme); +DPRINTK (INFO ,"Receive Peg ready too. starting stuff\n" ); addr = netxen_alloc(adapter->ahw.pdev, sizeof(struct netxen_ring_ctx) +
drivers/net/netxen/netxen_nic_init.c +2 -0
@@ -139,6 +139,8 @@ int netxen_init_firmware(struct netxen_areturn err; }/* Window 1 call */ +writel (INTR_SCHEME_PERPORT , +NETXEN_CRB_NORMALIZE (adapter,CRB_NIC_CAPABILITIES_HOST ));writel (MPORT_MULTI_FUNCTION_MODE ,NETXEN_CRB_NORMALIZE (adapter,CRB_MPORT_MODE )); writel(PHAN_INITIALIZE_ACK,
drivers/net/netxen/netxen_nic_main.c +17 -13
@@ -308,7 +308,13 @@ netxen_nic_probe(struct pci_dev *pdev, c adapter->netdev = netdev; adapter->pdev = pdev; + +/* this will be read from FW later */ + adapter->intr_scheme =-1 ; + +/* This will be reset for mezz cards */ adapter->portnum = pci_func_id; + adapter->status &= ~NETXEN_NETDEV_STATUS ; netdev->open = netxen_nic_open; netdev->stop = netxen_nic_close;
@@ -1100,28 +1106,26 @@ static int netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) { u32 ret = 0; +u32 our_int =0 ;DPRINTK (INFO ,"Entered handle ISR\n" ); adapter->stats.ints++;if (!(adapter->flags &NETXEN_NIC_MSI_ENABLED )) { -int count =0 ; -u32 mask; -u32 our_int =0 ; our_int =readl (NETXEN_CRB_NORMALIZE (adapter,CRB_INT_VECTOR ));/* not our interrupt */ if ((our_int & (0x80 << adapter->portnum)) ==0 )return ret; -netxen_nic_disable_int (adapter); -/* Window = 0 or 1 */ -do { -writel (0xffffffff ,PCI_OFFSET_SECOND_RANGE (adapter, -ISR_INT_TARGET_STATUS )); - mask =readl (pci_base_offset (adapter,ISR_INT_VECTOR )); - }while (((mask &0x80 ) !=0 ) && (++count <32 )); -if ((mask &0x80 ) !=0 ) -printk ("Could not disable interrupt completely\n" ); + } +netxen_nic_disable_int (adapter); + +if (adapter->intr_scheme ==INTR_SCHEME_PERPORT ) { +/* claim interrupt */ +if (!(adapter->flags &NETXEN_NIC_MSI_ENABLED )) { +writel (our_int & ~((u32)(0x80 << adapter->portnum)), +NETXEN_CRB_NORMALIZE (adapter,CRB_INT_VECTOR )); + } }if (netxen_nic_rx_has_work (adapter) ||netxen_nic_tx_has_work (adapter)) {
@@ -1133,7 +1137,7 @@ netxen_handle_int(struct netxen_adapter }else {static unsigned int intcount =0 ;if ((++intcount &0xfff ) ==0xfff ) -printk (KERN_ERR +DPRINTK (KERN_ERR "%s: %s interrupt %d while in poll\n" , netxen_nic_driver_name, netdev->name, intcount);
drivers/net/netxen/netxen_nic_phan_reg.h +14 -0
@@ -114,6 +114,20 @@#define CRB_V2P_3 NETXEN_NIC_REG(0x29c)#define CRB_V2P (port) (CRB_V2P_0+((port)*4))#define CRB_DRIVER_VERSION NETXEN_NIC_REG(0x2a0) +/* sw int status/mask registers */ +#define CRB_SW_INT_MASK_0 NETXEN_NIC_REG(0x1d8) +#define CRB_SW_INT_MASK_1 NETXEN_NIC_REG(0x1e0) +#define CRB_SW_INT_MASK_2 NETXEN_NIC_REG(0x1e4) +#define CRB_SW_INT_MASK_3 NETXEN_NIC_REG(0x1e8) + +/* +* capabilities register, can be used to selectively enable/disable features +* for backward compability +*/ +#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8) +#define CRB_NIC_CAPABILITIES_FW NETXEN_NIC_REG(0x1dc) + +#define INTR_SCHEME_PERPORT 0x1/* used for ethtool tests */ #define CRB_SCRATCHPAD_TEST NETXEN_NIC_REG(0x280)
PATCH 3/3 NetXen: Graceful teardown of interface and hardware upon module unload
In reply to [email protected]These changes allow driver close routine to be called during module unload, to clean-up buffers and other software resources, flush queues etc. Also, hardware is reset to pristine state.
drivers/net/netxen/netxen_nic.h +76 -2
@@ -952,6 +952,24 @@ struct netxen_adapter {int (*stop_port) (struct netxen_adapter *); };/* netxen_adapter structure */ +/* +* NetXen dma watchdog control structure +* +* Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive +* Bit 1 : disable_request => 1 req disable dma watchdog +* Bit 2 : enable_request => 1 req enable dma watchdog +* Bit 3-31 : unused +*/ + +#define netxen_set_dma_watchdog_disable_req (config_word) \ + _netxen_set_bits(config_word, 1, 1, 1) +#define netxen_set_dma_watchdog_enable_req (config_word) \ + _netxen_set_bits(config_word, 2, 1, 1) +#define netxen_get_dma_watchdog_enabled (config_word) \ + ((config_word) & 0x1) +#define netxen_get_dma_watchdog_disabled (config_word) \ + (((config_word) >> 1) & 0x1) +/* Max number of xmit producer threads that can run simultaneously */ #define MAX_XMIT_PRODUCERS 16
@@ -1031,8 +1049,8 @@ int netxen_nic_erase_pxe(struct netxen_a/* Functions from netxen_nic_init.c */ void netxen_free_adapter_offload (struct netxen_adapter *adapter);int netxen_initialize_adapter_offload (struct netxen_adapter *adapter); -void netxen_phantom_init (struct netxen_adapter *adapter,int pegtune_val); -void netxen_load_firmware (struct netxen_adapter *adapter); +int netxen_phantom_init (struct netxen_adapter *adapter,int pegtune_val); +int netxen_load_firmware (struct netxen_adapter *adapter);int netxen_pinit_from_rom (struct netxen_adapter *adapter,int verbose);int netxen_rom_fast_read (struct netxen_adapter *adapter,int addr,int *valp); int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
@@ -1230,6 +1248,62 @@ static inline void get_brd_name_by_type( name ="Unknown" ; } +static inline int +dma_watchdog_shutdown_request (struct netxen_adapter *adapter) +{ +u32 ctrl; + +/* check if already inactive */ +if (netxen_nic_hw_read_wx (adapter, +NETXEN_CAM_RAM (NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL ), &ctrl,4 )) +printk (KERN_ERR "failed to read dma watchdog status\n" ); + +if (netxen_get_dma_watchdog_enabled (ctrl) ==0 ) +return 1 ; + +/* Send the disable request */ +netxen_set_dma_watchdog_disable_req (ctrl); +netxen_crb_writelit_adapter (adapter, +NETXEN_CAM_RAM (NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL ), ctrl); + +return 0 ; +} + +static inline int +dma_watchdog_shutdown_poll_result (struct netxen_adapter *adapter) +{ +u32 ctrl; + +if (netxen_nic_hw_read_wx (adapter, +NETXEN_CAM_RAM (NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL ), &ctrl,4 )) +printk (KERN_ERR "failed to read dma watchdog status\n" ); + +return ((netxen_get_dma_watchdog_enabled (ctrl) ==0 ) && + (netxen_get_dma_watchdog_disabled (ctrl) ==0 )); +} + +static inline int +dma_watchdog_wakeup (struct netxen_adapter *adapter) +{ +u32 ctrl; + +if (netxen_nic_hw_read_wx (adapter, +NETXEN_CAM_RAM (NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL ), &ctrl,4 )) +printk (KERN_ERR "failed to read dma watchdog status\n" ); + +if (netxen_get_dma_watchdog_enabled (ctrl)) +return 1 ; + +/* send the wakeup request */ +netxen_set_dma_watchdog_enable_req (ctrl); + +netxen_crb_writelit_adapter (adapter, +NETXEN_CAM_RAM (NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL ), ctrl); + +return 0 ; +} + +int netxen_is_flash_supported (struct netxen_adapter *adapter);int netxen_get_flash_mac_addr (struct netxen_adapter *adapter,u64 mac[]);extern void netxen_change_ringparam (struct netxen_adapter *adapter);
drivers/net/netxen/netxen_nic_hdr.h +2 -0
@@ -687,4 +687,6 @@ enum {#define PCIE_MAX_MASTER_SPLIT (0x14048) +#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) +#endif /* __NETXEN_NIC_HDR_H_ */
drivers/net/netxen/netxen_nic_hw.c +19 -10
@@ -377,7 +377,7 @@ int netxen_nic_hw_resources(struct netxe recv_crb_registers[ctx]. crb_rcvpeg_state));while (state !=PHAN_PEG_RCV_INITIALIZED && loops <20 ) { -udelay (100 ); +msleep (1 );/* Window 1 call */ state = readl(NETXEN_CRB_NORMALIZE(adapter, recv_crb_registers
@@ -394,7 +394,7 @@ int netxen_nic_hw_resources(struct netxe } adapter->intr_scheme =readl (NETXEN_CRB_NORMALIZE (adapter,CRB_NIC_CAPABILITIES_FW )); -printk (KERN_NOTICE "%s: FW capabilities:0x%x\n" , netdev->name, +printk (KERN_NOTICE "%s: FW capabilities:0x%x\n" , netxen_nic_driver_name, adapter->intr_scheme);DPRINTK (INFO ,"Receive Peg ready too. starting stuff\n" );
@@ -701,7 +701,7 @@ void netxen_nic_pci_change_crbwindow(str adapter->curr_window =0 ; } -void netxen_load_firmware (struct netxen_adapter *adapter) +int netxen_load_firmware (struct netxen_adapter *adapter) {int i;u32 data, size =0 ;
@@ -713,15 +713,24 @@ void netxen_load_firmware(struct netxen_writel (1 ,NETXEN_CRB_NORMALIZE (adapter,NETXEN_ROMUSB_GLB_CAS_RST ));for (i =0 ; i < size; i++) { -if (netxen_rom_fast_read (adapter, flashaddr, (int *)&data) !=0 ) { -DPRINTK (ERR , -"Error in netxen_rom_fast_read(). Will skip" -"loading flash image\n" ); -return ; - } +int retries =10 ; +if (netxen_rom_fast_read (adapter, flashaddr, (int *)&data) !=0 ) +return -EIO ; + off =netxen_nic_pci_set_window (adapter, memaddr); addr =pci_base_offset (adapter, off);writel (data, addr); +do { +if (readl (addr) == data) +break ; +msleep_interruptible (100 ); +writel (data, addr); + }while (--retries); +if (!retries) { +printk (KERN_ERR "%s: firmware load aborted, write failed at 0x%x\n" , + netxen_nic_driver_name, memaddr); +return -EIO ; + } flashaddr +=4 ; memaddr +=4 ; }
@@ -731,7 +740,7 @@ void netxen_load_firmware(struct netxen_ NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));writel (0 ,NETXEN_CRB_NORMALIZE (adapter,NETXEN_ROMUSB_GLB_CAS_RST )); -udelay (100 ); +return 0 ; }int
drivers/net/netxen/netxen_nic_init.c +32 -22
116 lines not on this page · raw message
drivers/net/netxen/netxen_nic_main.c +80 -37
193 lines not on this page · raw message
Re: [PATCH 2/3] NetXen: Support per PCI-function interrupt mask registers
In reply to [email protected]Quoted 8 lines · On Saturday 30 June 2007 22:38:46 [email protected] wrote:
This patch updates the various access routines to access different control and status settings present in different register locations. This will fix problems related to working of different ports in multi Port card.
Signed-off by: Dhananjay Phadke <[email protected]> Signed-off by: Milan Bag <[email protected]>
drivers/net/netxen/netxen_nic.h struct net_device_stats *netxen_nic_get_ · line 1116
Quoted 7 lines
drivers/net/netxen/netxen_nic.h +7
-0+/* Window = 0 or 1 */ +if (!(adapter->flags &NETXEN_NIC_MSI_ENABLED )) { + do { + writel(0xffffffff, (void *) + (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_STATUS))); + mask = readl((void *) + (pci_base_offset(adapter, ISR_INT_VECTOR)));
I think you should add a small delay into this loop. Otherwise it depends on the speed of the CPU (and chipset) how big the total timeout (32) of the loop is. Could be too small on fast systems. Something like:
if (!(mask & 0x80)) break; udelay(10); } while (++count < 32);
and drop the next line.
Quoted 11 lines
drivers/net/netxen/netxen_nic.h +10
-0+ }while (((mask &0x80 ) !=0 ) && (++count <32 )); + +if ((mask &0x80 ) !=0 ) { +printk (KERN_NOTICE "Could not disable interrupt completely\n" ); + } + } + +DPRINTK (1 ,INFO ,"Done with Disable Int\n" ); + +return ; }
Signature · 1 line
Greetings Michael.
Re: [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload
In reply to [email protected]Quoted 8 lines · On Saturday 30 June 2007 22:38:47 [email protected] wrote:
These changes allow driver close routine to be called during module unload, to clean-up buffers and other software resources, flush queues etc. Also, hardware is reset to pristine state.
Signed-off-by Dhananjay Phadke <[email protected]>Signed-off-by Milan Bag <[email protected]>Signed-off-by Wen Xiong <[email protected]>
drivers/net/netxen/netxen_nic_hw.c void netxen_load_firmware(struct netxen_ · line 726
Quoted 7 lines
drivers/net/netxen/netxen_nic_hw.c +4
-0off =netxen_nic_pci_set_window (adapter, memaddr); addr =pci_base_offset (adapter, off);writel (data, addr); + do { + if (readl(addr) == data) + break; + msleep_interruptible(100);
If you use msleep_interruptible(), I'd say you should check for the return value of that call and probably abort firmware processing here if a signal interrupted us.
drivers/net/netxen/netxen_nic_init.c int netxen_pinit_from_rom(struct netxen_ · line 856
Quoted 8 lines
drivers/net/netxen/netxen_nic_init.c +1
-1netxen_nic_reg_write (adapter,NETXEN_ROMUSB_ROM_ADDRESS , addr);netxen_nic_reg_write (adapter,NETXEN_ROMUSB_ROM_ABYTE_CNT ,3 );@@ -856,10 +853,10 @@ int netxen_pinit_from_rom(struct netxen_netxen_nic_pci_change_crbwindow (adapter,1 ); }if (init_delay ==1 ) { -ssleep (1 ); +ssleep (2 );
Is it possible/desired to do some interruptible sleep here? Two seconds uninterruptible sleep is probably a long time. Even at init/boot.
drivers/net/netxen/netxen_nic_main.c netxen_nic_probe(struct pci_dev *pdev, c · line 515
Quoted 10 lines
Index:
netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===================================================================drivers/net/netxen/netxen_nic_main.c +2
-0@@ -511,6 +511,8 @@ netxen_nic_probe(struct pci_dev *pdev, c val |=0x4 ;netxen_nic_write_w0 (adapter,NETXEN_PCIE_REG (0x4 ), val);netxen_nic_read_w0 (adapter,NETXEN_PCIE_REG (0x4 ), &val); +if (!(val &0x4 )) +printk (KERN_ERR "NetXen: bit set failed\n" );
That's the award for the most useless error message. :P Can you give the user a hint what this bit is about?
Quoted 16 lines
drivers/net/netxen/netxen_nic_main.c +16
-0+if (adapter->portnum ==0 ) { +if (init_firmware_done) { +dma_watchdog_shutdown_request (adapter); +msleep (100 ); + i =100 ; +while ((dma_watchdog_shutdown_poll_result (adapter) !=1 ) && i) { +printk (KERN_INFO "dma_watchdog_shutdown_poll still in progress\n" ); +msleep (100 ); + i--; + } + +if (i ==0 ) { +printk (KERN_ERR "dma_watchdog_shutdown_request failed\n" ); +return ; + } +
drivers/net/netxen/netxen_nic_main.c static void __devexit netxen_nic_remove( · line 713
Quoted 10 lines
drivers/net/netxen/netxen_nic_main.c +10
-0+/* clear the register for future unloads/loads */ +writel (0 ,NETXEN_CRB_NORMALIZE (adapter,NETXEN_CAM_RAM (0x1fc ))); +printk (KERN_INFO "State: 0x%0x\n" , +readl (NETXEN_CRB_NORMALIZE (adapter,CRB_CMDPEG_STATE ))); + +/* leave the hw in the same state as reboot */ +writel (0 ,NETXEN_CRB_NORMALIZE (adapter,CRB_CMDPEG_STATE )); +if (netxen_pinit_from_rom (adapter,0 )) +return ; +udelay (500 );
I guess we can do msleep(1) here, too, instead of the huge delay, although it's twice as long.
Though, I could live with a 500us delay, too, if that's desired.
The rest looks pretty good to me.
Signature · 1 line
Greetings Michael.
Re: [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload
Quoted 9 lines · Michael Buesch
Quoted 7 lines · On Saturday 30 June 2007 22:38:47 [email protected] wrote:
These changes allow driver close routine to be called during module unload, to clean-up buffers and other software resources, flush queues etc. Also, hardware is reset to pristine state.
Signed-off-by Dhananjay Phadke <[email protected]>Signed-off-by Milan Bag <[email protected]>Signed-off-by Wen Xiong <[email protected]>
Quoted 11 lines
drivers/net/netxen/netxen_nic_hw.c void netxen_load_firmware(struct netxen_ · line 726
Quoted 7 lines
drivers/net/netxen/netxen_nic_hw.c +4
-0off =netxen_nic_pci_set_window (adapter, memaddr); addr =pci_base_offset (adapter, off);writel (data, addr); + do { + if (readl(addr) == data) + break; + msleep_interruptible(100);If you use
msleep_interruptible(), I'd say you should check for the return value of that call and probably abort firmware processing here if a signal interrupted us.
While strictly this is true, I strongly urge the use of non-interruptible sleeps when used in hardware-related delays. Very rarely does one really want to care about signals for such cases.
Jeff
Re: [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload
This stage is safe to bail out on signal. It's initializing about a hundred registers
and trying to guaranty by retrying, so can get stretched too much on faulty h/w.
-Dhananjay
Quoted 5 lines · Jeff Garzik
While strictly this is true, I strongly urge the use of non-interruptible sleeps when used in hardware-related delays. Very rarely does one really want to care about signals for such cases.
Jeff
Re: [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload
Quoted 3 lines · Dhananjay Phadke
This stage is safe to bail out on signal. It's initializing about a hundred registers
and trying to guaranty by retrying, so can get stretched too much on faulty h/w.
This implies that you have -add- code to check for and handle signals at each delay point. Don't bother. Too much code bloat for negligable gain.
It is better just to remove the _interruptible, for many reasons.
Jeff