sky2 update for net-next
Subsystems (2)
cover sky2 update for net-next
Several little fixes:
* Change WoL setup to fix http://bugzilla.kernel.org/show_bug.cgi?id=13764
* Change Jumbo settings for some chips
* Mike's changes to avoid free and alloc on driver recovery
PATCH 1/10 sky2: fix sparse warning
Warning about hidden variable
drivers/net/sky2.c +1 -1
@@ -3128,7 +3128,7 @@ static void sky2_reset(struct sky2_hw *h/* check if PSMv2 was running before */ reg =sky2_pci_read16 (hw,PSM_CONFIG_REG3 );if (reg &PCI_EXP_LNKCTL_ASPMC ) { -int cap =pci_find_capability (pdev,PCI_CAP_ID_EXP ); + cap =pci_find_capability (pdev,PCI_CAP_ID_EXP );/* restore the PCIe Link Control register */ sky2_pci_write16 (hw, cap +PCI_EXP_LNKCTL , reg); }
PATCH 2/10 sky2: WoL changes
In reply to Stephen HemmingerChange Wake On Lan code to be similar to vendor driver. The definition of Y2_HW_WOL_ON is confusing; what it means is transition to firmware SPI setting when doing power change.
Since same code is done for both shutdown and suspend, use common code path.
drivers/net/sky2.c +9 -56
@@ -251,6 +251,8 @@ static void sky2_power_on(struct sky2_hwsky2_pci_write32 (hw,PCI_CFG_REG_1 ,0 ); +sky2_write16 (hw,B0_CTST ,Y2_HW_WOL_ON ); +/* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */ reg =sky2_read32 (hw,B2_GP_IO ); reg |=GLB_GPIO_STAT_RACE_DIS ;
@@ -782,6 +784,9 @@ static void sky2_wol_init(struct sky2_po ctrl |=WOL_CTL_DIS_PME_ON_PATTERN |WOL_CTL_DIS_PATTERN_UNIT ;sky2_write16 (hw,WOL_REGS (port,WOL_CTRL_STAT ), ctrl); +/* Disable PiG firmware */ +sky2_write16 (hw,B0_CTST ,Y2_HW_WOL_OFF ); +/* Turn on legacy PCI-Express PME mode */ reg1 =sky2_pci_read32 (hw,PCI_DEV_REG1 ); reg1 |=PCI_Y2_PME_LEGACY ;
@@ -789,7 +794,6 @@ static void sky2_wol_init(struct sky2_po/* block receiver */ sky2_write8 (hw,SK_REG (port,RX_GMF_CTRL_T ),GMF_RST_SET ); - }static void sky2_set_tx_stfwd (struct sky2_hw *hw,unsigned port)
@@ -3272,27 +3276,6 @@ static inline u8 sky2_wol_supported(consreturn sky2_is_copper (hw) ? (WAKE_PHY |WAKE_MAGIC ) :0 ; } -static void sky2_hw_set_wol (struct sky2_hw *hw) -{ -int wol =0 ; -int i; - -for (i =0 ; i < hw->ports; i++) { -struct net_device *dev = hw->dev[i]; -struct sky2_port *sky2 =netdev_priv (dev); - -if (sky2->wol) - wol =1 ; - } - -if (hw->chip_id ==CHIP_ID_YUKON_EC_U || - hw->chip_id ==CHIP_ID_YUKON_EX || - hw->chip_id ==CHIP_ID_YUKON_FE_P ) -sky2_write32 (hw,B0_CTST , wol ?Y2_HW_WOL_ON :Y2_HW_WOL_OFF ); - -device_set_wakeup_enable (&hw->pdev->dev, wol); -} -static void sky2_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol) {const struct sky2_port *sky2 =netdev_priv (dev);
@@ -3311,11 +3294,6 @@ static int sky2_set_wol(struct net_devicreturn -EOPNOTSUPP ; sky2->wol = wol->wolopts; - -sky2_hw_set_wol (hw); - -if (!netif_running (dev)) -sky2_wol_init (sky2);return 0 ; }
@@ -4809,7 +4787,6 @@ static void __devexit sky2_remove(structpci_set_drvdata (pdev,NULL ); } -#ifdef CONFIG_PM static int sky2_suspend (struct pci_dev *pdev,pm_message_t state) {struct sky2_hw *hw =pci_get_drvdata (pdev);
@@ -4834,6 +4811,8 @@ static int sky2_suspend(struct pci_dev * wol |= sky2->wol; } +device_set_wakeup_enable (&pdev->dev, wol !=0 ); +sky2_write32 (hw,B0_IMSK ,0 );napi_disable (&hw->napi);sky2_power_aux (hw);
@@ -4846,6 +4825,7 @@ static int sky2_suspend(struct pci_dev *return 0 ; } +#ifdef CONFIG_PM static int sky2_resume (struct pci_dev *pdev) {struct sky2_hw *hw =pci_get_drvdata (pdev);
@@ -4895,34 +4875,7 @@ out:static void sky2_shutdown (struct pci_dev *pdev) { -struct sky2_hw *hw =pci_get_drvdata (pdev); -int i, wol =0 ; - -if (!hw) -return ; - -rtnl_lock (); -del_timer_sync (&hw->watchdog_timer); - -for (i =0 ; i < hw->ports; i++) { -struct net_device *dev = hw->dev[i]; -struct sky2_port *sky2 =netdev_priv (dev); - -if (sky2->wol) { - wol =1 ; -sky2_wol_init (sky2); - } - } - -if (wol) -sky2_power_aux (hw); -rtnl_unlock (); - -pci_enable_wake (pdev, PCI_D3hot, wol); -pci_enable_wake (pdev, PCI_D3cold, wol); - -pci_disable_device (pdev); -pci_set_power_state (pdev, PCI_D3hot); +sky2_suspend (pdev,PMSG_SUSPEND ); }static struct pci_driver sky2_driver = {
PATCH 3/10 sky2: dont enable PME legacy mode
In reply to Stephen HemmingerThis bit is not changed by vendor driver, and should be left alone. The documentation implies this a debug bit.
0 = WAKE# only asserted when VMAIN not available
1 = WAKE# is depend on wake events and independent of VMAIN.
drivers/net/sky2.c +0 -6
@@ -733,7 +733,6 @@ static void sky2_wol_init(struct sky2_pounsigned port = sky2->port;enum flow_control save_mode;u16 ctrl; -u32 reg1;/* Bring hardware out of reset */ sky2_write16 (hw,B0_CTST ,CS_RST_CLR );
@@ -787,11 +786,6 @@ static void sky2_wol_init(struct sky2_po/* Disable PiG firmware */ sky2_write16 (hw,B0_CTST ,Y2_HW_WOL_OFF ); -/* Turn on legacy PCI-Express PME mode */ - reg1 =sky2_pci_read32 (hw,PCI_DEV_REG1 ); - reg1 |=PCI_Y2_PME_LEGACY ; -sky2_pci_write32 (hw,PCI_DEV_REG1 , reg1); -/* block receiver */ sky2_write8 (hw,SK_REG (port,RX_GMF_CTRL_T ),GMF_RST_SET ); }
PATCH 4/10 sky2: jumbo packet changes
In reply to Stephen HemmingerChange how FIFO is programmed in jumbo mode (to match vendor driver). Mostly cosmetic, the only register change is that the bits 22,23 are not programemd used.
--- drivers/net/sky2.c | 97 +++++++++++++++++++++++------------------------------ drivers/net/sky2.h | 8 ++-- 2 files changed, 47 insertions(+), 58 deletions(-)
drivers/net/sky2.h +4 -4
@@ -1895,14 +1895,14 @@ enum {/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ enum { -TX_STFW_DIS =1 <<31 ,/* Disable Store & Forward (Yukon-EC Ultra) */ -TX_STFW_ENA =1 <<30 ,/* Enable Store & Forward (Yukon-EC Ultra) */ +TX_STFW_DIS =1 <<31 ,/* Disable Store & Forward */ +TX_STFW_ENA =1 <<30 ,/* Enable Store & Forward */ TX_VLAN_TAG_ON =1 <<25 ,/* enable VLAN tagging */ TX_VLAN_TAG_OFF =1 <<24 ,/* disable VLAN tagging */ -TX_JUMBO_ENA =1 <<23 ,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */ -TX_JUMBO_DIS =1 <<22 ,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */ +TX_PCI_JUM_ENA =1 <<23 ,/* PCI Jumbo Mode enable */ +TX_PCI_JUM_DIS =1 <<22 ,/* PCI Jumbo Mode enable */ GMF_WSP_TST_ON =1 <<18 ,/* Write Shadow Pointer Test On */ GMF_WSP_TST_OFF =1 <<17 ,/* Write Shadow Pointer Test Off */
drivers/net/sky2.c +14 -22
@@ -798,29 +798,15 @@ static void sky2_set_tx_stfwd(struct sky hw->chip_rev != CHIP_REV_YU_EX_A0) || hw->chip_id >= CHIP_ID_YUKON_FE_P) {/* Yukon-Extreme B0 and further Extreme devices */ -/* enable Store & Forward mode for TX */ +sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ),TX_STFW_ENA ); + } else if (dev->mtu > ETH_DATA_LEN) { +/* set Tx GMAC FIFO Almost Empty Threshold */ +sky2_write32 (hw,SK_REG (port,TX_GMF_AE_THR ), + (ECU_JUMBO_WM <<16 ) |ECU_AE_THR ); -if (dev->mtu <=ETH_DATA_LEN ) -sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ), -TX_JUMBO_DIS |TX_STFW_ENA ); - -else -sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ), -TX_JUMBO_ENA |TX_STFW_ENA ); - } else { -if (dev->mtu <=ETH_DATA_LEN ) -sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ),TX_STFW_ENA ); -else { -/* set Tx GMAC FIFO Almost Empty Threshold */ -sky2_write32 (hw,SK_REG (port,TX_GMF_AE_THR ), - (ECU_JUMBO_WM <<16 ) |ECU_AE_THR ); - -sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ),TX_STFW_DIS ); - -/* Can't do offload because of lack of store/forward */ - dev->features &= ~(NETIF_F_TSO |NETIF_F_SG |NETIF_F_ALL_CSUM ); - } - } +sky2_write32 (hw,SK_REG (port,TX_GMF_CTRL_T ),TX_STFW_DIS ); + } else +sky2_write32 (hw ,SK_REG (port ,TX_GMF_CTRL_T ),TX_STFW_ENA ); }static void sky2_mac_init (struct sky2_hw *hw,unsigned port)
@@ -2206,14 +2192,20 @@ static int sky2_change_mtu(struct net_deu16 ctl, mode;u32 imask; +/* MTU size outside the spec */ if (new_mtu <ETH_ZLEN || new_mtu >ETH_JUMBO_MTU )return -EINVAL ; +/* MTU > 1500 on yukon FE and FE+ not allowed */ if (new_mtu >ETH_DATA_LEN && (hw->chip_id ==CHIP_ID_YUKON_FE || hw->chip_id ==CHIP_ID_YUKON_FE_P ))return -EINVAL ; +/* TSO, etc on Yukon Ultra and MTU > 1500 not supported */ +if (new_mtu >ETH_DATA_LEN && hw->chip_id ==CHIP_ID_YUKON_EC_U ) + dev->features &= ~(NETIF_F_TSO |NETIF_F_SG |NETIF_F_ALL_CSUM ); +if (!netif_running (dev)) { dev->mtu = new_mtu;return 0 ;
PATCH 5/10 sky2: Factor out code to calculate packet sizes
In reply to Stephen HemmingerFrom: Mike McCormack <[email protected]>
Move code to calculate receive threshold and packet size out of sky2_rx_start() so that is can be called from elsewhere easily.
--- drivers/net/sky2.c | 57 +++++++++++++++++++++++++++++++++------------------ 1 files changed, 37 insertions(+), 20 deletions(-)
drivers/net/sky2.c +37 -20
@@ -1049,6 +1049,40 @@ static inline struct sky2_rx_le *sky2_nereturn le; } +static unsigned sky2_get_rx_threshold (struct sky2_port * sky2) +{ +unsigned size; + +/* Space needed for frame data + headers rounded up */ + size =roundup (sky2->netdev->mtu +ETH_HLEN +VLAN_HLEN ,8 ); + +/* Stopping point for hardware truncation */ +return (size -8 ) /sizeof (u32); +} + +static unsigned sky2_get_rx_data_size (struct sky2_port * sky2) +{ +struct rx_ring_info *re; +unsigned size; + +/* Space needed for frame data + headers rounded up */ + size =roundup (sky2->netdev->mtu +ETH_HLEN +VLAN_HLEN ,8 ); + + sky2->rx_nfrags = size >>PAGE_SHIFT ; +BUG_ON (sky2->rx_nfrags >ARRAY_SIZE (re->frag_addr)); + +/* Compute residue after pages */ + size -= sky2->rx_nfrags <<PAGE_SHIFT ; + +/* Optimize to handle small packets and headers */ +if (size < copybreak) + size = copybreak; +if (size <ETH_HLEN ) + size =ETH_HLEN ; + +return size; +} +/* Build description to hardware for one receive segment */ static void sky2_rx_add (struct sky2_port *sky2,u8 op,dma_addr_t map,unsigned len)
@@ -1343,7 +1377,7 @@ static int sky2_rx_start(struct sky2_porstruct sky2_hw *hw = sky2->hw;struct rx_ring_info *re;unsigned rxq = rxqaddr[sky2->port]; -unsigned i, size, thresh; +unsigned i, thresh; sky2->rx_put = sky2->rx_next =0 ;sky2_qset (hw, rxq);
@@ -1364,25 +1398,7 @@ static int sky2_rx_start(struct sky2_porif (!(hw->flags &SKY2_HW_NEW_LE ))rx_set_checksum (sky2); -/* Space needed for frame data + headers rounded up */ - size =roundup (sky2->netdev->mtu +ETH_HLEN +VLAN_HLEN ,8 ); - -/* Stopping point for hardware truncation */ - thresh = (size -8 ) /sizeof (u32); - - sky2->rx_nfrags = size >>PAGE_SHIFT ; -BUG_ON (sky2->rx_nfrags >ARRAY_SIZE (re->frag_addr)); - -/* Compute residue after pages */ - size -= sky2->rx_nfrags <<PAGE_SHIFT ; - -/* Optimize to handle small packets and headers */ -if (size < copybreak) - size = copybreak; -if (size <ETH_HLEN ) - size =ETH_HLEN ; - - sky2->rx_data_size = size; + sky2->rx_data_size =sky2_get_rx_data_size (sky2);/* Fill Rx ring */ for (i =0 ; i < sky2->rx_pending; i++) {
@@ -1407,6 +1423,7 @@ static int sky2_rx_start(struct sky2_por* the register is limited to 9 bits, so if you do frames > 2052 * you better get the MTU right! */ + thresh =sky2_get_rx_threshold (sky2);if (thresh >0x1ff )sky2_write32 (hw,SK_REG (sky2->port,RX_GMF_CTRL_T ),RX_TRUNC_OFF );else {
PATCH 6/10 sky2: Allocate initial skbs in sky2_alloc_buffers
In reply to Stephen HemmingerFrom: Mike McCormack <[email protected]>
Allocate everything in one place so there's a single point of failure in sky2_up, and sky2_rx_start can no longer fail.
Don't leave the hardware in a partially initialized state in the case rx ring allocation fails.
As with the old code, the rx ring still needs to be fully allocated for sky2_up to succeed.
--- drivers/net/sky2.c | 68 +++++++++++++++++++++++++++++----------------------- 1 files changed, 38 insertions(+), 30 deletions(-)
drivers/net/sky2.c +36 -30
@@ -1363,8 +1363,32 @@ static inline void sky2_rx_update(structsky2_put_idx (sky2->hw, rxq, sky2->rx_put); } +static int sky2_alloc_rx_skbs (struct sky2_port *sky2) +{ +struct sky2_hw *hw = sky2->hw; +unsigned i; + + sky2->rx_data_size =sky2_get_rx_data_size (sky2); + +/* Fill Rx ring */ +for (i =0 ; i < sky2->rx_pending; i++) { +struct rx_ring_info *re = sky2->rx_ring + i; + + re->skb =sky2_rx_alloc (sky2); +if (!re->skb) +return -ENOMEM ; + +if (sky2_rx_map_skb (hw->pdev, re, sky2->rx_data_size)) { +dev_kfree_skb (re->skb); + re->skb =NULL ; +return -ENOMEM ; + } + } +return 0 ; +} +/* -* Allocate and setup receiver buffer pool. +* Setup receiver buffer pool. * Normal case this ends up creating one list element for skb * in the receive ring. Worst case if using large MTU and each * allocation falls on a different 64 bit region, that results
@@ -1372,7 +1396,7 @@ static inline void sky2_rx_update(struct* One element is used for checksum enable/disable, and one * extra to avoid wrap. */ -static int sky2_rx_start (struct sky2_port *sky2) +static void sky2_rx_start (struct sky2_port *sky2) {struct sky2_hw *hw = sky2->hw;struct rx_ring_info *re;
@@ -1398,22 +1422,9 @@ static int sky2_rx_start(struct sky2_porif (!(hw->flags &SKY2_HW_NEW_LE ))rx_set_checksum (sky2); - sky2->rx_data_size =sky2_get_rx_data_size (sky2); - -/* Fill Rx ring */ +/* submit Rx ring */ for (i =0 ; i < sky2->rx_pending; i++) { re = sky2->rx_ring + i; - - re->skb =sky2_rx_alloc (sky2); -if (!re->skb) - goto nomem; - -if (sky2_rx_map_skb (hw->pdev, re, sky2->rx_data_size)) { -dev_kfree_skb (re->skb); - re->skb =NULL ; - goto nomem; - } -sky2_rx_submit (sky2, re); }
@@ -1455,13 +1466,6 @@ static int sky2_rx_start(struct sky2_porsky2_write32 (hw,Q_ADDR (txqaddr[sky2->port],Q_TEST ),TBMU_TEST_HOME_ADD_FIX_EN |TBMU_TEST_ROUTING_ADD_FIX_EN ); } - - - -return 0 ; -nomem: -sky2_rx_clean (sky2); -return -ENOMEM ; }static int sky2_alloc_buffers (struct sky2_port *sky2)
@@ -1492,7 +1496,7 @@ static int sky2_alloc_buffers(struct skyif (!sky2->rx_ring) goto nomem; -return 0 ; +return sky2_alloc_rx_skbs (sky2); nomem:return -ENOMEM ; }
@@ -1501,6 +1505,8 @@ static void sky2_free_buffers(struct sky {struct sky2_hw *hw = sky2->hw; +sky2_rx_clean (sky2); +if (sky2->rx_le) {pci_free_consistent (hw->pdev,RX_LE_BYTES , sky2->rx_le, sky2->rx_le_map);
@@ -1590,9 +1596,7 @@ static int sky2_up(struct net_device *desky2_set_vlan_mode (hw, port, sky2->vlgrp !=NULL );#endif - err =sky2_rx_start (sky2); -if (err) - goto err_out; +sky2_rx_start (sky2);/* Enable interrupts from phy/mac for port */ imask =sky2_read32 (hw,B0_IMSK );
@@ -1960,8 +1964,6 @@ static int sky2_down(struct net_device */* Free any pending frames stuck in HW queue */ sky2_tx_complete (sky2, sky2->tx_prod); -sky2_rx_clean (sky2); -sky2_free_buffers (sky2);return 0 ;
@@ -2257,7 +2259,11 @@ static int sky2_change_mtu(struct net_desky2_write8 (hw,RB_ADDR (rxqaddr[port],RB_CTRL ),RB_ENA_OP_MD ); - err =sky2_rx_start (sky2); + err =sky2_alloc_rx_skbs (sky2); +if (!err) +sky2_rx_start (sky2); +else +sky2_rx_clean (sky2);sky2_write32 (hw,B0_IMSK , imask);sky2_read32 (hw,B0_Y2_SP_LISR );
PATCH 7/10 sky2: Refactor sky2_up into two functions
In reply to Stephen HemmingerFrom: Mike McCormack <[email protected]>
Move hardware initialization into sky2_hw_up.
--- drivers/net/sky2.c | 41 +++++++++++++++++++++++++---------------- 1 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/sky2.c +25 -16
@@ -1525,16 +1525,16 @@ static void sky2_free_buffers(struct sky sky2->rx_ring =NULL ; } -/* Bring up network interface. */ -static int sky2_up (struct net_device *dev) +static void sky2_hw_up (struct sky2_port *sky2) { -struct sky2_port *sky2 =netdev_priv (dev);struct sky2_hw *hw = sky2->hw;unsigned port = sky2->port; -u32 imask, ramsize; -int cap, err; +u32 ramsize; +int cap;struct net_device *otherdev = hw->dev[sky2->port^1 ]; +tx_init (sky2); +/* * On dual port PCI-X card, there is an problem where status * can be received out of order due to split transactions
@@ -1546,16 +1546,7 @@ static int sky2_up(struct net_device *de cmd =sky2_pci_read16 (hw, cap +PCI_X_CMD ); cmd &= ~PCI_X_CMD_MAX_SPLIT ;sky2_pci_write16 (hw, cap +PCI_X_CMD , cmd); - - } - -netif_carrier_off (dev); - - err =sky2_alloc_buffers (sky2); -if (err) - goto err_out; - -tx_init (sky2); + }sky2_mac_init (hw, port);
@@ -1564,7 +1555,7 @@ static int sky2_up(struct net_device *deif (ramsize >0 ) {u32 rxspace; -pr_debug (PFX "%s: ram buffer %dK\n" , dev->name, ramsize); +pr_debug (PFX "%s: ram buffer %dK\n" , sky2->netdev->name, ramsize);if (ramsize <16 ) rxspace = ramsize /2 ;else
@@ -1597,6 +1588,24 @@ static int sky2_up(struct net_device *de#endif sky2_rx_start (sky2); +} + +/* Bring up network interface. */ +static int sky2_up (struct net_device *dev) +{ +struct sky2_port *sky2 =netdev_priv (dev); +struct sky2_hw *hw = sky2->hw; +unsigned port = sky2->port; +u32 imask; +int err; + +netif_carrier_off (dev); + + err =sky2_alloc_buffers (sky2); +if (err) + goto err_out; + +sky2_hw_up (sky2);/* Enable interrupts from phy/mac for port */ imask =sky2_read32 (hw,B0_IMSK );
PATCH 8/10 sky2: Refactor sky2_down into two functions
In reply to Stephen HemmingerFrom: Mike McCormack <[email protected]>
Create a sky2_hw_down that brings the hardware down.
--- drivers/net/sky2.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-)
drivers/net/sky2.c +17 -11
@@ -1908,21 +1908,12 @@ static void sky2_tx_reset(struct sky2_hwsky2_write8 (hw,SK_REG (port,TX_GMF_CTRL_T ),GMF_RST_SET ); } -/* Network shutdown */ -static int sky2_down (struct net_device *dev) +static void sky2_hw_down (struct sky2_port *sky2) { -struct sky2_port *sky2 =netdev_priv (dev);struct sky2_hw *hw = sky2->hw;unsigned port = sky2->port; -u16 ctrl;u32 imask; - -/* Never really got started! */ -if (!sky2->tx_le) -return 0 ; - -if (netif_msg_ifdown (sky2)) - printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); +u16 ctrl;/* Force flow control off */ sky2_write8 (hw,SK_REG (port,GMAC_CTRL ),GMC_PAUSE_OFF );
@@ -1972,6 +1963,21 @@ static int sky2_down(struct net_device */* Free any pending frames stuck in HW queue */ sky2_tx_complete (sky2, sky2->tx_prod); +} + +/* Network shutdown */ +static int sky2_down (struct net_device *dev) +{ +struct sky2_port *sky2 =netdev_priv (dev); + +/* Never really got started! */ +if (!sky2->tx_le) +return 0 ; + +if (netif_msg_ifdown (sky2)) + printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); + +sky2_hw_down (sky2);sky2_free_buffers (sky2);
PATCH 9/10 sky2: Avoid down and up during sky2_reset
In reply to Stephen HemmingerFrom: Mike McCormack <[email protected]>
Rewrite sky2_reset to work with interrupts disabled and
avoid freeing and reallocing memory.
The old code used sky2_down and sky2_up to implement sky2_reset,
which meant interrupts could not be disabled, and the transmit and receive ring buffers would be free'd and reallocated.
To avoid the interrupt handler waking the transmit queue while
we're doing a reset, it's better to have interrupts and NAPI polls disabled.
Note: Modified Mike's patch to do IRQ disable in sky2_down before
calling sky2_hw_down - Stephen
--- drivers/net/sky2.c | 68 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 21 deletions(-)
drivers/net/sky2.c +47 -21
@@ -1880,10 +1880,6 @@ static void sky2_tx_complete(struct sky2 sky2->tx_cons = idx;smp_mb (); - -/* Wake unless it's detached, and called e.g. from sky2_down() */ -if (tx_avail (sky2) >MAX_SKB_TX_LE +4 &&netif_device_present (dev)) -netif_wake_queue (dev); }static void sky2_tx_reset (struct sky2_hw *hw,unsigned port)
@@ -1912,7 +1908,6 @@ static void sky2_hw_down(struct sky2_por {struct sky2_hw *hw = sky2->hw;unsigned port = sky2->port; -u32 imask;u16 ctrl;/* Force flow control off */
@@ -1946,15 +1941,6 @@ static void sky2_hw_down(struct sky2_porsky2_rx_stop (sky2); -/* Disable port IRQ */ - imask =sky2_read32 (hw,B0_IMSK ); - imask &= ~portirq_msk[port]; -sky2_write32 (hw,B0_IMSK , imask); -sky2_read32 (hw,B0_IMSK ); - -synchronize_irq (hw->pdev->irq); -napi_synchronize (&hw->napi); -spin_lock_bh (&sky2->phy_lock);sky2_phy_power_down (hw, port);spin_unlock_bh (&sky2->phy_lock);
@@ -1969,6 +1955,7 @@ static void sky2_hw_down(struct sky2_porstatic int sky2_down (struct net_device *dev) {struct sky2_port *sky2 =netdev_priv (dev); +struct sky2_hw *hw = sky2->hw;/* Never really got started! */ if (!sky2->tx_le)
@@ -1977,6 +1964,14 @@ static int sky2_down(struct net_device *if (netif_msg_ifdown (sky2)) printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); +/* Disable port IRQ */ +sky2_write32 (hw,B0_IMSK , +sky2_read32 (hw,B0_IMSK ) & ~portirq_msk[sky2->port]); +sky2_read32 (hw,B0_IMSK ); + +synchronize_irq (hw->pdev->irq); +napi_synchronize (&hw->napi); +sky2_hw_down (sky2);sky2_free_buffers (sky2);
@@ -2475,8 +2470,13 @@ static inline void sky2_tx_done(struct n {struct sky2_port *sky2 =netdev_priv (dev); -if (netif_running (dev)) +if (netif_running (dev)) {sky2_tx_complete (sky2, last); + +/* Wake unless it's detached, and called e.g. from sky2_down() */ +if (tx_avail (sky2) >MAX_SKB_TX_LE +4 ) +netif_wake_queue (dev); + } } static inline void sky2_skb_rx(const struct sky2_port *sky2,
@@ -3277,20 +3277,46 @@ static int sky2_reattach(struct net_devistatic void sky2_restart (struct work_struct *work) { struct sky2_hw *hw = container_of(work, struct sky2_hw, restart_work); +u32 imask;int i;rtnl_lock (); -for (i =0 ; i < hw->ports; i++) -sky2_detach (hw->dev[i]);napi_disable (&hw->napi); +synchronize_irq (hw->pdev->irq); + imask =sky2_read32 (hw,B0_IMSK );sky2_write32 (hw,B0_IMSK ,0 ); + +for (i =0 ; i < hw->ports; i++) { +struct net_device *dev = hw->dev[i]; +struct sky2_port *sky2 =netdev_priv (dev); + +if (!netif_running (dev)) +continue ; + +netif_carrier_off (dev); +netif_tx_disable (dev); +sky2_hw_down (sky2); + } +sky2_reset (hw); -sky2_write32 (hw,B0_IMSK ,Y2_IS_BASE ); -napi_enable (&hw->napi); -for (i =0 ; i < hw->ports; i++) -sky2_reattach (hw->dev[i]); +for (i =0 ; i < hw->ports; i++) { +struct net_device *dev = hw->dev[i]; +struct sky2_port *sky2 =netdev_priv (dev); + +if (!netif_running (dev)) +continue ; + +sky2_hw_up (sky2); +netif_wake_queue (dev); + } + +sky2_write32 (hw,B0_IMSK , imask); +sky2_read32 (hw,B0_IMSK ); + +sky2_read32 (hw,B0_Y2_SP_LISR ); +napi_enable (&hw->napi);rtnl_unlock (); }
PATCH 10/10 sky2: version 1.27
In reply to Stephen Hemmingerdrivers/net/sky2.c +1 -1
@@ -50,7 +50,7 @@#include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "1.26" +#define DRV_VERSION "1.27"#define PFX DRV_NAME " "/*
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Fri, 12 Feb 2010 08:57:57 -0800
Quoted 4 lines
Several little fixes:
* Change WoL setup to fix http://bugzilla.kernel.org/show_bug.cgi?id=13764
* Change Jumbo settings for some chips
* Mike's changes to avoid free and alloc on driver recovery
All applied to net-next-2.6, thanks!