Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Linus Torvalds <torvalds@linux-foundation.org>
Reveiewed-by: Auke Kok <auke-jan.h.kok@intel.com>
Tested-by: Emil Tantilov <emil.s.tantilov@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+45 -36
+45 -36
drivers/net/e1000/e1000_param.c
··· 208 208 } r; 209 209 struct { /* list_option info */ 210 210 int nr; 211 - struct e1000_opt_list { int i; char *str; } *p; 211 + const struct e1000_opt_list { int i; char *str; } *p; 212 212 } l; 213 213 } arg; 214 214 }; ··· 242 242 break; 243 243 case list_option: { 244 244 int i; 245 - struct e1000_opt_list *ent; 245 + const struct e1000_opt_list *ent; 246 246 247 247 for (i = 0; i < opt->arg.l.nr; i++) { 248 248 ent = &opt->arg.l.p[i]; ··· 279 279 280 280 void __devinit e1000_check_options(struct e1000_adapter *adapter) 281 281 { 282 + struct e1000_option opt; 282 283 int bd = adapter->bd_number; 284 + 283 285 if (bd >= E1000_MAX_NIC) { 284 286 DPRINTK(PROBE, NOTICE, 285 287 "Warning: no configuration for board #%i\n", bd); ··· 289 287 } 290 288 291 289 { /* Transmit Descriptor Count */ 292 - struct e1000_option opt = { 290 + struct e1000_tx_ring *tx_ring = adapter->tx_ring; 291 + int i; 292 + e1000_mac_type mac_type = adapter->hw.mac_type; 293 + 294 + opt = (struct e1000_option) { 293 295 .type = range_option, 294 296 .name = "Transmit Descriptors", 295 297 .err = "using default of " 296 298 __MODULE_STRING(E1000_DEFAULT_TXD), 297 299 .def = E1000_DEFAULT_TXD, 298 - .arg = { .r = { .min = E1000_MIN_TXD }} 300 + .arg = { .r = { 301 + .min = E1000_MIN_TXD, 302 + .max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD 303 + }} 299 304 }; 300 - struct e1000_tx_ring *tx_ring = adapter->tx_ring; 301 - int i; 302 - e1000_mac_type mac_type = adapter->hw.mac_type; 303 - opt.arg.r.max = mac_type < e1000_82544 ? 304 - E1000_MAX_TXD : E1000_MAX_82544_TXD; 305 305 306 306 if (num_TxDescriptors > bd) { 307 307 tx_ring->count = TxDescriptors[bd]; ··· 317 313 tx_ring[i].count = tx_ring->count; 318 314 } 319 315 { /* Receive Descriptor Count */ 320 - struct e1000_option opt = { 316 + struct e1000_rx_ring *rx_ring = adapter->rx_ring; 317 + int i; 318 + e1000_mac_type mac_type = adapter->hw.mac_type; 319 + 320 + opt = (struct e1000_option) { 321 321 .type = range_option, 322 322 .name = "Receive Descriptors", 323 323 .err = "using default of " 324 324 __MODULE_STRING(E1000_DEFAULT_RXD), 325 325 .def = E1000_DEFAULT_RXD, 326 - .arg = { .r = { .min = E1000_MIN_RXD }} 326 + .arg = { .r = { 327 + .min = E1000_MIN_RXD, 328 + .max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD 329 + }} 327 330 }; 328 - struct e1000_rx_ring *rx_ring = adapter->rx_ring; 329 - int i; 330 - e1000_mac_type mac_type = adapter->hw.mac_type; 331 - opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : 332 - E1000_MAX_82544_RXD; 333 331 334 332 if (num_RxDescriptors > bd) { 335 333 rx_ring->count = RxDescriptors[bd]; ··· 345 339 rx_ring[i].count = rx_ring->count; 346 340 } 347 341 { /* Checksum Offload Enable/Disable */ 348 - struct e1000_option opt = { 342 + opt = (struct e1000_option) { 349 343 .type = enable_option, 350 344 .name = "Checksum Offload", 351 345 .err = "defaulting to Enabled", ··· 369 363 { E1000_FC_FULL, "Flow Control Enabled" }, 370 364 { E1000_FC_DEFAULT, "Flow Control Hardware Default" }}; 371 365 372 - struct e1000_option opt = { 366 + opt = (struct e1000_option) { 373 367 .type = list_option, 374 368 .name = "Flow Control", 375 369 .err = "reading default settings from EEPROM", ··· 387 381 } 388 382 } 389 383 { /* Transmit Interrupt Delay */ 390 - struct e1000_option opt = { 384 + opt = (struct e1000_option) { 391 385 .type = range_option, 392 386 .name = "Transmit Interrupt Delay", 393 387 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), ··· 405 399 } 406 400 } 407 401 { /* Transmit Absolute Interrupt Delay */ 408 - struct e1000_option opt = { 402 + opt = (struct e1000_option) { 409 403 .type = range_option, 410 404 .name = "Transmit Absolute Interrupt Delay", 411 405 .err = "using default of " __MODULE_STRING(DEFAULT_TADV), ··· 423 417 } 424 418 } 425 419 { /* Receive Interrupt Delay */ 426 - struct e1000_option opt = { 420 + opt = (struct e1000_option) { 427 421 .type = range_option, 428 422 .name = "Receive Interrupt Delay", 429 423 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), ··· 441 435 } 442 436 } 443 437 { /* Receive Absolute Interrupt Delay */ 444 - struct e1000_option opt = { 438 + opt = (struct e1000_option) { 445 439 .type = range_option, 446 440 .name = "Receive Absolute Interrupt Delay", 447 441 .err = "using default of " __MODULE_STRING(DEFAULT_RADV), ··· 459 453 } 460 454 } 461 455 { /* Interrupt Throttling Rate */ 462 - struct e1000_option opt = { 456 + opt = (struct e1000_option) { 463 457 .type = range_option, 464 458 .name = "Interrupt Throttling Rate (ints/sec)", 465 459 .err = "using default of " __MODULE_STRING(DEFAULT_ITR), ··· 503 497 } 504 498 } 505 499 { /* Smart Power Down */ 506 - struct e1000_option opt = { 500 + opt = (struct e1000_option) { 507 501 .type = enable_option, 508 502 .name = "PHY Smart Power Down", 509 503 .err = "defaulting to Disabled", ··· 519 513 } 520 514 } 521 515 { /* Kumeran Lock Loss Workaround */ 522 - struct e1000_option opt = { 516 + opt = (struct e1000_option) { 523 517 .type = enable_option, 524 518 .name = "Kumeran Lock Loss Workaround", 525 519 .err = "defaulting to Enabled", ··· 584 578 585 579 static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) 586 580 { 581 + struct e1000_option opt; 587 582 unsigned int speed, dplx, an; 588 583 int bd = adapter->bd_number; 589 584 590 585 { /* Speed */ 591 - struct e1000_opt_list speed_list[] = {{ 0, "" }, 592 - { SPEED_10, "" }, 593 - { SPEED_100, "" }, 594 - { SPEED_1000, "" }}; 586 + static const struct e1000_opt_list speed_list[] = { 587 + { 0, "" }, 588 + { SPEED_10, "" }, 589 + { SPEED_100, "" }, 590 + { SPEED_1000, "" }}; 595 591 596 - struct e1000_option opt = { 592 + opt = (struct e1000_option) { 597 593 .type = list_option, 598 594 .name = "Speed", 599 595 .err = "parameter ignored", ··· 612 604 } 613 605 } 614 606 { /* Duplex */ 615 - struct e1000_opt_list dplx_list[] = {{ 0, "" }, 616 - { HALF_DUPLEX, "" }, 617 - { FULL_DUPLEX, "" }}; 607 + static const struct e1000_opt_list dplx_list[] = { 608 + { 0, "" }, 609 + { HALF_DUPLEX, "" }, 610 + { FULL_DUPLEX, "" }}; 618 611 619 - struct e1000_option opt = { 612 + opt = (struct e1000_option) { 620 613 .type = list_option, 621 614 .name = "Duplex", 622 615 .err = "parameter ignored", ··· 646 637 "parameter ignored\n"); 647 638 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; 648 639 } else { /* Autoneg */ 649 - struct e1000_opt_list an_list[] = 640 + static const struct e1000_opt_list an_list[] = 650 641 #define AA "AutoNeg advertising " 651 642 {{ 0x01, AA "10/HD" }, 652 643 { 0x02, AA "10/FD" }, ··· 680 671 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, 681 672 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; 682 673 683 - struct e1000_option opt = { 674 + opt = (struct e1000_option) { 684 675 .type = list_option, 685 676 .name = "AutoNeg", 686 677 .err = "parameter ignored",