Commit 16ecf85a authored by Linus Torvalds's avatar Linus Torvalds

e1000: fix stack size

Here's the patch. It shrinks the stack from 1152 bytes to 192 bytes (the
first version, that only did the e1000_option part, got it down to 600
bytes). About half comes from not using multiple "e1000_option"
structures, the other half comes from turning the "e1000_opt_list[]"
arrays into "static const" instead, so that gcc doesn't copy them onto the
stack.
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Reveiewed-by: default avatarAuke Kok <auke-jan.h.kok@intel.com>
Tested-by: default avatarEmil Tantilov <emil.s.tantilov@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0559bc8e
...@@ -208,7 +208,7 @@ struct e1000_option { ...@@ -208,7 +208,7 @@ struct e1000_option {
} r; } r;
struct { /* list_option info */ struct { /* list_option info */
int nr; int nr;
struct e1000_opt_list { int i; char *str; } *p; const struct e1000_opt_list { int i; char *str; } *p;
} l; } l;
} arg; } arg;
}; };
...@@ -242,7 +242,7 @@ static int __devinit e1000_validate_option(unsigned int *value, ...@@ -242,7 +242,7 @@ static int __devinit e1000_validate_option(unsigned int *value,
break; break;
case list_option: { case list_option: {
int i; int i;
struct e1000_opt_list *ent; const struct e1000_opt_list *ent;
for (i = 0; i < opt->arg.l.nr; i++) { for (i = 0; i < opt->arg.l.nr; i++) {
ent = &opt->arg.l.p[i]; ent = &opt->arg.l.p[i];
...@@ -279,7 +279,9 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter); ...@@ -279,7 +279,9 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter);
void __devinit e1000_check_options(struct e1000_adapter *adapter) void __devinit e1000_check_options(struct e1000_adapter *adapter)
{ {
struct e1000_option opt;
int bd = adapter->bd_number; int bd = adapter->bd_number;
if (bd >= E1000_MAX_NIC) { if (bd >= E1000_MAX_NIC) {
DPRINTK(PROBE, NOTICE, DPRINTK(PROBE, NOTICE,
"Warning: no configuration for board #%i\n", bd); "Warning: no configuration for board #%i\n", bd);
...@@ -287,19 +289,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -287,19 +289,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
{ /* Transmit Descriptor Count */ { /* Transmit Descriptor Count */
struct e1000_option opt = { struct e1000_tx_ring *tx_ring = adapter->tx_ring;
int i;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Transmit Descriptors", .name = "Transmit Descriptors",
.err = "using default of " .err = "using default of "
__MODULE_STRING(E1000_DEFAULT_TXD), __MODULE_STRING(E1000_DEFAULT_TXD),
.def = E1000_DEFAULT_TXD, .def = E1000_DEFAULT_TXD,
.arg = { .r = { .min = E1000_MIN_TXD }} .arg = { .r = {
.min = E1000_MIN_TXD,
.max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD
}}
}; };
struct e1000_tx_ring *tx_ring = adapter->tx_ring;
int i;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ?
E1000_MAX_TXD : E1000_MAX_82544_TXD;
if (num_TxDescriptors > bd) { if (num_TxDescriptors > bd) {
tx_ring->count = TxDescriptors[bd]; tx_ring->count = TxDescriptors[bd];
...@@ -313,19 +317,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -313,19 +317,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
tx_ring[i].count = tx_ring->count; tx_ring[i].count = tx_ring->count;
} }
{ /* Receive Descriptor Count */ { /* Receive Descriptor Count */
struct e1000_option opt = { struct e1000_rx_ring *rx_ring = adapter->rx_ring;
int i;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Receive Descriptors", .name = "Receive Descriptors",
.err = "using default of " .err = "using default of "
__MODULE_STRING(E1000_DEFAULT_RXD), __MODULE_STRING(E1000_DEFAULT_RXD),
.def = E1000_DEFAULT_RXD, .def = E1000_DEFAULT_RXD,
.arg = { .r = { .min = E1000_MIN_RXD }} .arg = { .r = {
.min = E1000_MIN_RXD,
.max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD
}}
}; };
struct e1000_rx_ring *rx_ring = adapter->rx_ring;
int i;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
E1000_MAX_82544_RXD;
if (num_RxDescriptors > bd) { if (num_RxDescriptors > bd) {
rx_ring->count = RxDescriptors[bd]; rx_ring->count = RxDescriptors[bd];
...@@ -339,7 +345,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -339,7 +345,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
rx_ring[i].count = rx_ring->count; rx_ring[i].count = rx_ring->count;
} }
{ /* Checksum Offload Enable/Disable */ { /* Checksum Offload Enable/Disable */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = enable_option, .type = enable_option,
.name = "Checksum Offload", .name = "Checksum Offload",
.err = "defaulting to Enabled", .err = "defaulting to Enabled",
...@@ -363,7 +369,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -363,7 +369,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
{ E1000_FC_FULL, "Flow Control Enabled" }, { E1000_FC_FULL, "Flow Control Enabled" },
{ E1000_FC_DEFAULT, "Flow Control Hardware Default" }}; { E1000_FC_DEFAULT, "Flow Control Hardware Default" }};
struct e1000_option opt = { opt = (struct e1000_option) {
.type = list_option, .type = list_option,
.name = "Flow Control", .name = "Flow Control",
.err = "reading default settings from EEPROM", .err = "reading default settings from EEPROM",
...@@ -381,7 +387,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -381,7 +387,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Transmit Interrupt Delay */ { /* Transmit Interrupt Delay */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Transmit Interrupt Delay", .name = "Transmit Interrupt Delay",
.err = "using default of " __MODULE_STRING(DEFAULT_TIDV), .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
...@@ -399,7 +405,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -399,7 +405,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Transmit Absolute Interrupt Delay */ { /* Transmit Absolute Interrupt Delay */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Transmit Absolute Interrupt Delay", .name = "Transmit Absolute Interrupt Delay",
.err = "using default of " __MODULE_STRING(DEFAULT_TADV), .err = "using default of " __MODULE_STRING(DEFAULT_TADV),
...@@ -417,7 +423,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -417,7 +423,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Receive Interrupt Delay */ { /* Receive Interrupt Delay */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Receive Interrupt Delay", .name = "Receive Interrupt Delay",
.err = "using default of " __MODULE_STRING(DEFAULT_RDTR), .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
...@@ -435,7 +441,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -435,7 +441,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Receive Absolute Interrupt Delay */ { /* Receive Absolute Interrupt Delay */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Receive Absolute Interrupt Delay", .name = "Receive Absolute Interrupt Delay",
.err = "using default of " __MODULE_STRING(DEFAULT_RADV), .err = "using default of " __MODULE_STRING(DEFAULT_RADV),
...@@ -453,7 +459,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -453,7 +459,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Interrupt Throttling Rate */ { /* Interrupt Throttling Rate */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = range_option, .type = range_option,
.name = "Interrupt Throttling Rate (ints/sec)", .name = "Interrupt Throttling Rate (ints/sec)",
.err = "using default of " __MODULE_STRING(DEFAULT_ITR), .err = "using default of " __MODULE_STRING(DEFAULT_ITR),
...@@ -497,7 +503,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -497,7 +503,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Smart Power Down */ { /* Smart Power Down */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = enable_option, .type = enable_option,
.name = "PHY Smart Power Down", .name = "PHY Smart Power Down",
.err = "defaulting to Disabled", .err = "defaulting to Disabled",
...@@ -513,7 +519,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) ...@@ -513,7 +519,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
} }
} }
{ /* Kumeran Lock Loss Workaround */ { /* Kumeran Lock Loss Workaround */
struct e1000_option opt = { opt = (struct e1000_option) {
.type = enable_option, .type = enable_option,
.name = "Kumeran Lock Loss Workaround", .name = "Kumeran Lock Loss Workaround",
.err = "defaulting to Enabled", .err = "defaulting to Enabled",
...@@ -578,16 +584,18 @@ static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter) ...@@ -578,16 +584,18 @@ static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter)
static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter)
{ {
struct e1000_option opt;
unsigned int speed, dplx, an; unsigned int speed, dplx, an;
int bd = adapter->bd_number; int bd = adapter->bd_number;
{ /* Speed */ { /* Speed */
struct e1000_opt_list speed_list[] = {{ 0, "" }, static const struct e1000_opt_list speed_list[] = {
{ SPEED_10, "" }, { 0, "" },
{ SPEED_100, "" }, { SPEED_10, "" },
{ SPEED_1000, "" }}; { SPEED_100, "" },
{ SPEED_1000, "" }};
struct e1000_option opt = { opt = (struct e1000_option) {
.type = list_option, .type = list_option,
.name = "Speed", .name = "Speed",
.err = "parameter ignored", .err = "parameter ignored",
...@@ -604,11 +612,12 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -604,11 +612,12 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter)
} }
} }
{ /* Duplex */ { /* Duplex */
struct e1000_opt_list dplx_list[] = {{ 0, "" }, static const struct e1000_opt_list dplx_list[] = {
{ HALF_DUPLEX, "" }, { 0, "" },
{ FULL_DUPLEX, "" }}; { HALF_DUPLEX, "" },
{ FULL_DUPLEX, "" }};
struct e1000_option opt = { opt = (struct e1000_option) {
.type = list_option, .type = list_option,
.name = "Duplex", .name = "Duplex",
.err = "parameter ignored", .err = "parameter ignored",
...@@ -637,7 +646,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -637,7 +646,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter)
"parameter ignored\n"); "parameter ignored\n");
adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
} else { /* Autoneg */ } else { /* Autoneg */
struct e1000_opt_list an_list[] = static const struct e1000_opt_list an_list[] =
#define AA "AutoNeg advertising " #define AA "AutoNeg advertising "
{{ 0x01, AA "10/HD" }, {{ 0x01, AA "10/HD" },
{ 0x02, AA "10/FD" }, { 0x02, AA "10/FD" },
...@@ -671,7 +680,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -671,7 +680,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter)
{ 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
{ 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
struct e1000_option opt = { opt = (struct e1000_option) {
.type = list_option, .type = list_option,
.name = "AutoNeg", .name = "AutoNeg",
.err = "parameter ignored", .err = "parameter ignored",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment