/[linux-patches]/genpatches-2.6/trunk/2.6.15/1011_1__skge-memory-on-ring-changes.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.15/1011_1__skge-memory-on-ring-changes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 255 - (hide annotations) (download) (as text)
Wed Jan 11 21:15:20 2006 UTC (14 years, 6 months ago) by dsd
Original Path: genpatches-2.6/trunk/2.6.15/2100_skge-memory-on-ring-changes.patch
File MIME type: text/x-diff
File size: 6120 byte(s)
Several patches from 2.6.15.1 queue
1 dsd 255 From stable-bounces@linux.kernel.org Wed Jan 4 15:55:59 2006
2     Date: Wed, 4 Jan 2006 15:52:28 -0800
3     From: Stephen Hemminger <shemminger@osdl.org>
4     To: stable@kernel.org
5     Message-ID: <20060104155228.014d6326@dxpl.pdx.osdl.net>
6     Subject: [PATCH] skge: handle out of memory on ring changes
7    
8     Please consider this for 2.6.15.1; it fixes several cases where
9     the skge driver can get in a bad state and later crash; if an
10     admin operation that causes a restart fails from out of memory.
11     Such as changing the MTU or increasing the ring size.
12    
13     The fixes involve checking the return value and doing necessary
14     unwinds. Or in some cases avoiding doing a full restart.
15    
16     The same code is the netdev-2.6 tree for 2.6.16 but as separate pieces
17    
18     Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
19     Signed-off-by: Chris Wright <chrisw@sous-sol.org>
20     Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
21     ---
22    
23    
24     drivers/net/skge.c | 80 +++++++++++++++++++++++++++++++----------------------
25     1 files changed, 48 insertions(+), 32 deletions(-)
26    
27     Index: linux-2.6.15.y/drivers/net/skge.c
28     ===================================================================
29     --- linux-2.6.15.y.orig/drivers/net/skge.c
30     +++ linux-2.6.15.y/drivers/net/skge.c
31     @@ -43,7 +43,7 @@
32     #include "skge.h"
33    
34     #define DRV_NAME "skge"
35     -#define DRV_VERSION "1.2"
36     +#define DRV_VERSION "1.3"
37     #define PFX DRV_NAME " "
38    
39     #define DEFAULT_TX_RING_SIZE 128
40     @@ -88,15 +88,14 @@ MODULE_DEVICE_TABLE(pci, skge_id_table);
41    
42     static int skge_up(struct net_device *dev);
43     static int skge_down(struct net_device *dev);
44     +static void skge_phy_reset(struct skge_port *skge);
45     static void skge_tx_clean(struct skge_port *skge);
46     static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
47     static int gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
48     static void genesis_get_stats(struct skge_port *skge, u64 *data);
49     static void yukon_get_stats(struct skge_port *skge, u64 *data);
50     static void yukon_init(struct skge_hw *hw, int port);
51     -static void yukon_reset(struct skge_hw *hw, int port);
52     static void genesis_mac_init(struct skge_hw *hw, int port);
53     -static void genesis_reset(struct skge_hw *hw, int port);
54     static void genesis_link_up(struct skge_port *skge);
55    
56     /* Avoid conditionals by using array */
57     @@ -276,10 +275,9 @@ static int skge_set_settings(struct net_
58     skge->autoneg = ecmd->autoneg;
59     skge->advertising = ecmd->advertising;
60    
61     - if (netif_running(dev)) {
62     - skge_down(dev);
63     - skge_up(dev);
64     - }
65     + if (netif_running(dev))
66     + skge_phy_reset(skge);
67     +
68     return (0);
69     }
70    
71     @@ -399,6 +397,7 @@ static int skge_set_ring_param(struct ne
72     struct ethtool_ringparam *p)
73     {
74     struct skge_port *skge = netdev_priv(dev);
75     + int err;
76    
77     if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE ||
78     p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE)
79     @@ -409,7 +408,11 @@ static int skge_set_ring_param(struct ne
80    
81     if (netif_running(dev)) {
82     skge_down(dev);
83     - skge_up(dev);
84     + err = skge_up(dev);
85     + if (err)
86     + dev_close(dev);
87     + else
88     + dev->set_multicast_list(dev);
89     }
90    
91     return 0;
92     @@ -430,21 +433,11 @@ static void skge_set_msglevel(struct net
93     static int skge_nway_reset(struct net_device *dev)
94     {
95     struct skge_port *skge = netdev_priv(dev);
96     - struct skge_hw *hw = skge->hw;
97     - int port = skge->port;
98    
99     if (skge->autoneg != AUTONEG_ENABLE || !netif_running(dev))
100     return -EINVAL;
101    
102     - spin_lock_bh(&hw->phy_lock);
103     - if (hw->chip_id == CHIP_ID_GENESIS) {
104     - genesis_reset(hw, port);
105     - genesis_mac_init(hw, port);
106     - } else {
107     - yukon_reset(hw, port);
108     - yukon_init(hw, port);
109     - }
110     - spin_unlock_bh(&hw->phy_lock);
111     + skge_phy_reset(skge);
112     return 0;
113     }
114    
115     @@ -516,10 +509,8 @@ static int skge_set_pauseparam(struct ne
116     else
117     skge->flow_control = FLOW_MODE_NONE;
118    
119     - if (netif_running(dev)) {
120     - skge_down(dev);
121     - skge_up(dev);
122     - }
123     + if (netif_running(dev))
124     + skge_phy_reset(skge);
125     return 0;
126     }
127    
128     @@ -1935,7 +1926,6 @@ static void yukon_link_down(struct skge_
129    
130     }
131    
132     - yukon_reset(hw, port);
133     skge_link_down(skge);
134    
135     yukon_init(hw, port);
136     @@ -2019,6 +2009,22 @@ static void yukon_phy_intr(struct skge_p
137     /* XXX restart autonegotiation? */
138     }
139    
140     +static void skge_phy_reset(struct skge_port *skge)
141     +{
142     + struct skge_hw *hw = skge->hw;
143     + int port = skge->port;
144     +
145     + netif_stop_queue(skge->netdev);
146     + netif_carrier_off(skge->netdev);
147     +
148     + spin_lock_bh(&hw->phy_lock);
149     + if (hw->chip_id == CHIP_ID_GENESIS)
150     + genesis_mac_init(hw, port);
151     + else
152     + yukon_init(hw, port);
153     + spin_unlock_bh(&hw->phy_lock);
154     +}
155     +
156     /* Basic MII support */
157     static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
158     {
159     @@ -2187,6 +2193,7 @@ static int skge_up(struct net_device *de
160     kfree(skge->rx_ring.start);
161     free_pci_mem:
162     pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
163     + skge->mem = NULL;
164    
165     return err;
166     }
167     @@ -2197,6 +2204,9 @@ static int skge_down(struct net_device *
168     struct skge_hw *hw = skge->hw;
169     int port = skge->port;
170    
171     + if (skge->mem == NULL)
172     + return 0;
173     +
174     if (netif_msg_ifdown(skge))
175     printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
176    
177     @@ -2253,6 +2263,7 @@ static int skge_down(struct net_device *
178     kfree(skge->rx_ring.start);
179     kfree(skge->tx_ring.start);
180     pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
181     + skge->mem = NULL;
182     return 0;
183     }
184    
185     @@ -2413,18 +2424,23 @@ static void skge_tx_timeout(struct net_d
186    
187     static int skge_change_mtu(struct net_device *dev, int new_mtu)
188     {
189     - int err = 0;
190     - int running = netif_running(dev);
191     + int err;
192    
193     if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
194     return -EINVAL;
195    
196     + if (!netif_running(dev)) {
197     + dev->mtu = new_mtu;
198     + return 0;
199     + }
200     +
201     + skge_down(dev);
202    
203     - if (running)
204     - skge_down(dev);
205     dev->mtu = new_mtu;
206     - if (running)
207     - skge_up(dev);
208     +
209     + err = skge_up(dev);
210     + if (err)
211     + dev_close(dev);
212    
213     return err;
214     }
215     @@ -3398,8 +3414,8 @@ static int skge_resume(struct pci_dev *p
216     struct net_device *dev = hw->dev[i];
217     if (dev) {
218     netif_device_attach(dev);
219     - if (netif_running(dev))
220     - skge_up(dev);
221     + if (netif_running(dev) && skge_up(dev))
222     + dev_close(dev);
223     }
224     }
225     return 0;

  ViewVC Help
Powered by ViewVC 1.1.20