aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--arch/arm/mach-s5p6442/clock.c2
-rw-r--r--arch/arm/mach-s5pv210/clock.c115
-rw-r--r--arch/arm/plat-s5p/irq-eint.c2
-rw-r--r--arch/arm/plat-samsung/include/plat/sdhci.h4
-rw-r--r--arch/mips/alchemy/common/power.c12
-rw-r--r--arch/mips/alchemy/common/sleeper.S81
-rw-r--r--arch/mips/ar7/platform.c2
-rw-r--r--arch/mips/bcm47xx/Makefile2
-rw-r--r--arch/mips/bcm47xx/nvram.c94
-rw-r--r--arch/mips/bcm47xx/setup.c39
-rw-r--r--arch/mips/include/asm/mach-ar7/ar7.h6
-rw-r--r--arch/mips/include/asm/mach-ar7/gpio.h2
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000.h3
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/nvram.h36
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/gpio.h2
-rw-r--r--arch/mips/kernel/ftrace.c184
-rw-r--r--arch/mips/kernel/mcount.S55
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c87
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/loongson/Kconfig6
-rw-r--r--arch/mips/loongson/common/Makefile1
-rw-r--r--arch/mips/loongson/common/cs5536/cs5536_ehci.c2
-rw-r--r--arch/mips/loongson/common/cs5536/cs5536_ide.c15
-rw-r--r--arch/mips/loongson/common/cs5536/cs5536_isa.c4
-rw-r--r--arch/mips/loongson/common/cs5536/cs5536_ohci.c2
-rw-r--r--arch/mips/loongson/common/rtc.c43
-rw-r--r--arch/mips/math-emu/dp_simple.c1
-rw-r--r--arch/mips/math-emu/sp_simple.c1
-rw-r--r--arch/mips/oprofile/op_model_loongson2.c8
-rw-r--r--arch/powerpc/Kconfig4
-rw-r--r--arch/powerpc/Makefile4
-rw-r--r--arch/powerpc/include/asm/ptrace.h32
-rw-r--r--arch/powerpc/kernel/crash.c2
-rw-r--r--arch/powerpc/kernel/irq.c5
-rw-r--r--arch/powerpc/kernel/perf_event.c5
-rw-r--r--arch/powerpc/kernel/prom_init.c2
-rw-r--r--arch/powerpc/kernel/prom_init_check.sh6
-rw-r--r--arch/powerpc/lib/Makefile4
-rw-r--r--arch/powerpc/lib/crtsavres.S129
-rw-r--r--arch/powerpc/lib/feature-fixups.c17
-rw-r--r--arch/powerpc/platforms/iseries/pci.c6
-rw-r--r--arch/x86/kernel/pci-calgary_64.c4
-rw-r--r--arch/x86/mm/pat_rbtree.c34
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/bluetooth/hci_bcsp.c2
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c23
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c4
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c68
-rw-r--r--drivers/net/bonding/bond_alb.c3
-rw-r--r--drivers/net/bonding/bond_main.c33
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c17
-rw-r--r--drivers/net/ll_temac_main.c18
-rw-r--r--drivers/net/mv643xx_eth.c9
-rw-r--r--drivers/net/ne.c4
-rw-r--r--drivers/net/qlge/qlge_main.c11
-rw-r--r--drivers/net/s2io.c101
-rw-r--r--drivers/net/s2io.h4
-rw-r--r--drivers/net/sb1250-mac.c1
-rw-r--r--drivers/net/usb/rndis_host.c18
-rw-r--r--drivers/net/usb/usbnet.c5
-rw-r--r--drivers/net/virtio_net.c28
-rw-r--r--drivers/net/vxge/vxge-main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c7
-rw-r--r--drivers/pcmcia/ds.c3
-rw-r--r--drivers/vhost/net.c12
-rw-r--r--drivers/vhost/vhost.c86
-rw-r--r--drivers/vhost/vhost.h8
-rw-r--r--fs/afs/write.c1
-rw-r--r--fs/btrfs/extent_io.c2
-rw-r--r--fs/ceph/auth_x.c2
-rw-r--r--fs/ceph/caps.c21
-rw-r--r--fs/ceph/crush/mapper.c41
-rw-r--r--fs/ceph/debugfs.c2
-rw-r--r--fs/ceph/inode.c19
-rw-r--r--fs/ceph/mds_client.c6
-rw-r--r--fs/ceph/messenger.c4
-rw-r--r--fs/ceph/mon_client.c3
-rw-r--r--fs/ceph/osd_client.c3
-rw-r--r--fs/ceph/osdmap.c1
-rw-r--r--fs/fs-writeback.c335
-rw-r--r--fs/splice.c9
-rw-r--r--include/drm/ttm/ttm_page_alloc.h4
-rw-r--r--include/linux/backing-dev.h2
-rw-r--r--include/linux/ethtool.h2
-rw-r--r--include/linux/fs.h13
-rw-r--r--include/linux/mv643xx_eth.h5
-rw-r--r--include/linux/net.h3
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--include/linux/rbtree.h13
-rw-r--r--include/linux/writeback.h7
-rw-r--r--include/net/sch_generic.h20
-rw-r--r--include/net/xfrm.h2
-rw-r--r--lib/rbtree.c116
-rw-r--r--mm/backing-dev.c17
-rw-r--r--mm/page-writeback.c3
-rw-r--r--net/bridge/br_multicast.c21
-rw-r--r--net/bridge/br_netfilter.c3
-rw-r--r--net/core/dev.c18
-rw-r--r--net/core/ethtool.c41
-rw-r--r--net/ipv4/xfrm4_policy.c2
-rw-r--r--net/ipv6/netfilter/ip6t_REJECT.c6
-rw-r--r--net/ipv6/xfrm6_policy.c2
-rw-r--r--scripts/mod/modpost.c5
107 files changed, 1448 insertions, 869 deletions
diff --git a/Makefile b/Makefile
index 914e5f514888..f9835c80a274 100644
--- a/Makefile
+++ b/Makefile
@@ -886,7 +886,7 @@ $(vmlinux-dirs): prepare scripts
886# Store (new) KERNELRELASE string in include/config/kernel.release 886# Store (new) KERNELRELASE string in include/config/kernel.release
887include/config/kernel.release: include/config/auto.conf FORCE 887include/config/kernel.release: include/config/auto.conf FORCE
888 $(Q)rm -f $@ 888 $(Q)rm -f $@
889 $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) scripts/setlocalversion $(srctree))" > $@ 889 $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > $@
890 890
891 891
892# Things we need to do before we recursively start building the kernel 892# Things we need to do before we recursively start building the kernel
diff --git a/arch/arm/mach-s5p6442/clock.c b/arch/arm/mach-s5p6442/clock.c
index 3aadbf42c112..087e57f20ad5 100644
--- a/arch/arm/mach-s5p6442/clock.c
+++ b/arch/arm/mach-s5p6442/clock.c
@@ -294,7 +294,7 @@ void __init_or_cpufreq s5p6442_setup_clocks(void)
294 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502); 294 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
295 epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500); 295 epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500);
296 296
297 printk(KERN_INFO "S5P6440: PLL settings, A=%ld, M=%ld, E=%ld", 297 printk(KERN_INFO "S5P6442: PLL settings, A=%ld, M=%ld, E=%ld",
298 apll, mpll, epll); 298 apll, mpll, epll);
299 299
300 clk_fout_apll.rate = apll; 300 clk_fout_apll.rate = apll;
diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c
index 154bca4abc09..af91fefef2c6 100644
--- a/arch/arm/mach-s5pv210/clock.c
+++ b/arch/arm/mach-s5pv210/clock.c
@@ -183,6 +183,11 @@ static int s5pv210_clk_mask0_ctrl(struct clk *clk, int enable)
183 return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable); 183 return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable);
184} 184}
185 185
186static int s5pv210_clk_mask1_ctrl(struct clk *clk, int enable)
187{
188 return s5p_gatectrl(S5P_CLK_SRC_MASK1, clk, enable);
189}
190
186static struct clk clk_sclk_hdmi27m = { 191static struct clk clk_sclk_hdmi27m = {
187 .name = "sclk_hdmi27m", 192 .name = "sclk_hdmi27m",
188 .id = -1, 193 .id = -1,
@@ -406,14 +411,14 @@ static struct clk init_clocks_disable[] = {
406 .id = 0, 411 .id = 0,
407 .parent = &clk_p, 412 .parent = &clk_p,
408 .enable = s5pv210_clk_ip3_ctrl, 413 .enable = s5pv210_clk_ip3_ctrl,
409 .ctrlbit = (1<<4), 414 .ctrlbit = (1 << 5),
410 }, { 415 }, {
411 .name = "i2s_v32", 416 .name = "i2s_v32",
412 .id = 1, 417 .id = 1,
413 .parent = &clk_p, 418 .parent = &clk_p,
414 .enable = s5pv210_clk_ip3_ctrl, 419 .enable = s5pv210_clk_ip3_ctrl,
415 .ctrlbit = (1<<4), 420 .ctrlbit = (1 << 6),
416 } 421 },
417}; 422};
418 423
419static struct clk init_clocks[] = { 424static struct clk init_clocks[] = {
@@ -429,25 +434,25 @@ static struct clk init_clocks[] = {
429 .id = 0, 434 .id = 0,
430 .parent = &clk_pclk_psys.clk, 435 .parent = &clk_pclk_psys.clk,
431 .enable = s5pv210_clk_ip3_ctrl, 436 .enable = s5pv210_clk_ip3_ctrl,
432 .ctrlbit = (1<<7), 437 .ctrlbit = (1 << 17),
433 }, { 438 }, {
434 .name = "uart", 439 .name = "uart",
435 .id = 1, 440 .id = 1,
436 .parent = &clk_pclk_psys.clk, 441 .parent = &clk_pclk_psys.clk,
437 .enable = s5pv210_clk_ip3_ctrl, 442 .enable = s5pv210_clk_ip3_ctrl,
438 .ctrlbit = (1<<8), 443 .ctrlbit = (1 << 18),
439 }, { 444 }, {
440 .name = "uart", 445 .name = "uart",
441 .id = 2, 446 .id = 2,
442 .parent = &clk_pclk_psys.clk, 447 .parent = &clk_pclk_psys.clk,
443 .enable = s5pv210_clk_ip3_ctrl, 448 .enable = s5pv210_clk_ip3_ctrl,
444 .ctrlbit = (1<<9), 449 .ctrlbit = (1 << 19),
445 }, { 450 }, {
446 .name = "uart", 451 .name = "uart",
447 .id = 3, 452 .id = 3,
448 .parent = &clk_pclk_psys.clk, 453 .parent = &clk_pclk_psys.clk,
449 .enable = s5pv210_clk_ip3_ctrl, 454 .enable = s5pv210_clk_ip3_ctrl,
450 .ctrlbit = (1<<10), 455 .ctrlbit = (1 << 20),
451 }, 456 },
452}; 457};
453 458
@@ -497,8 +502,8 @@ static struct clksrc_clk clk_sclk_dac = {
497 .clk = { 502 .clk = {
498 .name = "sclk_dac", 503 .name = "sclk_dac",
499 .id = -1, 504 .id = -1,
500 .ctrlbit = (1 << 10), 505 .enable = s5pv210_clk_mask0_ctrl,
501 .enable = s5pv210_clk_ip1_ctrl, 506 .ctrlbit = (1 << 2),
502 }, 507 },
503 .sources = &clkset_sclk_dac, 508 .sources = &clkset_sclk_dac,
504 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 8, .size = 1 }, 509 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 8, .size = 1 },
@@ -527,8 +532,8 @@ static struct clksrc_clk clk_sclk_hdmi = {
527 .clk = { 532 .clk = {
528 .name = "sclk_hdmi", 533 .name = "sclk_hdmi",
529 .id = -1, 534 .id = -1,
530 .enable = s5pv210_clk_ip1_ctrl, 535 .enable = s5pv210_clk_mask0_ctrl,
531 .ctrlbit = (1 << 11), 536 .ctrlbit = (1 << 0),
532 }, 537 },
533 .sources = &clkset_sclk_hdmi, 538 .sources = &clkset_sclk_hdmi,
534 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 0, .size = 1 }, 539 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 0, .size = 1 },
@@ -565,8 +570,8 @@ static struct clksrc_clk clk_sclk_audio0 = {
565 .clk = { 570 .clk = {
566 .name = "sclk_audio", 571 .name = "sclk_audio",
567 .id = 0, 572 .id = 0,
568 .enable = s5pv210_clk_ip3_ctrl, 573 .enable = s5pv210_clk_mask0_ctrl,
569 .ctrlbit = (1 << 4), 574 .ctrlbit = (1 << 24),
570 }, 575 },
571 .sources = &clkset_sclk_audio0, 576 .sources = &clkset_sclk_audio0,
572 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 0, .size = 4 }, 577 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 0, .size = 4 },
@@ -594,8 +599,8 @@ static struct clksrc_clk clk_sclk_audio1 = {
594 .clk = { 599 .clk = {
595 .name = "sclk_audio", 600 .name = "sclk_audio",
596 .id = 1, 601 .id = 1,
597 .enable = s5pv210_clk_ip3_ctrl, 602 .enable = s5pv210_clk_mask0_ctrl,
598 .ctrlbit = (1 << 5), 603 .ctrlbit = (1 << 25),
599 }, 604 },
600 .sources = &clkset_sclk_audio1, 605 .sources = &clkset_sclk_audio1,
601 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 4, .size = 4 }, 606 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 4, .size = 4 },
@@ -623,8 +628,8 @@ static struct clksrc_clk clk_sclk_audio2 = {
623 .clk = { 628 .clk = {
624 .name = "sclk_audio", 629 .name = "sclk_audio",
625 .id = 2, 630 .id = 2,
626 .enable = s5pv210_clk_ip3_ctrl, 631 .enable = s5pv210_clk_mask0_ctrl,
627 .ctrlbit = (1 << 6), 632 .ctrlbit = (1 << 26),
628 }, 633 },
629 .sources = &clkset_sclk_audio2, 634 .sources = &clkset_sclk_audio2,
630 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 8, .size = 4 }, 635 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 8, .size = 4 },
@@ -680,8 +685,8 @@ static struct clksrc_clk clksrcs[] = {
680 .clk = { 685 .clk = {
681 .name = "uclk1", 686 .name = "uclk1",
682 .id = 0, 687 .id = 0,
683 .ctrlbit = (1<<17), 688 .enable = s5pv210_clk_mask0_ctrl,
684 .enable = s5pv210_clk_ip3_ctrl, 689 .ctrlbit = (1 << 12),
685 }, 690 },
686 .sources = &clkset_uart, 691 .sources = &clkset_uart,
687 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 16, .size = 4 }, 692 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 16, .size = 4 },
@@ -690,8 +695,8 @@ static struct clksrc_clk clksrcs[] = {
690 .clk = { 695 .clk = {
691 .name = "uclk1", 696 .name = "uclk1",
692 .id = 1, 697 .id = 1,
693 .enable = s5pv210_clk_ip3_ctrl, 698 .enable = s5pv210_clk_mask0_ctrl,
694 .ctrlbit = (1 << 18), 699 .ctrlbit = (1 << 13),
695 }, 700 },
696 .sources = &clkset_uart, 701 .sources = &clkset_uart,
697 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 20, .size = 4 }, 702 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 20, .size = 4 },
@@ -700,8 +705,8 @@ static struct clksrc_clk clksrcs[] = {
700 .clk = { 705 .clk = {
701 .name = "uclk1", 706 .name = "uclk1",
702 .id = 2, 707 .id = 2,
703 .enable = s5pv210_clk_ip3_ctrl, 708 .enable = s5pv210_clk_mask0_ctrl,
704 .ctrlbit = (1 << 19), 709 .ctrlbit = (1 << 14),
705 }, 710 },
706 .sources = &clkset_uart, 711 .sources = &clkset_uart,
707 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 24, .size = 4 }, 712 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 24, .size = 4 },
@@ -710,8 +715,8 @@ static struct clksrc_clk clksrcs[] = {
710 .clk = { 715 .clk = {
711 .name = "uclk1", 716 .name = "uclk1",
712 .id = 3, 717 .id = 3,
713 .enable = s5pv210_clk_ip3_ctrl, 718 .enable = s5pv210_clk_mask0_ctrl,
714 .ctrlbit = (1 << 20), 719 .ctrlbit = (1 << 15),
715 }, 720 },
716 .sources = &clkset_uart, 721 .sources = &clkset_uart,
717 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 28, .size = 4 }, 722 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 28, .size = 4 },
@@ -720,8 +725,8 @@ static struct clksrc_clk clksrcs[] = {
720 .clk = { 725 .clk = {
721 .name = "sclk_mixer", 726 .name = "sclk_mixer",
722 .id = -1, 727 .id = -1,
723 .enable = s5pv210_clk_ip1_ctrl, 728 .enable = s5pv210_clk_mask0_ctrl,
724 .ctrlbit = (1 << 9), 729 .ctrlbit = (1 << 1),
725 }, 730 },
726 .sources = &clkset_sclk_mixer, 731 .sources = &clkset_sclk_mixer,
727 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 }, 732 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 },
@@ -738,8 +743,8 @@ static struct clksrc_clk clksrcs[] = {
738 .clk = { 743 .clk = {
739 .name = "sclk_fimc", 744 .name = "sclk_fimc",
740 .id = 0, 745 .id = 0,
741 .enable = s5pv210_clk_ip0_ctrl, 746 .enable = s5pv210_clk_mask1_ctrl,
742 .ctrlbit = (1 << 24), 747 .ctrlbit = (1 << 2),
743 }, 748 },
744 .sources = &clkset_group2, 749 .sources = &clkset_group2,
745 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 4 }, 750 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 4 },
@@ -748,8 +753,8 @@ static struct clksrc_clk clksrcs[] = {
748 .clk = { 753 .clk = {
749 .name = "sclk_fimc", 754 .name = "sclk_fimc",
750 .id = 1, 755 .id = 1,
751 .enable = s5pv210_clk_ip0_ctrl, 756 .enable = s5pv210_clk_mask1_ctrl,
752 .ctrlbit = (1 << 25), 757 .ctrlbit = (1 << 3),
753 }, 758 },
754 .sources = &clkset_group2, 759 .sources = &clkset_group2,
755 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 4 }, 760 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 4 },
@@ -758,8 +763,8 @@ static struct clksrc_clk clksrcs[] = {
758 .clk = { 763 .clk = {
759 .name = "sclk_fimc", 764 .name = "sclk_fimc",
760 .id = 2, 765 .id = 2,
761 .enable = s5pv210_clk_ip0_ctrl, 766 .enable = s5pv210_clk_mask1_ctrl,
762 .ctrlbit = (1 << 26), 767 .ctrlbit = (1 << 4),
763 }, 768 },
764 .sources = &clkset_group2, 769 .sources = &clkset_group2,
765 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 4 }, 770 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 4 },
@@ -768,6 +773,8 @@ static struct clksrc_clk clksrcs[] = {
768 .clk = { 773 .clk = {
769 .name = "sclk_cam", 774 .name = "sclk_cam",
770 .id = 0, 775 .id = 0,
776 .enable = s5pv210_clk_mask0_ctrl,
777 .ctrlbit = (1 << 3),
771 }, 778 },
772 .sources = &clkset_group2, 779 .sources = &clkset_group2,
773 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 12, .size = 4 }, 780 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 12, .size = 4 },
@@ -776,6 +783,8 @@ static struct clksrc_clk clksrcs[] = {
776 .clk = { 783 .clk = {
777 .name = "sclk_cam", 784 .name = "sclk_cam",
778 .id = 1, 785 .id = 1,
786 .enable = s5pv210_clk_mask0_ctrl,
787 .ctrlbit = (1 << 4),
779 }, 788 },
780 .sources = &clkset_group2, 789 .sources = &clkset_group2,
781 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 16, .size = 4 }, 790 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 16, .size = 4 },
@@ -784,8 +793,8 @@ static struct clksrc_clk clksrcs[] = {
784 .clk = { 793 .clk = {
785 .name = "sclk_fimd", 794 .name = "sclk_fimd",
786 .id = -1, 795 .id = -1,
787 .enable = s5pv210_clk_ip1_ctrl, 796 .enable = s5pv210_clk_mask0_ctrl,
788 .ctrlbit = (1 << 0), 797 .ctrlbit = (1 << 5),
789 }, 798 },
790 .sources = &clkset_group2, 799 .sources = &clkset_group2,
791 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 20, .size = 4 }, 800 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 20, .size = 4 },
@@ -794,8 +803,8 @@ static struct clksrc_clk clksrcs[] = {
794 .clk = { 803 .clk = {
795 .name = "sclk_mmc", 804 .name = "sclk_mmc",
796 .id = 0, 805 .id = 0,
797 .enable = s5pv210_clk_ip2_ctrl, 806 .enable = s5pv210_clk_mask0_ctrl,
798 .ctrlbit = (1 << 16), 807 .ctrlbit = (1 << 8),
799 }, 808 },
800 .sources = &clkset_group2, 809 .sources = &clkset_group2,
801 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 0, .size = 4 }, 810 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 0, .size = 4 },
@@ -804,8 +813,8 @@ static struct clksrc_clk clksrcs[] = {
804 .clk = { 813 .clk = {
805 .name = "sclk_mmc", 814 .name = "sclk_mmc",
806 .id = 1, 815 .id = 1,
807 .enable = s5pv210_clk_ip2_ctrl, 816 .enable = s5pv210_clk_mask0_ctrl,
808 .ctrlbit = (1 << 17), 817 .ctrlbit = (1 << 9),
809 }, 818 },
810 .sources = &clkset_group2, 819 .sources = &clkset_group2,
811 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 4, .size = 4 }, 820 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 4, .size = 4 },
@@ -814,8 +823,8 @@ static struct clksrc_clk clksrcs[] = {
814 .clk = { 823 .clk = {
815 .name = "sclk_mmc", 824 .name = "sclk_mmc",
816 .id = 2, 825 .id = 2,
817 .enable = s5pv210_clk_ip2_ctrl, 826 .enable = s5pv210_clk_mask0_ctrl,
818 .ctrlbit = (1 << 18), 827 .ctrlbit = (1 << 10),
819 }, 828 },
820 .sources = &clkset_group2, 829 .sources = &clkset_group2,
821 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 8, .size = 4 }, 830 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 8, .size = 4 },
@@ -824,8 +833,8 @@ static struct clksrc_clk clksrcs[] = {
824 .clk = { 833 .clk = {
825 .name = "sclk_mmc", 834 .name = "sclk_mmc",
826 .id = 3, 835 .id = 3,
827 .enable = s5pv210_clk_ip2_ctrl, 836 .enable = s5pv210_clk_mask0_ctrl,
828 .ctrlbit = (1 << 19), 837 .ctrlbit = (1 << 11),
829 }, 838 },
830 .sources = &clkset_group2, 839 .sources = &clkset_group2,
831 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 12, .size = 4 }, 840 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 12, .size = 4 },
@@ -864,8 +873,8 @@ static struct clksrc_clk clksrcs[] = {
864 .clk = { 873 .clk = {
865 .name = "sclk_csis", 874 .name = "sclk_csis",
866 .id = -1, 875 .id = -1,
867 .enable = s5pv210_clk_ip0_ctrl, 876 .enable = s5pv210_clk_mask0_ctrl,
868 .ctrlbit = (1 << 31), 877 .ctrlbit = (1 << 6),
869 }, 878 },
870 .sources = &clkset_group2, 879 .sources = &clkset_group2,
871 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 24, .size = 4 }, 880 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 24, .size = 4 },
@@ -874,8 +883,8 @@ static struct clksrc_clk clksrcs[] = {
874 .clk = { 883 .clk = {
875 .name = "sclk_spi", 884 .name = "sclk_spi",
876 .id = 0, 885 .id = 0,
877 .enable = s5pv210_clk_ip3_ctrl, 886 .enable = s5pv210_clk_mask0_ctrl,
878 .ctrlbit = (1 << 12), 887 .ctrlbit = (1 << 16),
879 }, 888 },
880 .sources = &clkset_group2, 889 .sources = &clkset_group2,
881 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 0, .size = 4 }, 890 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 0, .size = 4 },
@@ -884,8 +893,8 @@ static struct clksrc_clk clksrcs[] = {
884 .clk = { 893 .clk = {
885 .name = "sclk_spi", 894 .name = "sclk_spi",
886 .id = 1, 895 .id = 1,
887 .enable = s5pv210_clk_ip3_ctrl, 896 .enable = s5pv210_clk_mask0_ctrl,
888 .ctrlbit = (1 << 13), 897 .ctrlbit = (1 << 17),
889 }, 898 },
890 .sources = &clkset_group2, 899 .sources = &clkset_group2,
891 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 4, .size = 4 }, 900 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 4, .size = 4 },
@@ -894,8 +903,8 @@ static struct clksrc_clk clksrcs[] = {
894 .clk = { 903 .clk = {
895 .name = "sclk_pwi", 904 .name = "sclk_pwi",
896 .id = -1, 905 .id = -1,
897 .enable = &s5pv210_clk_ip4_ctrl, 906 .enable = s5pv210_clk_mask0_ctrl,
898 .ctrlbit = (1 << 2), 907 .ctrlbit = (1 << 29),
899 }, 908 },
900 .sources = &clkset_group2, 909 .sources = &clkset_group2,
901 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 20, .size = 4 }, 910 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 20, .size = 4 },
@@ -904,8 +913,8 @@ static struct clksrc_clk clksrcs[] = {
904 .clk = { 913 .clk = {
905 .name = "sclk_pwm", 914 .name = "sclk_pwm",
906 .id = -1, 915 .id = -1,
907 .enable = s5pv210_clk_ip3_ctrl, 916 .enable = s5pv210_clk_mask0_ctrl,
908 .ctrlbit = (1 << 23), 917 .ctrlbit = (1 << 19),
909 }, 918 },
910 .sources = &clkset_group2, 919 .sources = &clkset_group2,
911 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 12, .size = 4 }, 920 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 12, .size = 4 },
diff --git a/arch/arm/plat-s5p/irq-eint.c b/arch/arm/plat-s5p/irq-eint.c
index e56c8075df97..f36cd3327025 100644
--- a/arch/arm/plat-s5p/irq-eint.c
+++ b/arch/arm/plat-s5p/irq-eint.c
@@ -71,7 +71,7 @@ static int s5p_irq_eint_set_type(unsigned int irq, unsigned int type)
71 break; 71 break;
72 72
73 case IRQ_TYPE_EDGE_FALLING: 73 case IRQ_TYPE_EDGE_FALLING:
74 newvalue = S5P_EXTINT_RISEEDGE; 74 newvalue = S5P_EXTINT_FALLEDGE;
75 break; 75 break;
76 76
77 case IRQ_TYPE_EDGE_BOTH: 77 case IRQ_TYPE_EDGE_BOTH:
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h
index 13f9fb20900a..016674fa20dd 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -166,8 +166,10 @@ static inline void s3c6410_default_sdhci2(void) { }
166#else 166#else
167static inline void s3c6410_default_sdhci0(void) { } 167static inline void s3c6410_default_sdhci0(void) { }
168static inline void s3c6410_default_sdhci1(void) { } 168static inline void s3c6410_default_sdhci1(void) { }
169static inline void s3c6410_default_sdhci2(void) { }
169static inline void s3c6400_default_sdhci0(void) { } 170static inline void s3c6400_default_sdhci0(void) { }
170static inline void s3c6400_default_sdhci1(void) { } 171static inline void s3c6400_default_sdhci1(void) { }
172static inline void s3c6400_default_sdhci2(void) { }
171 173
172#endif /* CONFIG_S3C64XX_SETUP_SDHCI */ 174#endif /* CONFIG_S3C64XX_SETUP_SDHCI */
173 175
@@ -239,7 +241,7 @@ static inline void s5pv210_default_sdhci0(void)
239 s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card; 241 s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
240} 242}
241#else 243#else
242static inline void s5pc100_default_sdhci0(void) { } 244static inline void s5pv210_default_sdhci0(void) { }
243#endif /* CONFIG_S3C_DEV_HSMMC */ 245#endif /* CONFIG_S3C_DEV_HSMMC */
244 246
245#ifdef CONFIG_S3C_DEV_HSMMC1 247#ifdef CONFIG_S3C_DEV_HSMMC1
diff --git a/arch/mips/alchemy/common/power.c b/arch/mips/alchemy/common/power.c
index 14eb8c492da2..5ef06a164a82 100644
--- a/arch/mips/alchemy/common/power.c
+++ b/arch/mips/alchemy/common/power.c
@@ -193,9 +193,15 @@ static void restore_core_regs(void)
193 193
194void au_sleep(void) 194void au_sleep(void)
195{ 195{
196 save_core_regs(); 196 int cpuid = alchemy_get_cputype();
197 au1xxx_save_and_sleep(); 197 if (cpuid != ALCHEMY_CPU_UNKNOWN) {
198 restore_core_regs(); 198 save_core_regs();
199 if (cpuid <= ALCHEMY_CPU_AU1500)
200 alchemy_sleep_au1000();
201 else if (cpuid <= ALCHEMY_CPU_AU1200)
202 alchemy_sleep_au1550();
203 restore_core_regs();
204 }
199} 205}
200 206
201#endif /* CONFIG_PM */ 207#endif /* CONFIG_PM */
diff --git a/arch/mips/alchemy/common/sleeper.S b/arch/mips/alchemy/common/sleeper.S
index 4f4b16741d12..77f3c743b716 100644
--- a/arch/mips/alchemy/common/sleeper.S
+++ b/arch/mips/alchemy/common/sleeper.S
@@ -22,10 +22,9 @@
22 .set noat 22 .set noat
23 .align 5 23 .align 5
24 24
25/* Save all of the processor general registers and go to sleep. 25
26 * A wakeup condition will get us back here to restore the registers. 26/* preparatory stuff */
27 */ 27.macro SETUP_SLEEP
28LEAF(au1xxx_save_and_sleep)
29 subu sp, PT_SIZE 28 subu sp, PT_SIZE
30 sw $1, PT_R1(sp) 29 sw $1, PT_R1(sp)
31 sw $2, PT_R2(sp) 30 sw $2, PT_R2(sp)
@@ -69,12 +68,32 @@ LEAF(au1xxx_save_and_sleep)
69 */ 68 */
70 lui t3, 0xb190 /* sys_xxx */ 69 lui t3, 0xb190 /* sys_xxx */
71 sw sp, 0x0018(t3) 70 sw sp, 0x0018(t3)
72 la k0, 3f /* resume path */ 71 la k0, alchemy_sleep_wakeup /* resume path */
73 sw k0, 0x001c(t3) 72 sw k0, 0x001c(t3)
73.endm
74 74
75 /* Put SDRAM into self refresh: Preload instructions into cache, 75.macro DO_SLEEP
76 * issue a precharge, auto/self refresh, then sleep commands to it. 76 /* put power supply and processor to sleep */
77 */ 77 sw zero, 0x0078(t3) /* sys_slppwr */
78 sync
79 sw zero, 0x007c(t3) /* sys_sleep */
80 sync
81 nop
82 nop
83 nop
84 nop
85 nop
86 nop
87 nop
88 nop
89.endm
90
91/* sleep code for Au1000/Au1100/Au1500 memory controller type */
92LEAF(alchemy_sleep_au1000)
93
94 SETUP_SLEEP
95
96 /* cache following instructions, as memory gets put to sleep */
78 la t0, 1f 97 la t0, 1f
79 .set mips3 98 .set mips3
80 cache 0x14, 0(t0) 99 cache 0x14, 0(t0)
@@ -84,17 +103,32 @@ LEAF(au1xxx_save_and_sleep)
84 .set mips0 103 .set mips0
85 104
861: lui a0, 0xb400 /* mem_xxx */ 1051: lui a0, 0xb400 /* mem_xxx */
87#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100) || \
88 defined(CONFIG_SOC_AU1500)
89 sw zero, 0x001c(a0) /* Precharge */ 106 sw zero, 0x001c(a0) /* Precharge */
90 sync 107 sync
91 sw zero, 0x0020(a0) /* Auto Refresh */ 108 sw zero, 0x0020(a0) /* Auto Refresh */
92 sync 109 sync
93 sw zero, 0x0030(a0) /* Sleep */ 110 sw zero, 0x0030(a0) /* Sleep */
94 sync 111 sync
95#endif
96 112
97#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) 113 DO_SLEEP
114
115END(alchemy_sleep_au1000)
116
117/* sleep code for Au1550/Au1200 memory controller type */
118LEAF(alchemy_sleep_au1550)
119
120 SETUP_SLEEP
121
122 /* cache following instructions, as memory gets put to sleep */
123 la t0, 1f
124 .set mips3
125 cache 0x14, 0(t0)
126 cache 0x14, 32(t0)
127 cache 0x14, 64(t0)
128 cache 0x14, 96(t0)
129 .set mips0
130
1311: lui a0, 0xb400 /* mem_xxx */
98 sw zero, 0x08c0(a0) /* Precharge */ 132 sw zero, 0x08c0(a0) /* Precharge */
99 sync 133 sync
100 sw zero, 0x08d0(a0) /* Self Refresh */ 134 sw zero, 0x08d0(a0) /* Self Refresh */
@@ -114,26 +148,17 @@ LEAF(au1xxx_save_and_sleep)
114 and t1, t0, t1 /* clear CE[1:0] */ 148 and t1, t0, t1 /* clear CE[1:0] */
115 sw t1, 0x0840(a0) /* mem_sdconfiga */ 149 sw t1, 0x0840(a0) /* mem_sdconfiga */
116 sync 150 sync
117#endif
118 151
119 /* put power supply and processor to sleep */ 152 DO_SLEEP
120 sw zero, 0x0078(t3) /* sys_slppwr */ 153
121 sync 154END(alchemy_sleep_au1550)
122 sw zero, 0x007c(t3) /* sys_sleep */ 155
123 sync
124 nop
125 nop
126 nop
127 nop
128 nop
129 nop
130 nop
131 nop
132 156
133 /* This is where we return upon wakeup. 157 /* This is where we return upon wakeup.
134 * Reload all of the registers and return. 158 * Reload all of the registers and return.
135 */ 159 */
1363: lw k0, 0x20(sp) 160LEAF(alchemy_sleep_wakeup)
161 lw k0, 0x20(sp)
137 mtc0 k0, CP0_STATUS 162 mtc0 k0, CP0_STATUS
138 lw k0, 0x1c(sp) 163 lw k0, 0x1c(sp)
139 mtc0 k0, CP0_CONTEXT 164 mtc0 k0, CP0_CONTEXT
@@ -169,4 +194,4 @@ LEAF(au1xxx_save_and_sleep)
169 lw $31, PT_R31(sp) 194 lw $31, PT_R31(sp)
170 jr ra 195 jr ra
171 addiu sp, PT_SIZE 196 addiu sp, PT_SIZE
172END(au1xxx_save_and_sleep) 197END(alchemy_sleep_wakeup)
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 566f2d7f2ea3..8f31d1d59683 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -542,7 +542,7 @@ static int __init ar7_register_uarts(void)
542 if (IS_ERR(bus_clk)) 542 if (IS_ERR(bus_clk))
543 panic("unable to get bus clk\n"); 543 panic("unable to get bus clk\n");
544 544
545 uart_port.type = PORT_16550A; 545 uart_port.type = PORT_AR7;
546 uart_port.uartclk = clk_get_rate(bus_clk) / 2; 546 uart_port.uartclk = clk_get_rate(bus_clk) / 2;
547 uart_port.iotype = UPIO_MEM32; 547 uart_port.iotype = UPIO_MEM32;
548 uart_port.regshift = 2; 548 uart_port.regshift = 2;
diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile
index 35294b12d638..7465e8a72d9a 100644
--- a/arch/mips/bcm47xx/Makefile
+++ b/arch/mips/bcm47xx/Makefile
@@ -3,4 +3,4 @@
3# under Linux. 3# under Linux.
4# 4#
5 5
6obj-y := gpio.o irq.o prom.o serial.o setup.o time.o wgt634u.o 6obj-y := gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
new file mode 100644
index 000000000000..06e03b222f6d
--- /dev/null
+++ b/arch/mips/bcm47xx/nvram.c
@@ -0,0 +1,94 @@
1/*
2 * BCM947xx nvram variable access
3 *
4 * Copyright (C) 2005 Broadcom Corporation
5 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/module.h>
16#include <linux/ssb/ssb.h>
17#include <linux/kernel.h>
18#include <linux/string.h>
19#include <asm/addrspace.h>
20#include <asm/mach-bcm47xx/nvram.h>
21#include <asm/mach-bcm47xx/bcm47xx.h>
22
23static char nvram_buf[NVRAM_SPACE];
24
25/* Probe for NVRAM header */
26static void __init early_nvram_init(void)
27{
28 struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
29 struct nvram_header *header;
30 int i;
31 u32 base, lim, off;
32 u32 *src, *dst;
33
34 base = mcore->flash_window;
35 lim = mcore->flash_window_size;
36
37 off = FLASH_MIN;
38 while (off <= lim) {
39 /* Windowed flash access */
40 header = (struct nvram_header *)
41 KSEG1ADDR(base + off - NVRAM_SPACE);
42 if (header->magic == NVRAM_HEADER)
43 goto found;
44 off <<= 1;
45 }
46
47 /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
48 header = (struct nvram_header *) KSEG1ADDR(base + 4096);
49 if (header->magic == NVRAM_HEADER)
50 goto found;
51
52 header = (struct nvram_header *) KSEG1ADDR(base + 1024);
53 if (header->magic == NVRAM_HEADER)
54 goto found;
55
56 return;
57
58found:
59 src = (u32 *) header;
60 dst = (u32 *) nvram_buf;
61 for (i = 0; i < sizeof(struct nvram_header); i += 4)
62 *dst++ = *src++;
63 for (; i < header->len && i < NVRAM_SPACE; i += 4)
64 *dst++ = le32_to_cpu(*src++);
65}
66
67int nvram_getenv(char *name, char *val, size_t val_len)
68{
69 char *var, *value, *end, *eq;
70
71 if (!name)
72 return 1;
73
74 if (!nvram_buf[0])
75 early_nvram_init();
76
77 /* Look for name=value and return value */
78 var = &nvram_buf[sizeof(struct nvram_header)];
79 end = nvram_buf + sizeof(nvram_buf) - 2;
80 end[0] = end[1] = '\0';
81 for (; *var; var = value + strlen(value) + 1) {
82 eq = strchr(var, '=');
83 if (!eq)
84 break;
85 value = eq + 1;
86 if ((eq - var) == strlen(name) &&
87 strncmp(var, name, (eq - var)) == 0) {
88 snprintf(val, val_len, "%s", value);
89 return 0;
90 }
91 }
92 return 1;
93}
94EXPORT_SYMBOL(nvram_getenv);
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index d442e11625fa..b1aee33efd11 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org> 2 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
3 * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
4 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> 3 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2006 Michael Buesch <mb@bu3sch.de> 4 * Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
5 * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
@@ -33,6 +33,7 @@
33#include <asm/time.h> 33#include <asm/time.h>
34#include <bcm47xx.h> 34#include <bcm47xx.h>
35#include <asm/fw/cfe/cfe_api.h> 35#include <asm/fw/cfe/cfe_api.h>
36#include <asm/mach-bcm47xx/nvram.h>
36 37
37struct ssb_bus ssb_bcm47xx; 38struct ssb_bus ssb_bcm47xx;
38EXPORT_SYMBOL(ssb_bcm47xx); 39EXPORT_SYMBOL(ssb_bcm47xx);
@@ -81,28 +82,42 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
81 /* Fill boardinfo structure */ 82 /* Fill boardinfo structure */
82 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo)); 83 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
83 84
84 if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0) 85 if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
86 nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
85 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 87 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
86 if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0) 88 if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
89 nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
87 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 90 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
88 if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0) 91 if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
92 nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
89 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); 93 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
90 94
91 /* Fill sprom structure */ 95 /* Fill sprom structure */
92 memset(&(iv->sprom), 0, sizeof(struct ssb_sprom)); 96 memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
93 iv->sprom.revision = 3; 97 iv->sprom.revision = 3;
94 98
95 if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0) 99 if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
100 nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
96 str2eaddr(buf, iv->sprom.et0mac); 101 str2eaddr(buf, iv->sprom.et0mac);
97 if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0) 102
103 if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
104 nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
98 str2eaddr(buf, iv->sprom.et1mac); 105 str2eaddr(buf, iv->sprom.et1mac);
99 if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0) 106
100 iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10); 107 if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
101 if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0) 108 nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
102 iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10); 109 iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
103 if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0) 110
111 if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
112 nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
113 iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
114
115 if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
116 nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
104 iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10); 117 iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
105 if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0) 118
119 if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
120 nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
106 iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10); 121 iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
107 122
108 return 0; 123 return 0;
diff --git a/arch/mips/include/asm/mach-ar7/ar7.h b/arch/mips/include/asm/mach-ar7/ar7.h
index f1cf38943497..483ffea9ecb1 100644
--- a/arch/mips/include/asm/mach-ar7/ar7.h
+++ b/arch/mips/include/asm/mach-ar7/ar7.h
@@ -50,7 +50,7 @@
50#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00) 50#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00)
51#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00) 51#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00)
52 52
53#define AR7_RESET_PEREPHERIAL 0x0 53#define AR7_RESET_PERIPHERAL 0x0
54#define AR7_RESET_SOFTWARE 0x4 54#define AR7_RESET_SOFTWARE 0x4
55#define AR7_RESET_STATUS 0x8 55#define AR7_RESET_STATUS 0x8
56 56
@@ -128,7 +128,7 @@ static inline int ar7_has_high_cpmac(void)
128static inline void ar7_device_enable(u32 bit) 128static inline void ar7_device_enable(u32 bit)
129{ 129{
130 void *reset_reg = 130 void *reset_reg =
131 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); 131 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PERIPHERAL);
132 writel(readl(reset_reg) | (1 << bit), reset_reg); 132 writel(readl(reset_reg) | (1 << bit), reset_reg);
133 msleep(20); 133 msleep(20);
134} 134}
@@ -136,7 +136,7 @@ static inline void ar7_device_enable(u32 bit)
136static inline void ar7_device_disable(u32 bit) 136static inline void ar7_device_disable(u32 bit)
137{ 137{
138 void *reset_reg = 138 void *reset_reg =
139 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); 139 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PERIPHERAL);
140 writel(readl(reset_reg) & ~(1 << bit), reset_reg); 140 writel(readl(reset_reg) & ~(1 << bit), reset_reg);
141 msleep(20); 141 msleep(20);
142} 142}
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h
index 73f9b162c970..abc317c0372e 100644
--- a/arch/mips/include/asm/mach-ar7/gpio.h
+++ b/arch/mips/include/asm/mach-ar7/gpio.h
@@ -24,7 +24,7 @@
24#define AR7_GPIO_MAX 32 24#define AR7_GPIO_MAX 32
25#define NR_BUILTIN_GPIO AR7_GPIO_MAX 25#define NR_BUILTIN_GPIO AR7_GPIO_MAX
26 26
27#define gpio_to_irq(gpio) NULL 27#define gpio_to_irq(gpio) -1
28 28
29#define gpio_get_value __gpio_get_value 29#define gpio_get_value __gpio_get_value
30#define gpio_set_value __gpio_set_value 30#define gpio_set_value __gpio_set_value
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index e76941db2312..a6976619160a 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -188,7 +188,8 @@ extern unsigned long get_au1x00_uart_baud_base(void);
188extern unsigned long au1xxx_calc_clock(void); 188extern unsigned long au1xxx_calc_clock(void);
189 189
190/* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */ 190/* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */
191void au1xxx_save_and_sleep(void); 191void alchemy_sleep_au1000(void);
192void alchemy_sleep_au1550(void);
192void au_sleep(void); 193void au_sleep(void);
193 194
194 195
diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/nvram.h
new file mode 100644
index 000000000000..0d8cc146f7a4
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2005, Broadcom Corporation
3 * Copyright (C) 2006, Felix Fietkau <nbd@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#ifndef __NVRAM_H
12#define __NVRAM_H
13
14#include <linux/types.h>
15
16struct nvram_header {
17 u32 magic;
18 u32 len;
19 u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
20 u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
21 u32 config_ncdl; /* ncdl values for memc */
22};
23
24#define NVRAM_HEADER 0x48534C46 /* 'FLSH' */
25#define NVRAM_VERSION 1
26#define NVRAM_HEADER_SIZE 20
27#define NVRAM_SPACE 0x8000
28
29#define FLASH_MIN 0x00020000 /* Minimum flash size */
30
31#define NVRAM_MAX_VALUE_LEN 255
32#define NVRAM_MAX_PARAM_LEN 64
33
34extern int nvram_getenv(char *name, char *val, size_t val_len);
35
36#endif
diff --git a/arch/mips/include/asm/mach-bcm63xx/gpio.h b/arch/mips/include/asm/mach-bcm63xx/gpio.h
index 7cda8c0a3979..1eb534de8e3b 100644
--- a/arch/mips/include/asm/mach-bcm63xx/gpio.h
+++ b/arch/mips/include/asm/mach-bcm63xx/gpio.h
@@ -3,7 +3,7 @@
3 3
4#include <bcm63xx_gpio.h> 4#include <bcm63xx_gpio.h>
5 5
6#define gpio_to_irq(gpio) NULL 6#define gpio_to_irq(gpio) -1
7 7
8#define gpio_get_value __gpio_get_value 8#define gpio_get_value __gpio_get_value
9#define gpio_set_value __gpio_set_value 9#define gpio_set_value __gpio_set_value
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index e9e64e0ff7aa..5a84a1f11231 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -2,7 +2,7 @@
2 * Code for replacing ftrace calls with jumps. 2 * Code for replacing ftrace calls with jumps.
3 * 3 *
4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
5 * Copyright (C) 2009 DSLab, Lanzhou University, China 5 * Copyright (C) 2009, 2010 DSLab, Lanzhou University, China
6 * Author: Wu Zhangjin <wuzhangjin@gmail.com> 6 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
7 * 7 *
8 * Thanks goes to Steven Rostedt for writing the original x86 version. 8 * Thanks goes to Steven Rostedt for writing the original x86 version.
@@ -12,18 +12,62 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/ftrace.h> 13#include <linux/ftrace.h>
14 14
15#include <asm/cacheflush.h>
16#include <asm/asm.h> 15#include <asm/asm.h>
17#include <asm/asm-offsets.h> 16#include <asm/asm-offsets.h>
17#include <asm/cacheflush.h>
18#include <asm/uasm.h>
19
20/*
21 * If the Instruction Pointer is in module space (0xc0000000), return true;
22 * otherwise, it is in kernel space (0x80000000), return false.
23 *
24 * FIXME: This will not work when the kernel space and module space are the
25 * same. If they are the same, we need to modify scripts/recordmcount.pl,
26 * ftrace_make_nop/call() and the other related parts to ensure the
27 * enabling/disabling of the calling site to _mcount is right for both kernel
28 * and module.
29 */
30
31static inline int in_module(unsigned long ip)
32{
33 return ip & 0x40000000;
34}
18 35
19#ifdef CONFIG_DYNAMIC_FTRACE 36#ifdef CONFIG_DYNAMIC_FTRACE
20 37
21#define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ 38#define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */
22#define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */ 39#define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */
23#define jump_insn_encode(op_code, addr) \
24 ((unsigned int)((op_code) | (((addr) >> 2) & ADDR_MASK)))
25 40
26static unsigned int ftrace_nop = 0x00000000; 41#define INSN_B_1F_4 0x10000004 /* b 1f; offset = 4 */
42#define INSN_B_1F_5 0x10000005 /* b 1f; offset = 5 */
43#define INSN_NOP 0x00000000 /* nop */
44#define INSN_JAL(addr) \
45 ((unsigned int)(JAL | (((addr) >> 2) & ADDR_MASK)))
46
47static unsigned int insn_jal_ftrace_caller __read_mostly;
48static unsigned int insn_lui_v1_hi16_mcount __read_mostly;
49static unsigned int insn_j_ftrace_graph_caller __maybe_unused __read_mostly;
50
51static inline void ftrace_dyn_arch_init_insns(void)
52{
53 u32 *buf;
54 unsigned int v1;
55
56 /* lui v1, hi16_mcount */
57 v1 = 3;
58 buf = (u32 *)&insn_lui_v1_hi16_mcount;
59 UASM_i_LA_mostly(&buf, v1, MCOUNT_ADDR);
60
61 /* jal (ftrace_caller + 8), jump over the first two instruction */
62 buf = (u32 *)&insn_jal_ftrace_caller;
63 uasm_i_jal(&buf, (FTRACE_ADDR + 8));
64
65#ifdef CONFIG_FUNCTION_GRAPH_TRACER
66 /* j ftrace_graph_caller */
67 buf = (u32 *)&insn_j_ftrace_graph_caller;
68 uasm_i_j(&buf, (unsigned long)ftrace_graph_caller);
69#endif
70}
27 71
28static int ftrace_modify_code(unsigned long ip, unsigned int new_code) 72static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
29{ 73{
@@ -40,67 +84,56 @@ static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
40 return 0; 84 return 0;
41} 85}
42 86
43static int lui_v1;
44static int jal_mcount;
45
46int ftrace_make_nop(struct module *mod, 87int ftrace_make_nop(struct module *mod,
47 struct dyn_ftrace *rec, unsigned long addr) 88 struct dyn_ftrace *rec, unsigned long addr)
48{ 89{
49 unsigned int new; 90 unsigned int new;
50 int faulted;
51 unsigned long ip = rec->ip; 91 unsigned long ip = rec->ip;
52 92
53 /* We have compiled module with -mlong-calls, but compiled the kernel 93 /*
54 * without it, we need to cope with them respectively. */ 94 * We have compiled module with -mlong-calls, but compiled the kernel
55 if (ip & 0x40000000) { 95 * without it, we need to cope with them respectively.
56 /* record it for ftrace_make_call */ 96 */
57 if (lui_v1 == 0) { 97 if (in_module(ip)) {
58 /* lui_v1 = *(unsigned int *)ip; */ 98#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT)
59 safe_load_code(lui_v1, ip, faulted); 99 /*
60 100 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005)
61 if (unlikely(faulted)) 101 * addiu v1, v1, low_16bit_of_mcount
62 return -EFAULT; 102 * move at, ra
63 } 103 * move $12, ra_address
64 104 * jalr v1
65 /* lui v1, hi_16bit_of_mcount --> b 1f (0x10000004) 105 * sub sp, sp, 8
106 * 1: offset = 5 instructions
107 */
108 new = INSN_B_1F_5;
109#else
110 /*
111 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000004)
66 * addiu v1, v1, low_16bit_of_mcount 112 * addiu v1, v1, low_16bit_of_mcount
67 * move at, ra 113 * move at, ra
68 * jalr v1 114 * jalr v1
69 * nop 115 * nop | move $12, ra_address | sub sp, sp, 8
70 * 1f: (ip + 12) 116 * 1: offset = 4 instructions
71 */ 117 */
72 new = 0x10000004; 118 new = INSN_B_1F_4;
119#endif
73 } else { 120 } else {
74 /* record/calculate it for ftrace_make_call */ 121 /*
75 if (jal_mcount == 0) { 122 * move at, ra
76 /* We can record it directly like this: 123 * jal _mcount --> nop
77 * jal_mcount = *(unsigned int *)ip;
78 * Herein, jump over the first two nop instructions */
79 jal_mcount = jump_insn_encode(JAL, (MCOUNT_ADDR + 8));
80 }
81
82 /* move at, ra
83 * jalr v1 --> nop
84 */ 124 */
85 new = ftrace_nop; 125 new = INSN_NOP;
86 } 126 }
87 return ftrace_modify_code(ip, new); 127 return ftrace_modify_code(ip, new);
88} 128}
89 129
90static int modified; /* initialized as 0 by default */
91
92int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) 130int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
93{ 131{
94 unsigned int new; 132 unsigned int new;
95 unsigned long ip = rec->ip; 133 unsigned long ip = rec->ip;
96 134
97 /* We just need to remove the "b ftrace_stub" at the fist time! */
98 if (modified == 0) {
99 modified = 1;
100 ftrace_modify_code(addr, ftrace_nop);
101 }
102 /* ip, module: 0xc0000000, kernel: 0x80000000 */ 135 /* ip, module: 0xc0000000, kernel: 0x80000000 */
103 new = (ip & 0x40000000) ? lui_v1 : jal_mcount; 136 new = in_module(ip) ? insn_lui_v1_hi16_mcount : insn_jal_ftrace_caller;
104 137
105 return ftrace_modify_code(ip, new); 138 return ftrace_modify_code(ip, new);
106} 139}
@@ -111,44 +144,48 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
111{ 144{
112 unsigned int new; 145 unsigned int new;
113 146
114 new = jump_insn_encode(JAL, (unsigned long)func); 147 new = INSN_JAL((unsigned long)func);
115 148
116 return ftrace_modify_code(FTRACE_CALL_IP, new); 149 return ftrace_modify_code(FTRACE_CALL_IP, new);
117} 150}
118 151
119int __init ftrace_dyn_arch_init(void *data) 152int __init ftrace_dyn_arch_init(void *data)
120{ 153{
154 /* Encode the instructions when booting */
155 ftrace_dyn_arch_init_insns();
156
157 /* Remove "b ftrace_stub" to ensure ftrace_caller() is executed */
158 ftrace_modify_code(MCOUNT_ADDR, INSN_NOP);
159
121 /* The return code is retured via data */ 160 /* The return code is retured via data */
122 *(unsigned long *)data = 0; 161 *(unsigned long *)data = 0;
123 162
124 return 0; 163 return 0;
125} 164}
126#endif /* CONFIG_DYNAMIC_FTRACE */ 165#endif /* CONFIG_DYNAMIC_FTRACE */
127 166
128#ifdef CONFIG_FUNCTION_GRAPH_TRACER 167#ifdef CONFIG_FUNCTION_GRAPH_TRACER
129 168
130#ifdef CONFIG_DYNAMIC_FTRACE 169#ifdef CONFIG_DYNAMIC_FTRACE
131 170
132extern void ftrace_graph_call(void); 171extern void ftrace_graph_call(void);
133#define JMP 0x08000000 /* jump to target directly */
134#define CALL_FTRACE_GRAPH_CALLER \
135 jump_insn_encode(JMP, (unsigned long)(&ftrace_graph_caller))
136#define FTRACE_GRAPH_CALL_IP ((unsigned long)(&ftrace_graph_call)) 172#define FTRACE_GRAPH_CALL_IP ((unsigned long)(&ftrace_graph_call))
137 173
138int ftrace_enable_ftrace_graph_caller(void) 174int ftrace_enable_ftrace_graph_caller(void)
139{ 175{
140 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, 176 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP,
141 CALL_FTRACE_GRAPH_CALLER); 177 insn_j_ftrace_graph_caller);
142} 178}
143 179
144int ftrace_disable_ftrace_graph_caller(void) 180int ftrace_disable_ftrace_graph_caller(void)
145{ 181{
146 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, ftrace_nop); 182 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, INSN_NOP);
147} 183}
148 184
149#endif /* !CONFIG_DYNAMIC_FTRACE */ 185#endif /* CONFIG_DYNAMIC_FTRACE */
150 186
151#ifndef KBUILD_MCOUNT_RA_ADDRESS 187#ifndef KBUILD_MCOUNT_RA_ADDRESS
188
152#define S_RA_SP (0xafbf << 16) /* s{d,w} ra, offset(sp) */ 189#define S_RA_SP (0xafbf << 16) /* s{d,w} ra, offset(sp) */
153#define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */ 190#define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */
154#define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */ 191#define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */
@@ -162,17 +199,17 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
162 unsigned int code; 199 unsigned int code;
163 int faulted; 200 int faulted;
164 201
165 /* in module or kernel? */ 202 /*
166 if (self_addr & 0x40000000) { 203 * For module, move the ip from calling site of mcount to the
167 /* module: move to the instruction "lui v1, HI_16BIT_OF_MCOUNT" */ 204 * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for
168 ip = self_addr - 20; 205 * kernel, move to the instruction "move ra, at"(offset is 12)
169 } else { 206 */
170 /* kernel: move to the instruction "move ra, at" */ 207 ip = self_addr - (in_module(self_addr) ? 20 : 12);
171 ip = self_addr - 12;
172 }
173 208
174 /* search the text until finding the non-store instruction or "s{d,w} 209 /*
175 * ra, offset(sp)" instruction */ 210 * search the text until finding the non-store instruction or "s{d,w}
211 * ra, offset(sp)" instruction
212 */
176 do { 213 do {
177 ip -= 4; 214 ip -= 4;
178 215
@@ -181,10 +218,11 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
181 218
182 if (unlikely(faulted)) 219 if (unlikely(faulted))
183 return 0; 220 return 0;
184 221 /*
185 /* If we hit the non-store instruction before finding where the 222 * If we hit the non-store instruction before finding where the
186 * ra is stored, then this is a leaf function and it does not 223 * ra is stored, then this is a leaf function and it does not
187 * store the ra on the stack. */ 224 * store the ra on the stack
225 */
188 if ((code & S_R_SP) != S_R_SP) 226 if ((code & S_R_SP) != S_R_SP)
189 return parent_addr; 227 return parent_addr;
190 228
@@ -202,7 +240,7 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
202 return 0; 240 return 0;
203} 241}
204 242
205#endif 243#endif /* !KBUILD_MCOUNT_RA_ADDRESS */
206 244
207/* 245/*
208 * Hook the return address and push it in the stack of return addrs 246 * Hook the return address and push it in the stack of return addrs
@@ -220,7 +258,8 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
220 if (unlikely(atomic_read(&current->tracing_graph_pause))) 258 if (unlikely(atomic_read(&current->tracing_graph_pause)))
221 return; 259 return;
222 260
223 /* "parent" is the stack address saved the return address of the caller 261 /*
262 * "parent" is the stack address saved the return address of the caller
224 * of _mcount. 263 * of _mcount.
225 * 264 *
226 * if the gcc < 4.5, a leaf function does not save the return address 265 * if the gcc < 4.5, a leaf function does not save the return address
@@ -242,10 +281,11 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
242 goto out; 281 goto out;
243#ifndef KBUILD_MCOUNT_RA_ADDRESS 282#ifndef KBUILD_MCOUNT_RA_ADDRESS
244 parent = (unsigned long *)ftrace_get_parent_addr(self_addr, old, 283 parent = (unsigned long *)ftrace_get_parent_addr(self_addr, old,
245 (unsigned long)parent, 284 (unsigned long)parent, fp);
246 fp); 285 /*
247 /* If fails when getting the stack address of the non-leaf function's 286 * If fails when getting the stack address of the non-leaf function's
248 * ra, stop function graph tracer and return */ 287 * ra, stop function graph tracer and return
288 */
249 if (parent == 0) 289 if (parent == 0)
250 goto out; 290 goto out;
251#endif 291#endif
@@ -272,4 +312,4 @@ out:
272 ftrace_graph_stop(); 312 ftrace_graph_stop();
273 WARN_ON(1); 313 WARN_ON(1);
274} 314}
275#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 315#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index 6851fc97a511..6bfcb7a00ec6 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -6,6 +6,7 @@
6 * more details. 6 * more details.
7 * 7 *
8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China 8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
9 * Copyright (C) 2010 DSLab, Lanzhou University, China
9 * Author: Wu Zhangjin <wuzhangjin@gmail.com> 10 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
10 */ 11 */
11 12
@@ -45,8 +46,6 @@
45 PTR_L a5, PT_R9(sp) 46 PTR_L a5, PT_R9(sp)
46 PTR_L a6, PT_R10(sp) 47 PTR_L a6, PT_R10(sp)
47 PTR_L a7, PT_R11(sp) 48 PTR_L a7, PT_R11(sp)
48#endif
49#ifdef CONFIG_64BIT
50 PTR_ADDIU sp, PT_SIZE 49 PTR_ADDIU sp, PT_SIZE
51#else 50#else
52 PTR_ADDIU sp, (PT_SIZE + 8) 51 PTR_ADDIU sp, (PT_SIZE + 8)
@@ -58,6 +57,12 @@
58 move ra, AT 57 move ra, AT
59 .endm 58 .endm
60 59
60/*
61 * The -mmcount-ra-address option of gcc 4.5 uses register $12 to pass
62 * the location of the parent's return address.
63 */
64#define MCOUNT_RA_ADDRESS_REG $12
65
61#ifdef CONFIG_DYNAMIC_FTRACE 66#ifdef CONFIG_DYNAMIC_FTRACE
62 67
63NESTED(ftrace_caller, PT_SIZE, ra) 68NESTED(ftrace_caller, PT_SIZE, ra)
@@ -71,14 +76,14 @@ _mcount:
71 76
72 MCOUNT_SAVE_REGS 77 MCOUNT_SAVE_REGS
73#ifdef KBUILD_MCOUNT_RA_ADDRESS 78#ifdef KBUILD_MCOUNT_RA_ADDRESS
74 PTR_S t0, PT_R12(sp) /* t0 saved the location of the return address(at) by -mmcount-ra-address */ 79 PTR_S MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
75#endif 80#endif
76 81
77 move a0, ra /* arg1: next ip, selfaddr */ 82 move a0, ra /* arg1: self return address */
78 .globl ftrace_call 83 .globl ftrace_call
79ftrace_call: 84ftrace_call:
80 nop /* a placeholder for the call to a real tracing function */ 85 nop /* a placeholder for the call to a real tracing function */
81 move a1, AT /* arg2: the caller's next ip, parent */ 86 move a1, AT /* arg2: parent's return address */
82 87
83#ifdef CONFIG_FUNCTION_GRAPH_TRACER 88#ifdef CONFIG_FUNCTION_GRAPH_TRACER
84 .globl ftrace_graph_call 89 .globl ftrace_graph_call
@@ -119,9 +124,9 @@ NESTED(_mcount, PT_SIZE, ra)
119static_trace: 124static_trace:
120 MCOUNT_SAVE_REGS 125 MCOUNT_SAVE_REGS
121 126
122 move a0, ra /* arg1: next ip, selfaddr */ 127 move a0, ra /* arg1: self return address */
123 jalr t2 /* (1) call *ftrace_trace_function */ 128 jalr t2 /* (1) call *ftrace_trace_function */
124 move a1, AT /* arg2: the caller's next ip, parent */ 129 move a1, AT /* arg2: parent's return address */
125 130
126 MCOUNT_RESTORE_REGS 131 MCOUNT_RESTORE_REGS
127 .globl ftrace_stub 132 .globl ftrace_stub
@@ -134,28 +139,34 @@ ftrace_stub:
134#ifdef CONFIG_FUNCTION_GRAPH_TRACER 139#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135 140
136NESTED(ftrace_graph_caller, PT_SIZE, ra) 141NESTED(ftrace_graph_caller, PT_SIZE, ra)
137#ifdef CONFIG_DYNAMIC_FTRACE 142#ifndef CONFIG_DYNAMIC_FTRACE
138 PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
139#ifdef KBUILD_MCOUNT_RA_ADDRESS
140 PTR_L t0, PT_R12(sp) /* load the original t0 from the stack */
141#endif
142#else
143 MCOUNT_SAVE_REGS 143 MCOUNT_SAVE_REGS
144 move a1, ra /* arg2: next ip, selfaddr */
145#endif 144#endif
146 145
146 /* arg1: Get the location of the parent's return address */
147#ifdef KBUILD_MCOUNT_RA_ADDRESS 147#ifdef KBUILD_MCOUNT_RA_ADDRESS
148 bnez t0, 1f /* non-leaf func: t0 saved the location of the return address */ 148#ifdef CONFIG_DYNAMIC_FTRACE
149 PTR_L a0, PT_R12(sp)
150#else
151 move a0, MCOUNT_RA_ADDRESS_REG
152#endif
153 bnez a0, 1f /* non-leaf func: stored in MCOUNT_RA_ADDRESS_REG */
149 nop 154 nop
150 PTR_LA t0, PT_R1(sp) /* leaf func: get the location of at(old ra) from our own stack */ 155#endif
1511: move a0, t0 /* arg1: the location of the return address */ 156 PTR_LA a0, PT_R1(sp) /* leaf func: the location in current stack */
1571:
158
159 /* arg2: Get self return address */
160#ifdef CONFIG_DYNAMIC_FTRACE
161 PTR_L a1, PT_R31(sp)
152#else 162#else
153 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */ 163 move a1, ra
154#endif 164#endif
155 jal prepare_ftrace_return 165
166 /* arg3: Get frame pointer of current stack */
156#ifdef CONFIG_FRAME_POINTER 167#ifdef CONFIG_FRAME_POINTER
157 move a2, fp /* arg3: frame pointer */ 168 move a2, fp
158#else 169#else /* ! CONFIG_FRAME_POINTER */
159#ifdef CONFIG_64BIT 170#ifdef CONFIG_64BIT
160 PTR_LA a2, PT_SIZE(sp) 171 PTR_LA a2, PT_SIZE(sp)
161#else 172#else
@@ -163,6 +174,8 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra)
163#endif 174#endif
164#endif 175#endif
165 176
177 jal prepare_ftrace_return
178 nop
166 MCOUNT_RESTORE_REGS 179 MCOUNT_RESTORE_REGS
167 RETURN_BACK 180 RETURN_BACK
168 END(ftrace_graph_caller) 181 END(ftrace_graph_caller)
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index f5981c499109..2340f11dc29c 100644
--- a/arch/mips/kernel/mips-mt-fpaff.c
+++ b/arch/mips/kernel/mips-mt-fpaff.c
@@ -3,6 +3,7 @@
3 * Copyright (C) 2005 Mips Technologies, Inc 3 * Copyright (C) 2005 Mips Technologies, Inc
4 */ 4 */
5#include <linux/cpu.h> 5#include <linux/cpu.h>
6#include <linux/cpuset.h>
6#include <linux/cpumask.h> 7#include <linux/cpumask.h>
7#include <linux/delay.h> 8#include <linux/delay.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -39,6 +40,21 @@ static inline struct task_struct *find_process_by_pid(pid_t pid)
39 return pid ? find_task_by_vpid(pid) : current; 40 return pid ? find_task_by_vpid(pid) : current;
40} 41}
41 42
43/*
44 * check the target process has a UID that matches the current process's
45 */
46static bool check_same_owner(struct task_struct *p)
47{
48 const struct cred *cred = current_cred(), *pcred;
49 bool match;
50
51 rcu_read_lock();
52 pcred = __task_cred(p);
53 match = (cred->euid == pcred->euid ||
54 cred->euid == pcred->uid);
55 rcu_read_unlock();
56 return match;
57}
42 58
43/* 59/*
44 * mipsmt_sys_sched_setaffinity - set the cpu affinity of a process 60 * mipsmt_sys_sched_setaffinity - set the cpu affinity of a process
@@ -46,12 +62,10 @@ static inline struct task_struct *find_process_by_pid(pid_t pid)
46asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len, 62asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
47 unsigned long __user *user_mask_ptr) 63 unsigned long __user *user_mask_ptr)
48{ 64{
49 cpumask_t new_mask; 65 cpumask_var_t cpus_allowed, new_mask, effective_mask;
50 cpumask_t effective_mask;
51 int retval;
52 struct task_struct *p;
53 struct thread_info *ti; 66 struct thread_info *ti;
54 uid_t euid; 67 struct task_struct *p;
68 int retval;
55 69
56 if (len < sizeof(new_mask)) 70 if (len < sizeof(new_mask))
57 return -EINVAL; 71 return -EINVAL;
@@ -60,53 +74,74 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
60 return -EFAULT; 74 return -EFAULT;
61 75
62 get_online_cpus(); 76 get_online_cpus();
63 read_lock(&tasklist_lock); 77 rcu_read_lock();
64 78
65 p = find_process_by_pid(pid); 79 p = find_process_by_pid(pid);
66 if (!p) { 80 if (!p) {
67 read_unlock(&tasklist_lock); 81 rcu_read_unlock();
68 put_online_cpus(); 82 put_online_cpus();
69 return -ESRCH; 83 return -ESRCH;
70 } 84 }
71 85
72 /* 86 /* Prevent p going away */
73 * It is not safe to call set_cpus_allowed with the
74 * tasklist_lock held. We will bump the task_struct's
75 * usage count and drop tasklist_lock before invoking
76 * set_cpus_allowed.
77 */
78 get_task_struct(p); 87 get_task_struct(p);
88 rcu_read_unlock();
79 89
80 euid = current_euid(); 90 if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) {
91 retval = -ENOMEM;
92 goto out_put_task;
93 }
94 if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
95 retval = -ENOMEM;
96 goto out_free_cpus_allowed;
97 }
98 if (!alloc_cpumask_var(&effective_mask, GFP_KERNEL)) {
99 retval = -ENOMEM;
100 goto out_free_new_mask;
101 }
81 retval = -EPERM; 102 retval = -EPERM;
82 if (euid != p->cred->euid && euid != p->cred->uid && 103 if (!check_same_owner(p) && !capable(CAP_SYS_NICE))
83 !capable(CAP_SYS_NICE)) {
84 read_unlock(&tasklist_lock);
85 goto out_unlock; 104 goto out_unlock;
86 }
87 105
88 retval = security_task_setscheduler(p, 0, NULL); 106 retval = security_task_setscheduler(p, 0, NULL);
89 if (retval) 107 if (retval)
90 goto out_unlock; 108 goto out_unlock;
91 109
92 /* Record new user-specified CPU set for future reference */ 110 /* Record new user-specified CPU set for future reference */
93 p->thread.user_cpus_allowed = new_mask; 111 cpumask_copy(&p->thread.user_cpus_allowed, new_mask);
94
95 /* Unlock the task list */
96 read_unlock(&tasklist_lock);
97 112
113 again:
98 /* Compute new global allowed CPU set if necessary */ 114 /* Compute new global allowed CPU set if necessary */
99 ti = task_thread_info(p); 115 ti = task_thread_info(p);
100 if (test_ti_thread_flag(ti, TIF_FPUBOUND) && 116 if (test_ti_thread_flag(ti, TIF_FPUBOUND) &&
101 cpus_intersects(new_mask, mt_fpu_cpumask)) { 117 cpus_intersects(*new_mask, mt_fpu_cpumask)) {
102 cpus_and(effective_mask, new_mask, mt_fpu_cpumask); 118 cpus_and(*effective_mask, *new_mask, mt_fpu_cpumask);
103 retval = set_cpus_allowed_ptr(p, &effective_mask); 119 retval = set_cpus_allowed_ptr(p, effective_mask);
104 } else { 120 } else {
121 cpumask_copy(effective_mask, new_mask);
105 clear_ti_thread_flag(ti, TIF_FPUBOUND); 122 clear_ti_thread_flag(ti, TIF_FPUBOUND);
106 retval = set_cpus_allowed_ptr(p, &new_mask); 123 retval = set_cpus_allowed_ptr(p, new_mask);
107 } 124 }
108 125
126 if (!retval) {
127 cpuset_cpus_allowed(p, cpus_allowed);
128 if (!cpumask_subset(effective_mask, cpus_allowed)) {
129 /*
130 * We must have raced with a concurrent cpuset
131 * update. Just reset the cpus_allowed to the
132 * cpuset's cpus_allowed
133 */
134 cpumask_copy(new_mask, cpus_allowed);
135 goto again;
136 }
137 }
109out_unlock: 138out_unlock:
139 free_cpumask_var(effective_mask);
140out_free_new_mask:
141 free_cpumask_var(new_mask);
142out_free_cpus_allowed:
143 free_cpumask_var(cpus_allowed);
144out_put_task:
110 put_task_struct(p); 145 put_task_struct(p);
111 put_online_cpus(); 146 put_online_cpus();
112 return retval; 147 return retval;
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 8bdd6a663c7f..852780868fb4 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -976,7 +976,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
976 976
977 case 2: 977 case 2:
978 raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs); 978 raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
979 break; 979 return;
980 980
981 case 3: 981 case 3:
982 break; 982 break;
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 3df1967dea08..c97ca69b94e0 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -23,6 +23,7 @@ config LEMOTE_FULOONG2E
23 select GENERIC_HARDIRQS_NO__DO_IRQ 23 select GENERIC_HARDIRQS_NO__DO_IRQ
24 select GENERIC_ISA_DMA_SUPPORT_BROKEN 24 select GENERIC_ISA_DMA_SUPPORT_BROKEN
25 select CPU_HAS_WB 25 select CPU_HAS_WB
26 select LOONGSON_MC146818
26 help 27 help
27 Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and 28 Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and
28 an FPGA northbridge 29 an FPGA northbridge
@@ -51,6 +52,7 @@ config LEMOTE_MACH2F
51 select SYS_SUPPORTS_64BIT_KERNEL 52 select SYS_SUPPORTS_64BIT_KERNEL
52 select SYS_SUPPORTS_HIGHMEM 53 select SYS_SUPPORTS_HIGHMEM
53 select SYS_SUPPORTS_LITTLE_ENDIAN 54 select SYS_SUPPORTS_LITTLE_ENDIAN
55 select LOONGSON_MC146818
54 help 56 help
55 Lemote Loongson 2F family machines utilize the 2F revision of 57 Lemote Loongson 2F family machines utilize the 2F revision of
56 Loongson processor and the AMD CS5536 south bridge. 58 Loongson processor and the AMD CS5536 south bridge.
@@ -83,3 +85,7 @@ config LOONGSON_UART_BASE
83 bool 85 bool
84 default y 86 default y
85 depends on EARLY_PRINTK || SERIAL_8250 87 depends on EARLY_PRINTK || SERIAL_8250
88
89config LOONGSON_MC146818
90 bool
91 default n
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index cdd2e812ba1a..e526488df655 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_GENERIC_GPIO) += gpio.o
12obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 12obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
13obj-$(CONFIG_SERIAL_8250) += serial.o 13obj-$(CONFIG_SERIAL_8250) += serial.o
14obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o 14obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o
15obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
15 16
16# 17#
17# Enable CS5536 Virtual Support Module(VSM) to virtulize the PCI configure 18# Enable CS5536 Virtual Support Module(VSM) to virtulize the PCI configure
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ehci.c b/arch/mips/loongson/common/cs5536/cs5536_ehci.c
index eaf8b86e3318..5b5cbba699b3 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_ehci.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_ehci.c
@@ -49,6 +49,8 @@ void pci_ehci_write_reg(int reg, u32 value)
49 lo |= SOFT_BAR_EHCI_FLAG; 49 lo |= SOFT_BAR_EHCI_FLAG;
50 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo); 50 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
51 } else if ((value & 0x01) == 0x00) { 51 } else if ((value & 0x01) == 0x00) {
52 _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
53 lo = value;
52 _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo); 54 _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
53 55
54 value &= 0xfffffff0; 56 value &= 0xfffffff0;
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ide.c b/arch/mips/loongson/common/cs5536/cs5536_ide.c
index 9a96b5664c78..681d1291a2c7 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_ide.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_ide.c
@@ -51,6 +51,7 @@ void pci_ide_write_reg(int reg, u32 value)
51 lo |= SOFT_BAR_IDE_FLAG; 51 lo |= SOFT_BAR_IDE_FLAG;
52 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo); 52 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
53 } else if (value & 0x01) { 53 } else if (value & 0x01) {
54 _rdmsr(IDE_MSR_REG(IDE_IO_BAR), &hi, &lo);
54 lo = (value & 0xfffffff0) | 0x1; 55 lo = (value & 0xfffffff0) | 0x1;
55 _wrmsr(IDE_MSR_REG(IDE_IO_BAR), hi, lo); 56 _wrmsr(IDE_MSR_REG(IDE_IO_BAR), hi, lo);
56 57
@@ -65,19 +66,30 @@ void pci_ide_write_reg(int reg, u32 value)
65 _rdmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), &hi, &lo); 66 _rdmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), &hi, &lo);
66 lo |= 0x01; 67 lo |= 0x01;
67 _wrmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), hi, lo); 68 _wrmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), hi, lo);
68 } else 69 } else {
70 _rdmsr(IDE_MSR_REG(IDE_CFG), &hi, &lo);
71 lo = value;
69 _wrmsr(IDE_MSR_REG(IDE_CFG), hi, lo); 72 _wrmsr(IDE_MSR_REG(IDE_CFG), hi, lo);
73 }
70 break; 74 break;
71 case PCI_IDE_DTC_REG: 75 case PCI_IDE_DTC_REG:
76 _rdmsr(IDE_MSR_REG(IDE_DTC), &hi, &lo);
77 lo = value;
72 _wrmsr(IDE_MSR_REG(IDE_DTC), hi, lo); 78 _wrmsr(IDE_MSR_REG(IDE_DTC), hi, lo);
73 break; 79 break;
74 case PCI_IDE_CAST_REG: 80 case PCI_IDE_CAST_REG:
81 _rdmsr(IDE_MSR_REG(IDE_CAST), &hi, &lo);
82 lo = value;
75 _wrmsr(IDE_MSR_REG(IDE_CAST), hi, lo); 83 _wrmsr(IDE_MSR_REG(IDE_CAST), hi, lo);
76 break; 84 break;
77 case PCI_IDE_ETC_REG: 85 case PCI_IDE_ETC_REG:
86 _rdmsr(IDE_MSR_REG(IDE_ETC), &hi, &lo);
87 lo = value;
78 _wrmsr(IDE_MSR_REG(IDE_ETC), hi, lo); 88 _wrmsr(IDE_MSR_REG(IDE_ETC), hi, lo);
79 break; 89 break;
80 case PCI_IDE_PM_REG: 90 case PCI_IDE_PM_REG:
91 _rdmsr(IDE_MSR_REG(IDE_INTERNAL_PM), &hi, &lo);
92 lo = value;
81 _wrmsr(IDE_MSR_REG(IDE_INTERNAL_PM), hi, lo); 93 _wrmsr(IDE_MSR_REG(IDE_INTERNAL_PM), hi, lo);
82 break; 94 break;
83 default: 95 default:
@@ -167,6 +179,7 @@ u32 pci_ide_read_reg(int reg)
167 case PCI_IDE_ETC_REG: 179 case PCI_IDE_ETC_REG:
168 _rdmsr(IDE_MSR_REG(IDE_ETC), &hi, &lo); 180 _rdmsr(IDE_MSR_REG(IDE_ETC), &hi, &lo);
169 conf_data = lo; 181 conf_data = lo;
182 break;
170 case PCI_IDE_PM_REG: 183 case PCI_IDE_PM_REG:
171 _rdmsr(IDE_MSR_REG(IDE_INTERNAL_PM), &hi, &lo); 184 _rdmsr(IDE_MSR_REG(IDE_INTERNAL_PM), &hi, &lo);
172 conf_data = lo; 185 conf_data = lo;
diff --git a/arch/mips/loongson/common/cs5536/cs5536_isa.c b/arch/mips/loongson/common/cs5536/cs5536_isa.c
index f5c0818831b2..4d9f65abeaff 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_isa.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_isa.c
@@ -61,7 +61,7 @@ static void divil_lbar_enable(void)
61 for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) { 61 for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) {
62 _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo); 62 _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo);
63 hi |= 0x01; 63 hi |= 0x01;
64 _wrmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), hi, lo); 64 _wrmsr(DIVIL_MSR_REG(offset), hi, lo);
65 } 65 }
66} 66}
67 67
@@ -76,7 +76,7 @@ static void divil_lbar_disable(void)
76 for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) { 76 for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) {
77 _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo); 77 _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo);
78 hi &= ~0x01; 78 hi &= ~0x01;
79 _wrmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), hi, lo); 79 _wrmsr(DIVIL_MSR_REG(offset), hi, lo);
80 } 80 }
81} 81}
82 82
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ohci.c b/arch/mips/loongson/common/cs5536/cs5536_ohci.c
index db5900aadd6b..bdedf512baf7 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_ohci.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_ohci.c
@@ -49,6 +49,8 @@ void pci_ohci_write_reg(int reg, u32 value)
49 lo |= SOFT_BAR_OHCI_FLAG; 49 lo |= SOFT_BAR_OHCI_FLAG;
50 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo); 50 _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
51 } else if ((value & 0x01) == 0x00) { 51 } else if ((value & 0x01) == 0x00) {
52 _rdmsr(USB_MSR_REG(USB_OHCI), &hi, &lo);
53 lo = value;
52 _wrmsr(USB_MSR_REG(USB_OHCI), hi, lo); 54 _wrmsr(USB_MSR_REG(USB_OHCI), hi, lo);
53 55
54 value &= 0xfffffff0; 56 value &= 0xfffffff0;
diff --git a/arch/mips/loongson/common/rtc.c b/arch/mips/loongson/common/rtc.c
new file mode 100644
index 000000000000..a90d87c01555
--- /dev/null
+++ b/arch/mips/loongson/common/rtc.c
@@ -0,0 +1,43 @@
1/*
2 * Lemote Fuloong platform support
3 *
4 * Copyright(c) 2010 Arnaud Patard <apatard@mandriva.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/mc146818rtc.h>
16
17struct resource loongson_rtc_resources[] = {
18 {
19 .start = RTC_PORT(0),
20 .end = RTC_PORT(1),
21 .flags = IORESOURCE_IO,
22 }, {
23 .start = RTC_IRQ,
24 .end = RTC_IRQ,
25 .flags = IORESOURCE_IRQ,
26 }
27};
28
29static struct platform_device loongson_rtc_device = {
30 .name = "rtc_cmos",
31 .id = -1,
32 .resource = loongson_rtc_resources,
33 .num_resources = ARRAY_SIZE(loongson_rtc_resources),
34};
35
36
37static int __init loongson_rtc_platform_init(void)
38{
39 platform_device_register(&loongson_rtc_device);
40 return 0;
41}
42
43device_initcall(loongson_rtc_platform_init);
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index d9ae1dbabda7..b90974246e5b 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -78,6 +78,7 @@ ieee754dp ieee754dp_abs(ieee754dp x)
78 DPSIGN(x) = 0; 78 DPSIGN(x) = 0;
79 79
80 if (xc == IEEE754_CLASS_SNAN) { 80 if (xc == IEEE754_CLASS_SNAN) {
81 SETCX(IEEE754_INVALID_OPERATION);
81 return ieee754dp_nanxcpt(ieee754dp_indef(), "abs"); 82 return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
82 } 83 }
83 84
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index 3175477d36f6..2fd53c920e99 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -78,6 +78,7 @@ ieee754sp ieee754sp_abs(ieee754sp x)
78 SPSIGN(x) = 0; 78 SPSIGN(x) = 0;
79 79
80 if (xc == IEEE754_CLASS_SNAN) { 80 if (xc == IEEE754_CLASS_SNAN) {
81 SETCX(IEEE754_INVALID_OPERATION);
81 return ieee754sp_nanxcpt(ieee754sp_indef(), "abs"); 82 return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
82 } 83 }
83 84
diff --git a/arch/mips/oprofile/op_model_loongson2.c b/arch/mips/oprofile/op_model_loongson2.c
index d0d24e047676..60d3ea602118 100644
--- a/arch/mips/oprofile/op_model_loongson2.c
+++ b/arch/mips/oprofile/op_model_loongson2.c
@@ -43,6 +43,12 @@ static struct loongson2_register_config {
43static char *oprofid = "LoongsonPerf"; 43static char *oprofid = "LoongsonPerf";
44static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id); 44static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id);
45 45
46static void reset_counters(void *arg)
47{
48 write_c0_perfctrl(0);
49 write_c0_perfcnt(0);
50}
51
46static void loongson2_reg_setup(struct op_counter_config *cfg) 52static void loongson2_reg_setup(struct op_counter_config *cfg)
47{ 53{
48 unsigned int ctrl = 0; 54 unsigned int ctrl = 0;
@@ -139,7 +145,7 @@ static int __init loongson2_init(void)
139 145
140static void loongson2_exit(void) 146static void loongson2_exit(void)
141{ 147{
142 write_c0_perfctrl(0); 148 reset_counters(NULL);
143 free_irq(LOONGSON2_PERFCNT_IRQ, oprofid); 149 free_irq(LOONGSON2_PERFCNT_IRQ, oprofid);
144} 150}
145 151
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 328774bd41ee..6506bf4fbff1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -400,7 +400,7 @@ config IRQ_ALL_CPUS
400 400
401config SPARSE_IRQ 401config SPARSE_IRQ
402 bool "Support sparse irq numbering" 402 bool "Support sparse irq numbering"
403 default y 403 default n
404 help 404 help
405 This enables support for sparse irqs. This is useful for distro 405 This enables support for sparse irqs. This is useful for distro
406 kernels that want to define a high CONFIG_NR_CPUS value but still 406 kernels that want to define a high CONFIG_NR_CPUS value but still
@@ -409,7 +409,7 @@ config SPARSE_IRQ
409 ( Sparse IRQs can also be beneficial on NUMA boxes, as they spread 409 ( Sparse IRQs can also be beneficial on NUMA boxes, as they spread
410 out the irq_desc[] array in a more NUMA-friendly way. ) 410 out the irq_desc[] array in a more NUMA-friendly way. )
411 411
412 If you don't know what to do here, say Y. 412 If you don't know what to do here, say N.
413 413
414config NUMA 414config NUMA
415 bool "NUMA support" 415 bool "NUMA support"
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 42dcd3f4ad7b..77cfe7a29e25 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -92,10 +92,10 @@ endif
92else 92else
93 KBUILD_CFLAGS += $(call cc-option,-mtune=power4) 93 KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
94endif 94endif
95else
96LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
97endif 95endif
98 96
97LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
98
99ifeq ($(CONFIG_TUNE_CELL),y) 99ifeq ($(CONFIG_TUNE_CELL),y)
100 KBUILD_CFLAGS += $(call cc-option,-mtune=cell) 100 KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
101endif 101endif
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index 5d8be0416227..0175a676b34b 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -24,11 +24,7 @@
24 * 2 of the License, or (at your option) any later version. 24 * 2 of the License, or (at your option) any later version.
25 */ 25 */
26 26
27#ifdef __KERNEL__
28#include <linux/types.h> 27#include <linux/types.h>
29#else
30#include <stdint.h>
31#endif
32 28
33#ifndef __ASSEMBLY__ 29#ifndef __ASSEMBLY__
34 30
@@ -364,13 +360,13 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
364#ifndef __ASSEMBLY__ 360#ifndef __ASSEMBLY__
365 361
366struct ppc_debug_info { 362struct ppc_debug_info {
367 uint32_t version; /* Only version 1 exists to date */ 363 __u32 version; /* Only version 1 exists to date */
368 uint32_t num_instruction_bps; 364 __u32 num_instruction_bps;
369 uint32_t num_data_bps; 365 __u32 num_data_bps;
370 uint32_t num_condition_regs; 366 __u32 num_condition_regs;
371 uint32_t data_bp_alignment; 367 __u32 data_bp_alignment;
372 uint32_t sizeof_condition; /* size of the DVC register */ 368 __u32 sizeof_condition; /* size of the DVC register */
373 uint64_t features; 369 __u64 features;
374}; 370};
375 371
376#endif /* __ASSEMBLY__ */ 372#endif /* __ASSEMBLY__ */
@@ -386,13 +382,13 @@ struct ppc_debug_info {
386#ifndef __ASSEMBLY__ 382#ifndef __ASSEMBLY__
387 383
388struct ppc_hw_breakpoint { 384struct ppc_hw_breakpoint {
389 uint32_t version; /* currently, version must be 1 */ 385 __u32 version; /* currently, version must be 1 */
390 uint32_t trigger_type; /* only some combinations allowed */ 386 __u32 trigger_type; /* only some combinations allowed */
391 uint32_t addr_mode; /* address match mode */ 387 __u32 addr_mode; /* address match mode */
392 uint32_t condition_mode; /* break/watchpoint condition flags */ 388 __u32 condition_mode; /* break/watchpoint condition flags */
393 uint64_t addr; /* break/watchpoint address */ 389 __u64 addr; /* break/watchpoint address */
394 uint64_t addr2; /* range end or mask */ 390 __u64 addr2; /* range end or mask */
395 uint64_t condition_value; /* contents of the DVC register */ 391 __u64 condition_value; /* contents of the DVC register */
396}; 392};
397 393
398#endif /* __ASSEMBLY__ */ 394#endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index b46f2e09bd81..29df48f2b61a 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -447,7 +447,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
447 crash_kexec_prepare_cpus(crashing_cpu); 447 crash_kexec_prepare_cpus(crashing_cpu);
448 cpu_set(crashing_cpu, cpus_in_crash); 448 cpu_set(crashing_cpu, cpus_in_crash);
449 crash_kexec_stop_spus(); 449 crash_kexec_stop_spus();
450#ifdef CONFIG_PPC_STD_MMU_64 450#if defined(CONFIG_PPC_STD_MMU_64) && defined(CONFIG_SMP)
451 crash_kexec_wait_realmode(crashing_cpu); 451 crash_kexec_wait_realmode(crashing_cpu);
452#endif 452#endif
453 if (ppc_md.kexec_cpu_down) 453 if (ppc_md.kexec_cpu_down)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 3333bbdd23ef..77be3d058a65 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -295,7 +295,10 @@ void fixup_irqs(const struct cpumask *map)
295 295
296 for_each_irq(irq) { 296 for_each_irq(irq) {
297 desc = irq_to_desc(irq); 297 desc = irq_to_desc(irq);
298 if (desc && desc->status & IRQ_PER_CPU) 298 if (!desc)
299 continue;
300
301 if (desc->status & IRQ_PER_CPU)
299 continue; 302 continue;
300 303
301 cpumask_and(mask, desc->affinity, map); 304 cpumask_and(mask, desc->affinity, map);
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
index 43b83c35cf54..5c14ffe51258 100644
--- a/arch/powerpc/kernel/perf_event.c
+++ b/arch/powerpc/kernel/perf_event.c
@@ -791,8 +791,11 @@ static void power_pmu_disable(struct perf_event *event)
791 cpuhw = &__get_cpu_var(cpu_hw_events); 791 cpuhw = &__get_cpu_var(cpu_hw_events);
792 for (i = 0; i < cpuhw->n_events; ++i) { 792 for (i = 0; i < cpuhw->n_events; ++i) {
793 if (event == cpuhw->event[i]) { 793 if (event == cpuhw->event[i]) {
794 while (++i < cpuhw->n_events) 794 while (++i < cpuhw->n_events) {
795 cpuhw->event[i-1] = cpuhw->event[i]; 795 cpuhw->event[i-1] = cpuhw->event[i];
796 cpuhw->events[i-1] = cpuhw->events[i];
797 cpuhw->flags[i-1] = cpuhw->flags[i];
798 }
796 --cpuhw->n_events; 799 --cpuhw->n_events;
797 ppmu->disable_pmc(event->hw.idx - 1, cpuhw->mmcr); 800 ppmu->disable_pmc(event->hw.idx - 1, cpuhw->mmcr);
798 if (event->hw.idx) { 801 if (event->hw.idx) {
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 97d4bd9442d3..3b6f8ae9b8cc 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -872,7 +872,7 @@ static void __init prom_send_capabilities(void)
872 "ibm_architecture_vec structure inconsistent: 0x%x !\n", 872 "ibm_architecture_vec structure inconsistent: 0x%x !\n",
873 *cores); 873 *cores);
874 } else { 874 } else {
875 *cores = NR_CPUS / prom_count_smt_threads(); 875 *cores = DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads());
876 prom_printf("Max number of cores passed to firmware: 0x%x\n", 876 prom_printf("Max number of cores passed to firmware: 0x%x\n",
877 (unsigned long)*cores); 877 (unsigned long)*cores);
878 } 878 }
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 1ac136b128f0..9f82f4937892 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -52,12 +52,18 @@ do
52 if [ "${UNDEF:0:9}" = "_restgpr_" ]; then 52 if [ "${UNDEF:0:9}" = "_restgpr_" ]; then
53 OK=1 53 OK=1
54 fi 54 fi
55 if [ "${UNDEF:0:10}" = "_restgpr0_" ]; then
56 OK=1
57 fi
55 if [ "${UNDEF:0:11}" = "_rest32gpr_" ]; then 58 if [ "${UNDEF:0:11}" = "_rest32gpr_" ]; then
56 OK=1 59 OK=1
57 fi 60 fi
58 if [ "${UNDEF:0:9}" = "_savegpr_" ]; then 61 if [ "${UNDEF:0:9}" = "_savegpr_" ]; then
59 OK=1 62 OK=1
60 fi 63 fi
64 if [ "${UNDEF:0:10}" = "_savegpr0_" ]; then
65 OK=1
66 fi
61 if [ "${UNDEF:0:11}" = "_save32gpr_" ]; then 67 if [ "${UNDEF:0:11}" = "_save32gpr_" ]; then
62 OK=1 68 OK=1
63 fi 69 fi
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 3040dac18a37..111da1c03a11 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -12,8 +12,8 @@ CFLAGS_REMOVE_code-patching.o = -pg
12CFLAGS_REMOVE_feature-fixups.o = -pg 12CFLAGS_REMOVE_feature-fixups.o = -pg
13 13
14obj-y := string.o alloc.o \ 14obj-y := string.o alloc.o \
15 checksum_$(CONFIG_WORD_SIZE).o 15 checksum_$(CONFIG_WORD_SIZE).o crtsavres.o
16obj-$(CONFIG_PPC32) += div64.o copy_32.o crtsavres.o 16obj-$(CONFIG_PPC32) += div64.o copy_32.o
17obj-$(CONFIG_HAS_IOMEM) += devres.o 17obj-$(CONFIG_HAS_IOMEM) += devres.o
18 18
19obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \ 19obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \
diff --git a/arch/powerpc/lib/crtsavres.S b/arch/powerpc/lib/crtsavres.S
index 70a9cd8a3008..1c893f05d224 100644
--- a/arch/powerpc/lib/crtsavres.S
+++ b/arch/powerpc/lib/crtsavres.S
@@ -6,6 +6,7 @@
6 * Written By Michael Meissner 6 * Written By Michael Meissner
7 * 7 *
8 * Based on gcc/config/rs6000/crtsavres.asm from gcc 8 * Based on gcc/config/rs6000/crtsavres.asm from gcc
9 * 64 bit additions from reading the PPC elf64abi document.
9 * 10 *
10 * This file is free software; you can redistribute it and/or modify it 11 * This file is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 12 * under the terms of the GNU General Public License as published by the
@@ -44,6 +45,8 @@
44 45
45#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 46#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
46 47
48#ifndef CONFIG_PPC64
49
47/* Routines for saving integer registers, called by the compiler. */ 50/* Routines for saving integer registers, called by the compiler. */
48/* Called with r11 pointing to the stack header word of the caller of the */ 51/* Called with r11 pointing to the stack header word of the caller of the */
49/* function, just beyond the end of the integer save area. */ 52/* function, just beyond the end of the integer save area. */
@@ -226,4 +229,130 @@ _GLOBAL(_rest32gpr_31_x)
226 mtlr 0 229 mtlr 0
227 mr 1,11 230 mr 1,11
228 blr 231 blr
232
233#else /* CONFIG_PPC64 */
234
235.globl _savegpr0_14
236_savegpr0_14:
237 std r14,-144(r1)
238.globl _savegpr0_15
239_savegpr0_15:
240 std r15,-136(r1)
241.globl _savegpr0_16
242_savegpr0_16:
243 std r16,-128(r1)
244.globl _savegpr0_17
245_savegpr0_17:
246 std r17,-120(r1)
247.globl _savegpr0_18
248_savegpr0_18:
249 std r18,-112(r1)
250.globl _savegpr0_19
251_savegpr0_19:
252 std r19,-104(r1)
253.globl _savegpr0_20
254_savegpr0_20:
255 std r20,-96(r1)
256.globl _savegpr0_21
257_savegpr0_21:
258 std r21,-88(r1)
259.globl _savegpr0_22
260_savegpr0_22:
261 std r22,-80(r1)
262.globl _savegpr0_23
263_savegpr0_23:
264 std r23,-72(r1)
265.globl _savegpr0_24
266_savegpr0_24:
267 std r24,-64(r1)
268.globl _savegpr0_25
269_savegpr0_25:
270 std r25,-56(r1)
271.globl _savegpr0_26
272_savegpr0_26:
273 std r26,-48(r1)
274.globl _savegpr0_27
275_savegpr0_27:
276 std r27,-40(r1)
277.globl _savegpr0_28
278_savegpr0_28:
279 std r28,-32(r1)
280.globl _savegpr0_29
281_savegpr0_29:
282 std r29,-24(r1)
283.globl _savegpr0_30
284_savegpr0_30:
285 std r30,-16(r1)
286.globl _savegpr0_31
287_savegpr0_31:
288 std r31,-8(r1)
289 std r0,16(r1)
290 blr
291
292.globl _restgpr0_14
293_restgpr0_14:
294 ld r14,-144(r1)
295.globl _restgpr0_15
296_restgpr0_15:
297 ld r15,-136(r1)
298.globl _restgpr0_16
299_restgpr0_16:
300 ld r16,-128(r1)
301.globl _restgpr0_17
302_restgpr0_17:
303 ld r17,-120(r1)
304.globl _restgpr0_18
305_restgpr0_18:
306 ld r18,-112(r1)
307.globl _restgpr0_19
308_restgpr0_19:
309 ld r19,-104(r1)
310.globl _restgpr0_20
311_restgpr0_20:
312 ld r20,-96(r1)
313.globl _restgpr0_21
314_restgpr0_21:
315 ld r21,-88(r1)
316.globl _restgpr0_22
317_restgpr0_22:
318 ld r22,-80(r1)
319.globl _restgpr0_23
320_restgpr0_23:
321 ld r23,-72(r1)
322.globl _restgpr0_24
323_restgpr0_24:
324 ld r24,-64(r1)
325.globl _restgpr0_25
326_restgpr0_25:
327 ld r25,-56(r1)
328.globl _restgpr0_26
329_restgpr0_26:
330 ld r26,-48(r1)
331.globl _restgpr0_27
332_restgpr0_27:
333 ld r27,-40(r1)
334.globl _restgpr0_28
335_restgpr0_28:
336 ld r28,-32(r1)
337.globl _restgpr0_29
338_restgpr0_29:
339 ld r0,16(r1)
340 ld r29,-24(r1)
341 mtlr r0
342 ld r30,-16(r1)
343 ld r31,-8(r1)
344 blr
345
346.globl _restgpr0_30
347_restgpr0_30:
348 ld r30,-16(r1)
349.globl _restgpr0_31
350_restgpr0_31:
351 ld r0,16(r1)
352 ld r31,-8(r1)
353 mtlr r0
354 blr
355
356#endif /* CONFIG_PPC64 */
357
229#endif 358#endif
diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
index e640175b65ae..0d08d0171392 100644
--- a/arch/powerpc/lib/feature-fixups.c
+++ b/arch/powerpc/lib/feature-fixups.c
@@ -12,6 +12,7 @@
12 * 2 of the License, or (at your option) any later version. 12 * 2 of the License, or (at your option) any later version.
13 */ 13 */
14 14
15#include <linux/types.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/string.h> 17#include <linux/string.h>
17#include <linux/init.h> 18#include <linux/init.h>
@@ -288,8 +289,8 @@ static void test_alternative_case_with_external_branch(void)
288 289
289static void test_cpu_macros(void) 290static void test_cpu_macros(void)
290{ 291{
291 extern void ftr_fixup_test_FTR_macros; 292 extern u8 ftr_fixup_test_FTR_macros;
292 extern void ftr_fixup_test_FTR_macros_expected; 293 extern u8 ftr_fixup_test_FTR_macros_expected;
293 unsigned long size = &ftr_fixup_test_FTR_macros_expected - 294 unsigned long size = &ftr_fixup_test_FTR_macros_expected -
294 &ftr_fixup_test_FTR_macros; 295 &ftr_fixup_test_FTR_macros;
295 296
@@ -301,8 +302,8 @@ static void test_cpu_macros(void)
301static void test_fw_macros(void) 302static void test_fw_macros(void)
302{ 303{
303#ifdef CONFIG_PPC64 304#ifdef CONFIG_PPC64
304 extern void ftr_fixup_test_FW_FTR_macros; 305 extern u8 ftr_fixup_test_FW_FTR_macros;
305 extern void ftr_fixup_test_FW_FTR_macros_expected; 306 extern u8 ftr_fixup_test_FW_FTR_macros_expected;
306 unsigned long size = &ftr_fixup_test_FW_FTR_macros_expected - 307 unsigned long size = &ftr_fixup_test_FW_FTR_macros_expected -
307 &ftr_fixup_test_FW_FTR_macros; 308 &ftr_fixup_test_FW_FTR_macros;
308 309
@@ -314,10 +315,10 @@ static void test_fw_macros(void)
314 315
315static void test_lwsync_macros(void) 316static void test_lwsync_macros(void)
316{ 317{
317 extern void lwsync_fixup_test; 318 extern u8 lwsync_fixup_test;
318 extern void end_lwsync_fixup_test; 319 extern u8 end_lwsync_fixup_test;
319 extern void lwsync_fixup_test_expected_LWSYNC; 320 extern u8 lwsync_fixup_test_expected_LWSYNC;
320 extern void lwsync_fixup_test_expected_SYNC; 321 extern u8 lwsync_fixup_test_expected_SYNC;
321 unsigned long size = &end_lwsync_fixup_test - 322 unsigned long size = &end_lwsync_fixup_test -
322 &lwsync_fixup_test; 323 &lwsync_fixup_test;
323 324
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 3fc2e6494b8b..ab3962b0d246 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -445,7 +445,11 @@ void __init iSeries_pcibios_fixup_resources(struct pci_dev *pdev)
445 } 445 }
446 446
447 allocate_device_bars(pdev); 447 allocate_device_bars(pdev);
448 iseries_device_information(pdev, bus, *sub_bus); 448 if (likely(sub_bus))
449 iseries_device_information(pdev, bus, *sub_bus);
450 else
451 printk(KERN_ERR "PCI: Device node %s has missing or invalid "
452 "linux,subbus property\n", node->full_name);
449} 453}
450 454
451/* 455/*
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 0b96b5589f08..078d4ec1a9d9 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -110,7 +110,7 @@ int use_calgary __read_mostly = 0;
110 * x3950 (PCIE): 8 chassis, 32 PHBs per chassis = 256 110 * x3950 (PCIE): 8 chassis, 32 PHBs per chassis = 256
111 * x3950 (PCIX): 8 chassis, 16 PHBs per chassis = 128 111 * x3950 (PCIX): 8 chassis, 16 PHBs per chassis = 128
112 */ 112 */
113#define MAX_PHB_BUS_NUM 384 113#define MAX_PHB_BUS_NUM 256
114 114
115#define PHBS_PER_CALGARY 4 115#define PHBS_PER_CALGARY 4
116 116
@@ -1056,8 +1056,6 @@ static int __init calgary_init_one(struct pci_dev *dev)
1056 struct iommu_table *tbl; 1056 struct iommu_table *tbl;
1057 int ret; 1057 int ret;
1058 1058
1059 BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM);
1060
1061 bbar = busno_to_bbar(dev->bus->number); 1059 bbar = busno_to_bbar(dev->bus->number);
1062 ret = calgary_setup_tar(dev, bbar); 1060 ret = calgary_setup_tar(dev, bbar);
1063 if (ret) 1061 if (ret)
diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
index f20eeec85a86..8acaddd0fb21 100644
--- a/arch/x86/mm/pat_rbtree.c
+++ b/arch/x86/mm/pat_rbtree.c
@@ -34,8 +34,7 @@
34 * memtype_lock protects the rbtree. 34 * memtype_lock protects the rbtree.
35 */ 35 */
36 36
37static void memtype_rb_augment_cb(struct rb_node *node); 37static struct rb_root memtype_rbroot = RB_ROOT;
38static struct rb_root memtype_rbroot = RB_AUGMENT_ROOT(&memtype_rb_augment_cb);
39 38
40static int is_node_overlap(struct memtype *node, u64 start, u64 end) 39static int is_node_overlap(struct memtype *node, u64 start, u64 end)
41{ 40{
@@ -56,7 +55,7 @@ static u64 get_subtree_max_end(struct rb_node *node)
56} 55}
57 56
58/* Update 'subtree_max_end' for a node, based on node and its children */ 57/* Update 'subtree_max_end' for a node, based on node and its children */
59static void update_node_max_end(struct rb_node *node) 58static void memtype_rb_augment_cb(struct rb_node *node, void *__unused)
60{ 59{
61 struct memtype *data; 60 struct memtype *data;
62 u64 max_end, child_max_end; 61 u64 max_end, child_max_end;
@@ -78,25 +77,6 @@ static void update_node_max_end(struct rb_node *node)
78 data->subtree_max_end = max_end; 77 data->subtree_max_end = max_end;
79} 78}
80 79
81/* Update 'subtree_max_end' for a node and all its ancestors */
82static void update_path_max_end(struct rb_node *node)
83{
84 u64 old_max_end, new_max_end;
85
86 while (node) {
87 struct memtype *data = container_of(node, struct memtype, rb);
88
89 old_max_end = data->subtree_max_end;
90 update_node_max_end(node);
91 new_max_end = data->subtree_max_end;
92
93 if (new_max_end == old_max_end)
94 break;
95
96 node = rb_parent(node);
97 }
98}
99
100/* Find the first (lowest start addr) overlapping range from rb tree */ 80/* Find the first (lowest start addr) overlapping range from rb tree */
101static struct memtype *memtype_rb_lowest_match(struct rb_root *root, 81static struct memtype *memtype_rb_lowest_match(struct rb_root *root,
102 u64 start, u64 end) 82 u64 start, u64 end)
@@ -190,12 +170,6 @@ failure:
190 return -EBUSY; 170 return -EBUSY;
191} 171}
192 172
193static void memtype_rb_augment_cb(struct rb_node *node)
194{
195 if (node)
196 update_path_max_end(node);
197}
198
199static void memtype_rb_insert(struct rb_root *root, struct memtype *newdata) 173static void memtype_rb_insert(struct rb_root *root, struct memtype *newdata)
200{ 174{
201 struct rb_node **node = &(root->rb_node); 175 struct rb_node **node = &(root->rb_node);
@@ -213,6 +187,7 @@ static void memtype_rb_insert(struct rb_root *root, struct memtype *newdata)
213 187
214 rb_link_node(&newdata->rb, parent, node); 188 rb_link_node(&newdata->rb, parent, node);
215 rb_insert_color(&newdata->rb, root); 189 rb_insert_color(&newdata->rb, root);
190 rb_augment_insert(&newdata->rb, memtype_rb_augment_cb, NULL);
216} 191}
217 192
218int rbt_memtype_check_insert(struct memtype *new, unsigned long *ret_type) 193int rbt_memtype_check_insert(struct memtype *new, unsigned long *ret_type)
@@ -234,13 +209,16 @@ int rbt_memtype_check_insert(struct memtype *new, unsigned long *ret_type)
234 209
235struct memtype *rbt_memtype_erase(u64 start, u64 end) 210struct memtype *rbt_memtype_erase(u64 start, u64 end)
236{ 211{
212 struct rb_node *deepest;
237 struct memtype *data; 213 struct memtype *data;
238 214
239 data = memtype_rb_exact_match(&memtype_rbroot, start, end); 215 data = memtype_rb_exact_match(&memtype_rbroot, start, end);
240 if (!data) 216 if (!data)
241 goto out; 217 goto out;
242 218
219 deepest = rb_augment_erase_begin(&data->rb);
243 rb_erase(&data->rb, &memtype_rbroot); 220 rb_erase(&data->rb, &memtype_rbroot);
221 rb_augment_erase_end(deepest, memtype_rb_augment_cb, NULL);
244out: 222out:
245 return data; 223 return data;
246} 224}
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 6f907ebed2d5..6d34f405a2f3 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -37,7 +37,7 @@
37#include <linux/wait.h> 37#include <linux/wait.h>
38 38
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <asm/io.h> 40#include <linux/io.h>
41 41
42#include <pcmcia/cs_types.h> 42#include <pcmcia/cs_types.h>
43#include <pcmcia/cs.h> 43#include <pcmcia/cs.h>
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 40aec0fb8596..42d69d4de05c 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -244,7 +244,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
244 if (rel) { 244 if (rel) {
245 hdr[0] |= 0x80 + bcsp->msgq_txseq; 245 hdr[0] |= 0x80 + bcsp->msgq_txseq;
246 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); 246 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq);
247 bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; 247 bcsp->msgq_txseq = (bcsp->msgq_txseq + 1) & 0x07;
248 } 248 }
249 249
250 if (bcsp->use_crc) 250 if (bcsp->use_crc)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1f2cc6b09623..719662034bbf 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -315,8 +315,9 @@ static void drm_fb_helper_on(struct fb_info *info)
315 struct drm_device *dev = fb_helper->dev; 315 struct drm_device *dev = fb_helper->dev;
316 struct drm_crtc *crtc; 316 struct drm_crtc *crtc;
317 struct drm_crtc_helper_funcs *crtc_funcs; 317 struct drm_crtc_helper_funcs *crtc_funcs;
318 struct drm_connector *connector;
318 struct drm_encoder *encoder; 319 struct drm_encoder *encoder;
319 int i; 320 int i, j;
320 321
321 /* 322 /*
322 * For each CRTC in this fb, turn the crtc on then, 323 * For each CRTC in this fb, turn the crtc on then,
@@ -332,7 +333,14 @@ static void drm_fb_helper_on(struct fb_info *info)
332 333
333 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); 334 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
334 335
335 336 /* Walk the connectors & encoders on this fb turning them on */
337 for (j = 0; j < fb_helper->connector_count; j++) {
338 connector = fb_helper->connector_info[j]->connector;
339 connector->dpms = DRM_MODE_DPMS_ON;
340 drm_connector_property_set_value(connector,
341 dev->mode_config.dpms_property,
342 DRM_MODE_DPMS_ON);
343 }
336 /* Found a CRTC on this fb, now find encoders */ 344 /* Found a CRTC on this fb, now find encoders */
337 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 345 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
338 if (encoder->crtc == crtc) { 346 if (encoder->crtc == crtc) {
@@ -352,8 +360,9 @@ static void drm_fb_helper_off(struct fb_info *info, int dpms_mode)
352 struct drm_device *dev = fb_helper->dev; 360 struct drm_device *dev = fb_helper->dev;
353 struct drm_crtc *crtc; 361 struct drm_crtc *crtc;
354 struct drm_crtc_helper_funcs *crtc_funcs; 362 struct drm_crtc_helper_funcs *crtc_funcs;
363 struct drm_connector *connector;
355 struct drm_encoder *encoder; 364 struct drm_encoder *encoder;
356 int i; 365 int i, j;
357 366
358 /* 367 /*
359 * For each CRTC in this fb, find all associated encoders 368 * For each CRTC in this fb, find all associated encoders
@@ -367,6 +376,14 @@ static void drm_fb_helper_off(struct fb_info *info, int dpms_mode)
367 if (!crtc->enabled) 376 if (!crtc->enabled)
368 continue; 377 continue;
369 378
379 /* Walk the connectors on this fb and mark them off */
380 for (j = 0; j < fb_helper->connector_count; j++) {
381 connector = fb_helper->connector_info[j]->connector;
382 connector->dpms = dpms_mode;
383 drm_connector_property_set_value(connector,
384 dev->mode_config.dpms_property,
385 dpms_mode);
386 }
370 /* Found a CRTC on this fb, now find encoders */ 387 /* Found a CRTC on this fb, now find encoders */
371 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 388 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
372 if (encoder->crtc == crtc) { 389 if (encoder->crtc == crtc) {
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 0c7ccc6961a3..f58f8bd8f77b 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -785,7 +785,9 @@ static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connect
785 if (connector == list_connector) 785 if (connector == list_connector)
786 continue; 786 continue;
787 list_radeon_connector = to_radeon_connector(list_connector); 787 list_radeon_connector = to_radeon_connector(list_connector);
788 if (radeon_connector->devices == list_radeon_connector->devices) { 788 if (list_radeon_connector->shared_ddc &&
789 (list_radeon_connector->ddc_bus->rec.i2c_id ==
790 radeon_connector->ddc_bus->rec.i2c_id)) {
789 if (drm_detect_hdmi_monitor(radeon_connector->edid)) { 791 if (drm_detect_hdmi_monitor(radeon_connector->edid)) {
790 if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) { 792 if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) {
791 kfree(radeon_connector->edid); 793 kfree(radeon_connector->edid);
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 2f047577b1e3..b1d67dc973dc 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -104,7 +104,6 @@ struct ttm_pool_opts {
104struct ttm_pool_manager { 104struct ttm_pool_manager {
105 struct kobject kobj; 105 struct kobject kobj;
106 struct shrinker mm_shrink; 106 struct shrinker mm_shrink;
107 atomic_t page_alloc_inited;
108 struct ttm_pool_opts options; 107 struct ttm_pool_opts options;
109 108
110 union { 109 union {
@@ -142,7 +141,7 @@ static void ttm_pool_kobj_release(struct kobject *kobj)
142{ 141{
143 struct ttm_pool_manager *m = 142 struct ttm_pool_manager *m =
144 container_of(kobj, struct ttm_pool_manager, kobj); 143 container_of(kobj, struct ttm_pool_manager, kobj);
145 (void)m; 144 kfree(m);
146} 145}
147 146
148static ssize_t ttm_pool_store(struct kobject *kobj, 147static ssize_t ttm_pool_store(struct kobject *kobj,
@@ -214,9 +213,7 @@ static struct kobj_type ttm_pool_kobj_type = {
214 .default_attrs = ttm_pool_attrs, 213 .default_attrs = ttm_pool_attrs,
215}; 214};
216 215
217static struct ttm_pool_manager _manager = { 216static struct ttm_pool_manager *_manager;
218 .page_alloc_inited = ATOMIC_INIT(0)
219};
220 217
221#ifndef CONFIG_X86 218#ifndef CONFIG_X86
222static int set_pages_array_wb(struct page **pages, int addrinarray) 219static int set_pages_array_wb(struct page **pages, int addrinarray)
@@ -271,7 +268,7 @@ static struct ttm_page_pool *ttm_get_pool(int flags,
271 if (flags & TTM_PAGE_FLAG_DMA32) 268 if (flags & TTM_PAGE_FLAG_DMA32)
272 pool_index |= 0x2; 269 pool_index |= 0x2;
273 270
274 return &_manager.pools[pool_index]; 271 return &_manager->pools[pool_index];
275} 272}
276 273
277/* set memory back to wb and free the pages. */ 274/* set memory back to wb and free the pages. */
@@ -387,7 +384,7 @@ static int ttm_pool_get_num_unused_pages(void)
387 unsigned i; 384 unsigned i;
388 int total = 0; 385 int total = 0;
389 for (i = 0; i < NUM_POOLS; ++i) 386 for (i = 0; i < NUM_POOLS; ++i)
390 total += _manager.pools[i].npages; 387 total += _manager->pools[i].npages;
391 388
392 return total; 389 return total;
393} 390}
@@ -408,7 +405,7 @@ static int ttm_pool_mm_shrink(int shrink_pages, gfp_t gfp_mask)
408 unsigned nr_free = shrink_pages; 405 unsigned nr_free = shrink_pages;
409 if (shrink_pages == 0) 406 if (shrink_pages == 0)
410 break; 407 break;
411 pool = &_manager.pools[(i + pool_offset)%NUM_POOLS]; 408 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
412 shrink_pages = ttm_page_pool_free(pool, nr_free); 409 shrink_pages = ttm_page_pool_free(pool, nr_free);
413 } 410 }
414 /* return estimated number of unused pages in pool */ 411 /* return estimated number of unused pages in pool */
@@ -576,10 +573,10 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
576 573
577 /* If allocation request is small and there is not enough 574 /* If allocation request is small and there is not enough
578 * pages in pool we fill the pool first */ 575 * pages in pool we fill the pool first */
579 if (count < _manager.options.small 576 if (count < _manager->options.small
580 && count > pool->npages) { 577 && count > pool->npages) {
581 struct list_head new_pages; 578 struct list_head new_pages;
582 unsigned alloc_size = _manager.options.alloc_size; 579 unsigned alloc_size = _manager->options.alloc_size;
583 580
584 /** 581 /**
585 * Can't change page caching if in irqsave context. We have to 582 * Can't change page caching if in irqsave context. We have to
@@ -759,8 +756,8 @@ void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags,
759 pool->npages += page_count; 756 pool->npages += page_count;
760 /* Check that we don't go over the pool limit */ 757 /* Check that we don't go over the pool limit */
761 page_count = 0; 758 page_count = 0;
762 if (pool->npages > _manager.options.max_size) { 759 if (pool->npages > _manager->options.max_size) {
763 page_count = pool->npages - _manager.options.max_size; 760 page_count = pool->npages - _manager->options.max_size;
764 /* free at least NUM_PAGES_TO_ALLOC number of pages 761 /* free at least NUM_PAGES_TO_ALLOC number of pages
765 * to reduce calls to set_memory_wb */ 762 * to reduce calls to set_memory_wb */
766 if (page_count < NUM_PAGES_TO_ALLOC) 763 if (page_count < NUM_PAGES_TO_ALLOC)
@@ -785,33 +782,36 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags,
785int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) 782int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
786{ 783{
787 int ret; 784 int ret;
788 if (atomic_add_return(1, &_manager.page_alloc_inited) > 1) 785
789 return 0; 786 WARN_ON(_manager);
790 787
791 printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n"); 788 printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n");
792 789
793 ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER, "wc"); 790 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
794 791
795 ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER, "uc"); 792 ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc");
796 793
797 ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32, 794 ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc");
798 "wc dma");
799 795
800 ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32, 796 ttm_page_pool_init_locked(&_manager->wc_pool_dma32,
801 "uc dma"); 797 GFP_USER | GFP_DMA32, "wc dma");
802 798
803 _manager.options.max_size = max_pages; 799 ttm_page_pool_init_locked(&_manager->uc_pool_dma32,
804 _manager.options.small = SMALL_ALLOCATION; 800 GFP_USER | GFP_DMA32, "uc dma");
805 _manager.options.alloc_size = NUM_PAGES_TO_ALLOC;
806 801
807 kobject_init(&_manager.kobj, &ttm_pool_kobj_type); 802 _manager->options.max_size = max_pages;
808 ret = kobject_add(&_manager.kobj, &glob->kobj, "pool"); 803 _manager->options.small = SMALL_ALLOCATION;
804 _manager->options.alloc_size = NUM_PAGES_TO_ALLOC;
805
806 ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type,
807 &glob->kobj, "pool");
809 if (unlikely(ret != 0)) { 808 if (unlikely(ret != 0)) {
810 kobject_put(&_manager.kobj); 809 kobject_put(&_manager->kobj);
810 _manager = NULL;
811 return ret; 811 return ret;
812 } 812 }
813 813
814 ttm_pool_mm_shrink_init(&_manager); 814 ttm_pool_mm_shrink_init(_manager);
815 815
816 return 0; 816 return 0;
817} 817}
@@ -820,16 +820,14 @@ void ttm_page_alloc_fini()
820{ 820{
821 int i; 821 int i;
822 822
823 if (atomic_sub_return(1, &_manager.page_alloc_inited) > 0)
824 return;
825
826 printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n"); 823 printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n");
827 ttm_pool_mm_shrink_fini(&_manager); 824 ttm_pool_mm_shrink_fini(_manager);
828 825
829 for (i = 0; i < NUM_POOLS; ++i) 826 for (i = 0; i < NUM_POOLS; ++i)
830 ttm_page_pool_free(&_manager.pools[i], FREE_ALL_PAGES); 827 ttm_page_pool_free(&_manager->pools[i], FREE_ALL_PAGES);
831 828
832 kobject_put(&_manager.kobj); 829 kobject_put(&_manager->kobj);
830 _manager = NULL;
833} 831}
834 832
835int ttm_page_alloc_debugfs(struct seq_file *m, void *data) 833int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
@@ -837,14 +835,14 @@ int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
837 struct ttm_page_pool *p; 835 struct ttm_page_pool *p;
838 unsigned i; 836 unsigned i;
839 char *h[] = {"pool", "refills", "pages freed", "size"}; 837 char *h[] = {"pool", "refills", "pages freed", "size"};
840 if (atomic_read(&_manager.page_alloc_inited) == 0) { 838 if (!_manager) {
841 seq_printf(m, "No pool allocator running.\n"); 839 seq_printf(m, "No pool allocator running.\n");
842 return 0; 840 return 0;
843 } 841 }
844 seq_printf(m, "%6s %12s %13s %8s\n", 842 seq_printf(m, "%6s %12s %13s %8s\n",
845 h[0], h[1], h[2], h[3]); 843 h[0], h[1], h[2], h[3]);
846 for (i = 0; i < NUM_POOLS; ++i) { 844 for (i = 0; i < NUM_POOLS; ++i) {
847 p = &_manager.pools[i]; 845 p = &_manager->pools[i];
848 846
849 seq_printf(m, "%6s %12ld %13ld %8d\n", 847 seq_printf(m, "%6s %12ld %13ld %8d\n",
850 p->name, p->nrefills, 848 p->name, p->nrefills,
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 40fdc41446cc..df483076eda6 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -340,7 +340,8 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
340 340
341 if ((client_info->assigned) && 341 if ((client_info->assigned) &&
342 (client_info->ip_src == arp->ip_dst) && 342 (client_info->ip_src == arp->ip_dst) &&
343 (client_info->ip_dst == arp->ip_src)) { 343 (client_info->ip_dst == arp->ip_src) &&
344 (compare_ether_addr_64bits(client_info->mac_dst, arp->mac_src))) {
344 /* update the clients MAC address */ 345 /* update the clients MAC address */
345 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN); 346 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
346 client_info->ntt = 1; 347 client_info->ntt = 1;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5e12462a9d5e..c3d98dde2f86 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -168,7 +168,7 @@ static int arp_ip_count;
168static int bond_mode = BOND_MODE_ROUNDROBIN; 168static int bond_mode = BOND_MODE_ROUNDROBIN;
169static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; 169static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
170static int lacp_fast; 170static int lacp_fast;
171 171static int disable_netpoll = 1;
172 172
173const struct bond_parm_tbl bond_lacp_tbl[] = { 173const struct bond_parm_tbl bond_lacp_tbl[] = {
174{ "slow", AD_LACP_SLOW}, 174{ "slow", AD_LACP_SLOW},
@@ -1742,15 +1742,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1742 bond_set_carrier(bond); 1742 bond_set_carrier(bond);
1743 1743
1744#ifdef CONFIG_NET_POLL_CONTROLLER 1744#ifdef CONFIG_NET_POLL_CONTROLLER
1745 if (slaves_support_netpoll(bond_dev)) { 1745 /*
1746 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; 1746 * Netpoll and bonding is broken, make sure it is not initialized
1747 if (bond_dev->npinfo) 1747 * until it is fixed.
1748 slave_dev->npinfo = bond_dev->npinfo; 1748 */
1749 } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) { 1749 if (disable_netpoll) {
1750 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; 1750 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
1751 pr_info("New slave device %s does not support netpoll\n", 1751 } else {
1752 slave_dev->name); 1752 if (slaves_support_netpoll(bond_dev)) {
1753 pr_info("Disabling netpoll support for %s\n", bond_dev->name); 1753 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
1754 if (bond_dev->npinfo)
1755 slave_dev->npinfo = bond_dev->npinfo;
1756 } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
1757 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
1758 pr_info("New slave device %s does not support netpoll\n",
1759 slave_dev->name);
1760 pr_info("Disabling netpoll support for %s\n", bond_dev->name);
1761 }
1754 } 1762 }
1755#endif 1763#endif
1756 read_unlock(&bond->lock); 1764 read_unlock(&bond->lock);
@@ -1950,8 +1958,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1950 1958
1951#ifdef CONFIG_NET_POLL_CONTROLLER 1959#ifdef CONFIG_NET_POLL_CONTROLLER
1952 read_lock_bh(&bond->lock); 1960 read_lock_bh(&bond->lock);
1953 if (slaves_support_netpoll(bond_dev)) 1961
1954 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; 1962 /* Make sure netpoll over stays disabled until fixed. */
1963 if (!disable_netpoll)
1964 if (slaves_support_netpoll(bond_dev))
1965 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
1955 read_unlock_bh(&bond->lock); 1966 read_unlock_bh(&bond->lock);
1956 if (slave_dev->netdev_ops->ndo_netpoll_cleanup) 1967 if (slave_dev->netdev_ops->ndo_netpoll_cleanup)
1957 slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev); 1968 slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev);
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index ce30c62a97f7..7b5d9764f317 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -3684,10 +3684,6 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3684 /* signal that we are down to the interrupt handler */ 3684 /* signal that we are down to the interrupt handler */
3685 set_bit(__IXGBE_DOWN, &adapter->state); 3685 set_bit(__IXGBE_DOWN, &adapter->state);
3686 3686
3687 /* power down the optics */
3688 if (hw->phy.multispeed_fiber)
3689 hw->mac.ops.disable_tx_laser(hw);
3690
3691 /* disable receive for all VFs and wait one second */ 3687 /* disable receive for all VFs and wait one second */
3692 if (adapter->num_vfs) { 3688 if (adapter->num_vfs) {
3693 /* ping all the active vfs to let them know we are going down */ 3689 /* ping all the active vfs to let them know we are going down */
@@ -3742,6 +3738,10 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3742 (IXGBE_READ_REG(hw, IXGBE_DMATXCTL) & 3738 (IXGBE_READ_REG(hw, IXGBE_DMATXCTL) &
3743 ~IXGBE_DMATXCTL_TE)); 3739 ~IXGBE_DMATXCTL_TE));
3744 3740
3741 /* power down the optics */
3742 if (hw->phy.multispeed_fiber)
3743 hw->mac.ops.disable_tx_laser(hw);
3744
3745 /* clear n-tuple filters that are cached */ 3745 /* clear n-tuple filters that are cached */
3746 ethtool_ntuple_flush(netdev); 3746 ethtool_ntuple_flush(netdev);
3747 3747
@@ -4001,7 +4001,7 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
4001 4001
4002done: 4002done:
4003 /* Notify the stack of the (possibly) reduced Tx Queue count. */ 4003 /* Notify the stack of the (possibly) reduced Tx Queue count. */
4004 adapter->netdev->real_num_tx_queues = adapter->num_tx_queues; 4004 netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
4005} 4005}
4006 4006
4007static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, 4007static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
@@ -5195,7 +5195,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
5195 ixgbe_free_all_tx_resources(adapter); 5195 ixgbe_free_all_tx_resources(adapter);
5196 ixgbe_free_all_rx_resources(adapter); 5196 ixgbe_free_all_rx_resources(adapter);
5197 } 5197 }
5198 ixgbe_clear_interrupt_scheme(adapter);
5199 5198
5200#ifdef CONFIG_PM 5199#ifdef CONFIG_PM
5201 retval = pci_save_state(pdev); 5200 retval = pci_save_state(pdev);
@@ -5230,6 +5229,8 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
5230 5229
5231 *enable_wake = !!wufc; 5230 *enable_wake = !!wufc;
5232 5231
5232 ixgbe_clear_interrupt_scheme(adapter);
5233
5233 ixgbe_release_hw_control(adapter); 5234 ixgbe_release_hw_control(adapter);
5234 5235
5235 pci_disable_device(pdev); 5236 pci_disable_device(pdev);
@@ -6023,7 +6024,6 @@ static void ixgbe_tx_queue(struct ixgbe_adapter *adapter,
6023static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb, 6024static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb,
6024 int queue, u32 tx_flags) 6025 int queue, u32 tx_flags)
6025{ 6026{
6026 /* Right now, we support IPv4 only */
6027 struct ixgbe_atr_input atr_input; 6027 struct ixgbe_atr_input atr_input;
6028 struct tcphdr *th; 6028 struct tcphdr *th;
6029 struct iphdr *iph = ip_hdr(skb); 6029 struct iphdr *iph = ip_hdr(skb);
@@ -6032,6 +6032,9 @@ static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb,
6032 u32 src_ipv4_addr, dst_ipv4_addr; 6032 u32 src_ipv4_addr, dst_ipv4_addr;
6033 u8 l4type = 0; 6033 u8 l4type = 0;
6034 6034
6035 /* Right now, we support IPv4 only */
6036 if (skb->protocol != htons(ETH_P_IP))
6037 return;
6035 /* check if we're UDP or TCP */ 6038 /* check if we're UDP or TCP */
6036 if (iph->protocol == IPPROTO_TCP) { 6039 if (iph->protocol == IPPROTO_TCP) {
6037 th = tcp_hdr(skb); 6040 th = tcp_hdr(skb);
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index 52dcc8495647..6474c4973d3a 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -964,7 +964,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
964 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0); 964 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0);
965 if (!np) { 965 if (!np) {
966 dev_err(&op->dev, "could not find DMA node\n"); 966 dev_err(&op->dev, "could not find DMA node\n");
967 goto nodev; 967 goto err_iounmap;
968 } 968 }
969 969
970 /* Setup the DMA register accesses, could be DCR or memory mapped */ 970 /* Setup the DMA register accesses, could be DCR or memory mapped */
@@ -978,7 +978,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
978 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs); 978 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs);
979 } else { 979 } else {
980 dev_err(&op->dev, "unable to map DMA registers\n"); 980 dev_err(&op->dev, "unable to map DMA registers\n");
981 goto nodev; 981 goto err_iounmap;
982 } 982 }
983 } 983 }
984 984
@@ -987,7 +987,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
987 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) { 987 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) {
988 dev_err(&op->dev, "could not determine irqs\n"); 988 dev_err(&op->dev, "could not determine irqs\n");
989 rc = -ENOMEM; 989 rc = -ENOMEM;
990 goto nodev; 990 goto err_iounmap_2;
991 } 991 }
992 992
993 of_node_put(np); /* Finished with the DMA node; drop the reference */ 993 of_node_put(np); /* Finished with the DMA node; drop the reference */
@@ -997,7 +997,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
997 if ((!addr) || (size != 6)) { 997 if ((!addr) || (size != 6)) {
998 dev_err(&op->dev, "could not find MAC address\n"); 998 dev_err(&op->dev, "could not find MAC address\n");
999 rc = -ENODEV; 999 rc = -ENODEV;
1000 goto nodev; 1000 goto err_iounmap_2;
1001 } 1001 }
1002 temac_set_mac_address(ndev, (void *)addr); 1002 temac_set_mac_address(ndev, (void *)addr);
1003 1003
@@ -1013,7 +1013,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
1013 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group); 1013 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group);
1014 if (rc) { 1014 if (rc) {
1015 dev_err(lp->dev, "Error creating sysfs files\n"); 1015 dev_err(lp->dev, "Error creating sysfs files\n");
1016 goto nodev; 1016 goto err_iounmap_2;
1017 } 1017 }
1018 1018
1019 rc = register_netdev(lp->ndev); 1019 rc = register_netdev(lp->ndev);
@@ -1026,6 +1026,11 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
1026 1026
1027 err_register_ndev: 1027 err_register_ndev:
1028 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); 1028 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
1029 err_iounmap_2:
1030 if (lp->sdma_regs)
1031 iounmap(lp->sdma_regs);
1032 err_iounmap:
1033 iounmap(lp->regs);
1029 nodev: 1034 nodev:
1030 free_netdev(ndev); 1035 free_netdev(ndev);
1031 ndev = NULL; 1036 ndev = NULL;
@@ -1044,6 +1049,9 @@ static int __devexit temac_of_remove(struct of_device *op)
1044 of_node_put(lp->phy_node); 1049 of_node_put(lp->phy_node);
1045 lp->phy_node = NULL; 1050 lp->phy_node = NULL;
1046 dev_set_drvdata(&op->dev, NULL); 1051 dev_set_drvdata(&op->dev, NULL);
1052 iounmap(lp->regs);
1053 if (lp->sdma_regs)
1054 iounmap(lp->sdma_regs);
1047 free_netdev(ndev); 1055 free_netdev(ndev);
1048 return 0; 1056 return 0;
1049} 1057}
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index e345ec8cb473..73bb8ea6f54a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
289 unsigned int t_clk; 289 unsigned int t_clk;
290 int extended_rx_coal_limit; 290 int extended_rx_coal_limit;
291 int tx_bw_control; 291 int tx_bw_control;
292 int tx_csum_limit;
292}; 293};
293 294
294#define TX_BW_CONTROL_ABSENT 0 295#define TX_BW_CONTROL_ABSENT 0
@@ -776,13 +777,16 @@ static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
776 l4i_chk = 0; 777 l4i_chk = 0;
777 778
778 if (skb->ip_summed == CHECKSUM_PARTIAL) { 779 if (skb->ip_summed == CHECKSUM_PARTIAL) {
780 int hdr_len;
779 int tag_bytes; 781 int tag_bytes;
780 782
781 BUG_ON(skb->protocol != htons(ETH_P_IP) && 783 BUG_ON(skb->protocol != htons(ETH_P_IP) &&
782 skb->protocol != htons(ETH_P_8021Q)); 784 skb->protocol != htons(ETH_P_8021Q));
783 785
784 tag_bytes = (void *)ip_hdr(skb) - (void *)skb->data - ETH_HLEN; 786 hdr_len = (void *)ip_hdr(skb) - (void *)skb->data;
785 if (unlikely(tag_bytes & ~12)) { 787 tag_bytes = hdr_len - ETH_HLEN;
788 if (skb->len - hdr_len > mp->shared->tx_csum_limit ||
789 unlikely(tag_bytes & ~12)) {
786 if (skb_checksum_help(skb) == 0) 790 if (skb_checksum_help(skb) == 0)
787 goto no_csum; 791 goto no_csum;
788 kfree_skb(skb); 792 kfree_skb(skb);
@@ -2666,6 +2670,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2666 * Detect hardware parameters. 2670 * Detect hardware parameters.
2667 */ 2671 */
2668 msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000; 2672 msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
2673 msp->tx_csum_limit = pd->tx_csum_limit ? pd->tx_csum_limit : 9 * 1024;
2669 infer_hw_params(msp); 2674 infer_hw_params(msp);
2670 2675
2671 platform_set_drvdata(pdev, msp); 2676 platform_set_drvdata(pdev, msp);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index b8e2923a1d69..1063093b3afc 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -806,8 +806,10 @@ static int __init ne_drv_probe(struct platform_device *pdev)
806 dev->base_addr = res->start; 806 dev->base_addr = res->start;
807 dev->irq = platform_get_irq(pdev, 0); 807 dev->irq = platform_get_irq(pdev, 0);
808 } else { 808 } else {
809 if (this_dev < 0 || this_dev >= MAX_NE_CARDS) 809 if (this_dev < 0 || this_dev >= MAX_NE_CARDS) {
810 free_netdev(dev);
810 return -EINVAL; 811 return -EINVAL;
812 }
811 dev->base_addr = io[this_dev]; 813 dev->base_addr = io[this_dev];
812 dev->irq = irq[this_dev]; 814 dev->irq = irq[this_dev];
813 dev->mem_end = bad[this_dev]; 815 dev->mem_end = bad[this_dev];
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index fa4b24c49f42..d10bcefc0e45 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4611,8 +4611,7 @@ static void ql_timer(unsigned long data)
4611 return; 4611 return;
4612 } 4612 }
4613 4613
4614 qdev->timer.expires = jiffies + (5*HZ); 4614 mod_timer(&qdev->timer, jiffies + (5*HZ));
4615 add_timer(&qdev->timer);
4616} 4615}
4617 4616
4618static int __devinit qlge_probe(struct pci_dev *pdev, 4617static int __devinit qlge_probe(struct pci_dev *pdev,
@@ -4713,6 +4712,8 @@ static void ql_eeh_close(struct net_device *ndev)
4713 netif_stop_queue(ndev); 4712 netif_stop_queue(ndev);
4714 } 4713 }
4715 4714
4715 /* Disabling the timer */
4716 del_timer_sync(&qdev->timer);
4716 if (test_bit(QL_ADAPTER_UP, &qdev->flags)) 4717 if (test_bit(QL_ADAPTER_UP, &qdev->flags))
4717 cancel_delayed_work_sync(&qdev->asic_reset_work); 4718 cancel_delayed_work_sync(&qdev->asic_reset_work);
4718 cancel_delayed_work_sync(&qdev->mpi_reset_work); 4719 cancel_delayed_work_sync(&qdev->mpi_reset_work);
@@ -4808,8 +4809,7 @@ static void qlge_io_resume(struct pci_dev *pdev)
4808 netif_err(qdev, ifup, qdev->ndev, 4809 netif_err(qdev, ifup, qdev->ndev,
4809 "Device was not running prior to EEH.\n"); 4810 "Device was not running prior to EEH.\n");
4810 } 4811 }
4811 qdev->timer.expires = jiffies + (5*HZ); 4812 mod_timer(&qdev->timer, jiffies + (5*HZ));
4812 add_timer(&qdev->timer);
4813 netif_device_attach(ndev); 4813 netif_device_attach(ndev);
4814} 4814}
4815 4815
@@ -4871,8 +4871,7 @@ static int qlge_resume(struct pci_dev *pdev)
4871 return err; 4871 return err;
4872 } 4872 }
4873 4873
4874 qdev->timer.expires = jiffies + (5*HZ); 4874 mod_timer(&qdev->timer, jiffies + (5*HZ));
4875 add_timer(&qdev->timer);
4876 netif_device_attach(ndev); 4875 netif_device_attach(ndev);
4877 4876
4878 return 0; 4877 return 0;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 668327ccd8d0..1d37f0c310ca 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3130,7 +3130,6 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
3130 pkt_cnt++; 3130 pkt_cnt++;
3131 3131
3132 /* Updating the statistics block */ 3132 /* Updating the statistics block */
3133 nic->dev->stats.tx_bytes += skb->len;
3134 swstats->mem_freed += skb->truesize; 3133 swstats->mem_freed += skb->truesize;
3135 dev_kfree_skb_irq(skb); 3134 dev_kfree_skb_irq(skb);
3136 3135
@@ -4901,48 +4900,81 @@ static void s2io_updt_stats(struct s2io_nic *sp)
4901 * Return value: 4900 * Return value:
4902 * pointer to the updated net_device_stats structure. 4901 * pointer to the updated net_device_stats structure.
4903 */ 4902 */
4904
4905static struct net_device_stats *s2io_get_stats(struct net_device *dev) 4903static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4906{ 4904{
4907 struct s2io_nic *sp = netdev_priv(dev); 4905 struct s2io_nic *sp = netdev_priv(dev);
4908 struct config_param *config = &sp->config;
4909 struct mac_info *mac_control = &sp->mac_control; 4906 struct mac_info *mac_control = &sp->mac_control;
4910 struct stat_block *stats = mac_control->stats_info; 4907 struct stat_block *stats = mac_control->stats_info;
4911 int i; 4908 u64 delta;
4912 4909
4913 /* Configure Stats for immediate updt */ 4910 /* Configure Stats for immediate updt */
4914 s2io_updt_stats(sp); 4911 s2io_updt_stats(sp);
4915 4912
4916 /* Using sp->stats as a staging area, because reset (due to mtu 4913 /* A device reset will cause the on-adapter statistics to be zero'ed.
4917 change, for example) will clear some hardware counters */ 4914 * This can be done while running by changing the MTU. To prevent the
4918 dev->stats.tx_packets += le32_to_cpu(stats->tmac_frms) - 4915 * system from having the stats zero'ed, the driver keeps a copy of the
4919 sp->stats.tx_packets; 4916 * last update to the system (which is also zero'ed on reset). This
4920 sp->stats.tx_packets = le32_to_cpu(stats->tmac_frms); 4917 * enables the driver to accurately know the delta between the last
4921 4918 * update and the current update.
4922 dev->stats.tx_errors += le32_to_cpu(stats->tmac_any_err_frms) - 4919 */
4923 sp->stats.tx_errors; 4920 delta = ((u64) le32_to_cpu(stats->rmac_vld_frms_oflow) << 32 |
4924 sp->stats.tx_errors = le32_to_cpu(stats->tmac_any_err_frms); 4921 le32_to_cpu(stats->rmac_vld_frms)) - sp->stats.rx_packets;
4925 4922 sp->stats.rx_packets += delta;
4926 dev->stats.rx_errors += le64_to_cpu(stats->rmac_drop_frms) - 4923 dev->stats.rx_packets += delta;
4927 sp->stats.rx_errors; 4924
4928 sp->stats.rx_errors = le64_to_cpu(stats->rmac_drop_frms); 4925 delta = ((u64) le32_to_cpu(stats->tmac_frms_oflow) << 32 |
4929 4926 le32_to_cpu(stats->tmac_frms)) - sp->stats.tx_packets;
4930 dev->stats.multicast = le32_to_cpu(stats->rmac_vld_mcst_frms) - 4927 sp->stats.tx_packets += delta;
4931 sp->stats.multicast; 4928 dev->stats.tx_packets += delta;
4932 sp->stats.multicast = le32_to_cpu(stats->rmac_vld_mcst_frms); 4929
4933 4930 delta = ((u64) le32_to_cpu(stats->rmac_data_octets_oflow) << 32 |
4934 dev->stats.rx_length_errors = le64_to_cpu(stats->rmac_long_frms) - 4931 le32_to_cpu(stats->rmac_data_octets)) - sp->stats.rx_bytes;
4935 sp->stats.rx_length_errors; 4932 sp->stats.rx_bytes += delta;
4936 sp->stats.rx_length_errors = le64_to_cpu(stats->rmac_long_frms); 4933 dev->stats.rx_bytes += delta;
4934
4935 delta = ((u64) le32_to_cpu(stats->tmac_data_octets_oflow) << 32 |
4936 le32_to_cpu(stats->tmac_data_octets)) - sp->stats.tx_bytes;
4937 sp->stats.tx_bytes += delta;
4938 dev->stats.tx_bytes += delta;
4939
4940 delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_errors;
4941 sp->stats.rx_errors += delta;
4942 dev->stats.rx_errors += delta;
4943
4944 delta = ((u64) le32_to_cpu(stats->tmac_any_err_frms_oflow) << 32 |
4945 le32_to_cpu(stats->tmac_any_err_frms)) - sp->stats.tx_errors;
4946 sp->stats.tx_errors += delta;
4947 dev->stats.tx_errors += delta;
4948
4949 delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_dropped;
4950 sp->stats.rx_dropped += delta;
4951 dev->stats.rx_dropped += delta;
4952
4953 delta = le64_to_cpu(stats->tmac_drop_frms) - sp->stats.tx_dropped;
4954 sp->stats.tx_dropped += delta;
4955 dev->stats.tx_dropped += delta;
4956
4957 /* The adapter MAC interprets pause frames as multicast packets, but
4958 * does not pass them up. This erroneously increases the multicast
4959 * packet count and needs to be deducted when the multicast frame count
4960 * is queried.
4961 */
4962 delta = (u64) le32_to_cpu(stats->rmac_vld_mcst_frms_oflow) << 32 |
4963 le32_to_cpu(stats->rmac_vld_mcst_frms);
4964 delta -= le64_to_cpu(stats->rmac_pause_ctrl_frms);
4965 delta -= sp->stats.multicast;
4966 sp->stats.multicast += delta;
4967 dev->stats.multicast += delta;
4937 4968
4938 /* collect per-ring rx_packets and rx_bytes */ 4969 delta = ((u64) le32_to_cpu(stats->rmac_usized_frms_oflow) << 32 |
4939 dev->stats.rx_packets = dev->stats.rx_bytes = 0; 4970 le32_to_cpu(stats->rmac_usized_frms)) +
4940 for (i = 0; i < config->rx_ring_num; i++) { 4971 le64_to_cpu(stats->rmac_long_frms) - sp->stats.rx_length_errors;
4941 struct ring_info *ring = &mac_control->rings[i]; 4972 sp->stats.rx_length_errors += delta;
4973 dev->stats.rx_length_errors += delta;
4942 4974
4943 dev->stats.rx_packets += ring->rx_packets; 4975 delta = le64_to_cpu(stats->rmac_fcs_err_frms) - sp->stats.rx_crc_errors;
4944 dev->stats.rx_bytes += ring->rx_bytes; 4976 sp->stats.rx_crc_errors += delta;
4945 } 4977 dev->stats.rx_crc_errors += delta;
4946 4978
4947 return &dev->stats; 4979 return &dev->stats;
4948} 4980}
@@ -7455,15 +7487,11 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7455 } 7487 }
7456 } 7488 }
7457 7489
7458 /* Updating statistics */
7459 ring_data->rx_packets++;
7460 rxdp->Host_Control = 0; 7490 rxdp->Host_Control = 0;
7461 if (sp->rxd_mode == RXD_MODE_1) { 7491 if (sp->rxd_mode == RXD_MODE_1) {
7462 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 7492 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
7463 7493
7464 ring_data->rx_bytes += len;
7465 skb_put(skb, len); 7494 skb_put(skb, len);
7466
7467 } else if (sp->rxd_mode == RXD_MODE_3B) { 7495 } else if (sp->rxd_mode == RXD_MODE_3B) {
7468 int get_block = ring_data->rx_curr_get_info.block_index; 7496 int get_block = ring_data->rx_curr_get_info.block_index;
7469 int get_off = ring_data->rx_curr_get_info.offset; 7497 int get_off = ring_data->rx_curr_get_info.offset;
@@ -7472,7 +7500,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7472 unsigned char *buff = skb_push(skb, buf0_len); 7500 unsigned char *buff = skb_push(skb, buf0_len);
7473 7501
7474 struct buffAdd *ba = &ring_data->ba[get_block][get_off]; 7502 struct buffAdd *ba = &ring_data->ba[get_block][get_off];
7475 ring_data->rx_bytes += buf0_len + buf2_len;
7476 memcpy(buff, ba->ba_0, buf0_len); 7503 memcpy(buff, ba->ba_0, buf0_len);
7477 skb_put(skb, buf2_len); 7504 skb_put(skb, buf2_len);
7478 } 7505 }
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 47c36e0994f5..5e52c75892df 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -745,10 +745,6 @@ struct ring_info {
745 745
746 /* Buffer Address store. */ 746 /* Buffer Address store. */
747 struct buffAdd **ba; 747 struct buffAdd **ba;
748
749 /* per-Ring statistics */
750 unsigned long rx_packets;
751 unsigned long rx_bytes;
752} ____cacheline_aligned; 748} ____cacheline_aligned;
753 749
754/* Fifo specific structure */ 750/* Fifo specific structure */
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 1f3acc3a5dfd..79eee3062083 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2671,6 +2671,7 @@ static struct platform_driver sbmac_driver = {
2671 .remove = __exit_p(sbmac_remove), 2671 .remove = __exit_p(sbmac_remove),
2672 .driver = { 2672 .driver = {
2673 .name = sbmac_string, 2673 .name = sbmac_string,
2674 .owner = THIS_MODULE,
2674 }, 2675 },
2675}; 2676};
2676 2677
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 28d3ee175e7b..dd8a4adf48ca 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -104,10 +104,8 @@ static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
104int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen) 104int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
105{ 105{
106 struct cdc_state *info = (void *) &dev->data; 106 struct cdc_state *info = (void *) &dev->data;
107 struct usb_cdc_notification notification;
108 int master_ifnum; 107 int master_ifnum;
109 int retval; 108 int retval;
110 int partial;
111 unsigned count; 109 unsigned count;
112 __le32 rsp; 110 __le32 rsp;
113 u32 xid = 0, msg_len, request_id; 111 u32 xid = 0, msg_len, request_id;
@@ -135,17 +133,13 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
135 if (unlikely(retval < 0 || xid == 0)) 133 if (unlikely(retval < 0 || xid == 0))
136 return retval; 134 return retval;
137 135
138 /* Some devices don't respond on the control channel until 136 // FIXME Seems like some devices discard responses when
139 * polled on the status channel, so do that first. */ 137 // we time out and cancel our "get response" requests...
140 retval = usb_interrupt_msg( 138 // so, this is fragile. Probably need to poll for status.
141 dev->udev,
142 usb_rcvintpipe(dev->udev, dev->status->desc.bEndpointAddress),
143 &notification, sizeof(notification), &partial,
144 RNDIS_CONTROL_TIMEOUT_MS);
145 if (unlikely(retval < 0))
146 return retval;
147 139
148 /* Poll the control channel; the request probably completed immediately */ 140 /* ignore status endpoint, just poll the control channel;
141 * the request probably completed immediately
142 */
149 rsp = buf->msg_type | RNDIS_MSG_COMPLETION; 143 rsp = buf->msg_type | RNDIS_MSG_COMPLETION;
150 for (count = 0; count < 10; count++) { 144 for (count = 0; count < 10; count++) {
151 memset(buf, 0, CONTROL_BUFFER_SIZE); 145 memset(buf, 0, CONTROL_BUFFER_SIZE);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index a95c73de5824..81c76ada8e56 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1293,6 +1293,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1293 goto out; 1293 goto out;
1294 } 1294 }
1295 1295
1296 /* netdev_printk() needs this so do it as early as possible */
1297 SET_NETDEV_DEV(net, &udev->dev);
1298
1296 dev = netdev_priv(net); 1299 dev = netdev_priv(net);
1297 dev->udev = xdev; 1300 dev->udev = xdev;
1298 dev->intf = udev; 1301 dev->intf = udev;
@@ -1377,8 +1380,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1377 dev->rx_urb_size = dev->hard_mtu; 1380 dev->rx_urb_size = dev->hard_mtu;
1378 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); 1381 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1379 1382
1380 SET_NETDEV_DEV(net, &udev->dev);
1381
1382 if ((dev->driver_info->flags & FLAG_WLAN) != 0) 1383 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1383 SET_NETDEV_DEVTYPE(net, &wlan_type); 1384 SET_NETDEV_DEVTYPE(net, &wlan_type);
1384 if ((dev->driver_info->flags & FLAG_WWAN) != 0) 1385 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1edb7a61983c..bb6b67f6b0cc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -415,7 +415,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp)
415static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) 415static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
416{ 416{
417 int err; 417 int err;
418 bool oom = false; 418 bool oom;
419 419
420 do { 420 do {
421 if (vi->mergeable_rx_bufs) 421 if (vi->mergeable_rx_bufs)
@@ -425,10 +425,9 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
425 else 425 else
426 err = add_recvbuf_small(vi, gfp); 426 err = add_recvbuf_small(vi, gfp);
427 427
428 if (err < 0) { 428 oom = err == -ENOMEM;
429 oom = true; 429 if (err < 0)
430 break; 430 break;
431 }
432 ++vi->num; 431 ++vi->num;
433 } while (err > 0); 432 } while (err > 0);
434 if (unlikely(vi->num > vi->max)) 433 if (unlikely(vi->num > vi->max))
@@ -563,7 +562,6 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
563 struct virtnet_info *vi = netdev_priv(dev); 562 struct virtnet_info *vi = netdev_priv(dev);
564 int capacity; 563 int capacity;
565 564
566again:
567 /* Free up any pending old buffers before queueing new ones. */ 565 /* Free up any pending old buffers before queueing new ones. */
568 free_old_xmit_skbs(vi); 566 free_old_xmit_skbs(vi);
569 567
@@ -572,14 +570,20 @@ again:
572 570
573 /* This can happen with OOM and indirect buffers. */ 571 /* This can happen with OOM and indirect buffers. */
574 if (unlikely(capacity < 0)) { 572 if (unlikely(capacity < 0)) {
575 netif_stop_queue(dev); 573 if (net_ratelimit()) {
576 dev_warn(&dev->dev, "Unexpected full queue\n"); 574 if (likely(capacity == -ENOMEM)) {
577 if (unlikely(!virtqueue_enable_cb(vi->svq))) { 575 dev_warn(&dev->dev,
578 virtqueue_disable_cb(vi->svq); 576 "TX queue failure: out of memory\n");
579 netif_start_queue(dev); 577 } else {
580 goto again; 578 dev->stats.tx_fifo_errors++;
579 dev_warn(&dev->dev,
580 "Unexpected TX queue failure: %d\n",
581 capacity);
582 }
581 } 583 }
582 return NETDEV_TX_BUSY; 584 dev->stats.tx_dropped++;
585 kfree_skb(skb);
586 return NETDEV_TX_OK;
583 } 587 }
584 virtqueue_kick(vi->svq); 588 virtqueue_kick(vi->svq);
585 589
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index d14e207de1df..fc8b2d7a0919 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -4517,9 +4517,9 @@ vxge_starter(void)
4517 char version[32]; 4517 char version[32];
4518 snprintf(version, 32, "%s", DRV_VERSION); 4518 snprintf(version, 32, "%s", DRV_VERSION);
4519 4519
4520 printk(KERN_CRIT "%s: Copyright(c) 2002-2009 Neterion Inc\n", 4520 printk(KERN_INFO "%s: Copyright(c) 2002-2009 Neterion Inc\n",
4521 VXGE_DRIVER_NAME); 4521 VXGE_DRIVER_NAME);
4522 printk(KERN_CRIT "%s: Driver version: %s\n", 4522 printk(KERN_INFO "%s: Driver version: %s\n",
4523 VXGE_DRIVER_NAME, version); 4523 VXGE_DRIVER_NAME, version);
4524 4524
4525 verify_bandwidth(); 4525 verify_bandwidth();
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index fbb7dec6ddeb..5ea87736a6ae 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -445,6 +445,7 @@ void ath_deinit_leds(struct ath_softc *sc);
445#define SC_OP_TSF_RESET BIT(11) 445#define SC_OP_TSF_RESET BIT(11)
446#define SC_OP_BT_PRIORITY_DETECTED BIT(12) 446#define SC_OP_BT_PRIORITY_DETECTED BIT(12)
447#define SC_OP_BT_SCAN BIT(13) 447#define SC_OP_BT_SCAN BIT(13)
448#define SC_OP_ANI_RUN BIT(14)
448 449
449/* Powersave flags */ 450/* Powersave flags */
450#define PS_WAIT_FOR_BEACON BIT(0) 451#define PS_WAIT_FOR_BEACON BIT(0)
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index abfa0493236f..1e2a68ea9355 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -336,6 +336,10 @@ set_timer:
336static void ath_start_ani(struct ath_common *common) 336static void ath_start_ani(struct ath_common *common)
337{ 337{
338 unsigned long timestamp = jiffies_to_msecs(jiffies); 338 unsigned long timestamp = jiffies_to_msecs(jiffies);
339 struct ath_softc *sc = (struct ath_softc *) common->priv;
340
341 if (!(sc->sc_flags & SC_OP_ANI_RUN))
342 return;
339 343
340 common->ani.longcal_timer = timestamp; 344 common->ani.longcal_timer = timestamp;
341 common->ani.shortcal_timer = timestamp; 345 common->ani.shortcal_timer = timestamp;
@@ -872,11 +876,13 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
872 /* Reset rssi stats */ 876 /* Reset rssi stats */
873 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 877 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
874 878
879 sc->sc_flags |= SC_OP_ANI_RUN;
875 ath_start_ani(common); 880 ath_start_ani(common);
876 } else { 881 } else {
877 ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n"); 882 ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
878 common->curaid = 0; 883 common->curaid = 0;
879 /* Stop ANI */ 884 /* Stop ANI */
885 sc->sc_flags &= ~SC_OP_ANI_RUN;
880 del_timer_sync(&common->ani.timer); 886 del_timer_sync(&common->ani.timer);
881 } 887 }
882} 888}
@@ -1478,8 +1484,10 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1478 1484
1479 if (vif->type == NL80211_IFTYPE_AP || 1485 if (vif->type == NL80211_IFTYPE_AP ||
1480 vif->type == NL80211_IFTYPE_ADHOC || 1486 vif->type == NL80211_IFTYPE_ADHOC ||
1481 vif->type == NL80211_IFTYPE_MONITOR) 1487 vif->type == NL80211_IFTYPE_MONITOR) {
1488 sc->sc_flags |= SC_OP_ANI_RUN;
1482 ath_start_ani(common); 1489 ath_start_ani(common);
1490 }
1483 1491
1484out: 1492out:
1485 mutex_unlock(&sc->mutex); 1493 mutex_unlock(&sc->mutex);
@@ -1500,6 +1508,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1500 mutex_lock(&sc->mutex); 1508 mutex_lock(&sc->mutex);
1501 1509
1502 /* Stop ANI */ 1510 /* Stop ANI */
1511 sc->sc_flags &= ~SC_OP_ANI_RUN;
1503 del_timer_sync(&common->ani.timer); 1512 del_timer_sync(&common->ani.timer);
1504 1513
1505 /* Reclaim beacon resources */ 1514 /* Reclaim beacon resources */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 44ef5d93befc..01658cf82d39 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -212,11 +212,7 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
212static void iwlagn_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 212static void iwlagn_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
213 __le32 *tx_flags) 213 __le32 *tx_flags)
214{ 214{
215 if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || 215 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
216 (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
217 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
218 else
219 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
220} 216}
221 217
222/* Calc max signal level (dBm) among 3 possible receivers */ 218/* Calc max signal level (dBm) among 3 possible receivers */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 426e95567de3..5bbc5298ef96 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1314,7 +1314,6 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
1314 changed_flags, *total_flags); 1314 changed_flags, *total_flags);
1315 1315
1316 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); 1316 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK);
1317 CHK(FIF_ALLMULTI, RXON_FILTER_ACCEPT_GRP_MSK);
1318 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); 1317 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK);
1319 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); 1318 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK);
1320 1319
@@ -1329,6 +1328,12 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
1329 1328
1330 mutex_unlock(&priv->mutex); 1329 mutex_unlock(&priv->mutex);
1331 1330
1331 /*
1332 * Receiving all multicast frames is always enabled by the
1333 * default flags setup in iwl_connection_init_rx_config()
1334 * since we currently do not support programming multicast
1335 * filters into the device.
1336 */
1332 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | 1337 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1333 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 1338 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
1334} 1339}
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 9fc339845538..eac961463be2 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1356,6 +1356,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1356 INIT_LIST_HEAD(&socket->devices_list); 1356 INIT_LIST_HEAD(&socket->devices_list);
1357 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1357 memset(&socket->pcmcia_state, 0, sizeof(u8));
1358 socket->device_count = 0; 1358 socket->device_count = 0;
1359 atomic_set(&socket->present, 0);
1359 1360
1360 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); 1361 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback);
1361 if (ret) { 1362 if (ret) {
@@ -1364,8 +1365,6 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1364 return ret; 1365 return ret;
1365 } 1366 }
1366 1367
1367 atomic_set(&socket->present, 0);
1368
1369 return 0; 1368 return 0;
1370} 1369}
1371 1370
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index df5b6b971f26..57a593c58cf4 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -98,7 +98,8 @@ static void tx_poll_start(struct vhost_net *net, struct socket *sock)
98static void handle_tx(struct vhost_net *net) 98static void handle_tx(struct vhost_net *net)
99{ 99{
100 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_TX]; 100 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_TX];
101 unsigned head, out, in, s; 101 unsigned out, in, s;
102 int head;
102 struct msghdr msg = { 103 struct msghdr msg = {
103 .msg_name = NULL, 104 .msg_name = NULL,
104 .msg_namelen = 0, 105 .msg_namelen = 0,
@@ -135,6 +136,9 @@ static void handle_tx(struct vhost_net *net)
135 ARRAY_SIZE(vq->iov), 136 ARRAY_SIZE(vq->iov),
136 &out, &in, 137 &out, &in,
137 NULL, NULL); 138 NULL, NULL);
139 /* On error, stop handling until the next kick. */
140 if (unlikely(head < 0))
141 break;
138 /* Nothing new? Wait for eventfd to tell us they refilled. */ 142 /* Nothing new? Wait for eventfd to tell us they refilled. */
139 if (head == vq->num) { 143 if (head == vq->num) {
140 wmem = atomic_read(&sock->sk->sk_wmem_alloc); 144 wmem = atomic_read(&sock->sk->sk_wmem_alloc);
@@ -192,7 +196,8 @@ static void handle_tx(struct vhost_net *net)
192static void handle_rx(struct vhost_net *net) 196static void handle_rx(struct vhost_net *net)
193{ 197{
194 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX]; 198 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX];
195 unsigned head, out, in, log, s; 199 unsigned out, in, log, s;
200 int head;
196 struct vhost_log *vq_log; 201 struct vhost_log *vq_log;
197 struct msghdr msg = { 202 struct msghdr msg = {
198 .msg_name = NULL, 203 .msg_name = NULL,
@@ -228,6 +233,9 @@ static void handle_rx(struct vhost_net *net)
228 ARRAY_SIZE(vq->iov), 233 ARRAY_SIZE(vq->iov),
229 &out, &in, 234 &out, &in,
230 vq_log, &log); 235 vq_log, &log);
236 /* On error, stop handling until the next kick. */
237 if (unlikely(head < 0))
238 break;
231 /* OK, now we need to know about added descriptors. */ 239 /* OK, now we need to know about added descriptors. */
232 if (head == vq->num) { 240 if (head == vq->num) {
233 if (unlikely(vhost_enable_notify(vq))) { 241 if (unlikely(vhost_enable_notify(vq))) {
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 3b83382e06eb..0b99783083f6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -736,12 +736,12 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len,
736 mem = rcu_dereference(dev->memory); 736 mem = rcu_dereference(dev->memory);
737 while ((u64)len > s) { 737 while ((u64)len > s) {
738 u64 size; 738 u64 size;
739 if (ret >= iov_size) { 739 if (unlikely(ret >= iov_size)) {
740 ret = -ENOBUFS; 740 ret = -ENOBUFS;
741 break; 741 break;
742 } 742 }
743 reg = find_region(mem, addr, len); 743 reg = find_region(mem, addr, len);
744 if (!reg) { 744 if (unlikely(!reg)) {
745 ret = -EFAULT; 745 ret = -EFAULT;
746 break; 746 break;
747 } 747 }
@@ -780,18 +780,18 @@ static unsigned next_desc(struct vring_desc *desc)
780 return next; 780 return next;
781} 781}
782 782
783static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq, 783static int get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
784 struct iovec iov[], unsigned int iov_size, 784 struct iovec iov[], unsigned int iov_size,
785 unsigned int *out_num, unsigned int *in_num, 785 unsigned int *out_num, unsigned int *in_num,
786 struct vhost_log *log, unsigned int *log_num, 786 struct vhost_log *log, unsigned int *log_num,
787 struct vring_desc *indirect) 787 struct vring_desc *indirect)
788{ 788{
789 struct vring_desc desc; 789 struct vring_desc desc;
790 unsigned int i = 0, count, found = 0; 790 unsigned int i = 0, count, found = 0;
791 int ret; 791 int ret;
792 792
793 /* Sanity check */ 793 /* Sanity check */
794 if (indirect->len % sizeof desc) { 794 if (unlikely(indirect->len % sizeof desc)) {
795 vq_err(vq, "Invalid length in indirect descriptor: " 795 vq_err(vq, "Invalid length in indirect descriptor: "
796 "len 0x%llx not multiple of 0x%zx\n", 796 "len 0x%llx not multiple of 0x%zx\n",
797 (unsigned long long)indirect->len, 797 (unsigned long long)indirect->len,
@@ -801,7 +801,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
801 801
802 ret = translate_desc(dev, indirect->addr, indirect->len, vq->indirect, 802 ret = translate_desc(dev, indirect->addr, indirect->len, vq->indirect,
803 ARRAY_SIZE(vq->indirect)); 803 ARRAY_SIZE(vq->indirect));
804 if (ret < 0) { 804 if (unlikely(ret < 0)) {
805 vq_err(vq, "Translation failure %d in indirect.\n", ret); 805 vq_err(vq, "Translation failure %d in indirect.\n", ret);
806 return ret; 806 return ret;
807 } 807 }
@@ -813,7 +813,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
813 count = indirect->len / sizeof desc; 813 count = indirect->len / sizeof desc;
814 /* Buffers are chained via a 16 bit next field, so 814 /* Buffers are chained via a 16 bit next field, so
815 * we can have at most 2^16 of these. */ 815 * we can have at most 2^16 of these. */
816 if (count > USHRT_MAX + 1) { 816 if (unlikely(count > USHRT_MAX + 1)) {
817 vq_err(vq, "Indirect buffer length too big: %d\n", 817 vq_err(vq, "Indirect buffer length too big: %d\n",
818 indirect->len); 818 indirect->len);
819 return -E2BIG; 819 return -E2BIG;
@@ -821,19 +821,19 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
821 821
822 do { 822 do {
823 unsigned iov_count = *in_num + *out_num; 823 unsigned iov_count = *in_num + *out_num;
824 if (++found > count) { 824 if (unlikely(++found > count)) {
825 vq_err(vq, "Loop detected: last one at %u " 825 vq_err(vq, "Loop detected: last one at %u "
826 "indirect size %u\n", 826 "indirect size %u\n",
827 i, count); 827 i, count);
828 return -EINVAL; 828 return -EINVAL;
829 } 829 }
830 if (memcpy_fromiovec((unsigned char *)&desc, vq->indirect, 830 if (unlikely(memcpy_fromiovec((unsigned char *)&desc, vq->indirect,
831 sizeof desc)) { 831 sizeof desc))) {
832 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n", 832 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n",
833 i, (size_t)indirect->addr + i * sizeof desc); 833 i, (size_t)indirect->addr + i * sizeof desc);
834 return -EINVAL; 834 return -EINVAL;
835 } 835 }
836 if (desc.flags & VRING_DESC_F_INDIRECT) { 836 if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) {
837 vq_err(vq, "Nested indirect descriptor: idx %d, %zx\n", 837 vq_err(vq, "Nested indirect descriptor: idx %d, %zx\n",
838 i, (size_t)indirect->addr + i * sizeof desc); 838 i, (size_t)indirect->addr + i * sizeof desc);
839 return -EINVAL; 839 return -EINVAL;
@@ -841,7 +841,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
841 841
842 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count, 842 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count,
843 iov_size - iov_count); 843 iov_size - iov_count);
844 if (ret < 0) { 844 if (unlikely(ret < 0)) {
845 vq_err(vq, "Translation failure %d indirect idx %d\n", 845 vq_err(vq, "Translation failure %d indirect idx %d\n",
846 ret, i); 846 ret, i);
847 return ret; 847 return ret;
@@ -857,7 +857,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
857 } else { 857 } else {
858 /* If it's an output descriptor, they're all supposed 858 /* If it's an output descriptor, they're all supposed
859 * to come before any input descriptors. */ 859 * to come before any input descriptors. */
860 if (*in_num) { 860 if (unlikely(*in_num)) {
861 vq_err(vq, "Indirect descriptor " 861 vq_err(vq, "Indirect descriptor "
862 "has out after in: idx %d\n", i); 862 "has out after in: idx %d\n", i);
863 return -EINVAL; 863 return -EINVAL;
@@ -873,12 +873,13 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
873 * number of output then some number of input descriptors, it's actually two 873 * number of output then some number of input descriptors, it's actually two
874 * iovecs, but we pack them into one and note how many of each there were. 874 * iovecs, but we pack them into one and note how many of each there were.
875 * 875 *
876 * This function returns the descriptor number found, or vq->num (which 876 * This function returns the descriptor number found, or vq->num (which is
877 * is never a valid descriptor number) if none was found. */ 877 * never a valid descriptor number) if none was found. A negative code is
878unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq, 878 * returned on error. */
879 struct iovec iov[], unsigned int iov_size, 879int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
880 unsigned int *out_num, unsigned int *in_num, 880 struct iovec iov[], unsigned int iov_size,
881 struct vhost_log *log, unsigned int *log_num) 881 unsigned int *out_num, unsigned int *in_num,
882 struct vhost_log *log, unsigned int *log_num)
882{ 883{
883 struct vring_desc desc; 884 struct vring_desc desc;
884 unsigned int i, head, found = 0; 885 unsigned int i, head, found = 0;
@@ -887,16 +888,16 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
887 888
888 /* Check it isn't doing very strange things with descriptor numbers. */ 889 /* Check it isn't doing very strange things with descriptor numbers. */
889 last_avail_idx = vq->last_avail_idx; 890 last_avail_idx = vq->last_avail_idx;
890 if (get_user(vq->avail_idx, &vq->avail->idx)) { 891 if (unlikely(get_user(vq->avail_idx, &vq->avail->idx))) {
891 vq_err(vq, "Failed to access avail idx at %p\n", 892 vq_err(vq, "Failed to access avail idx at %p\n",
892 &vq->avail->idx); 893 &vq->avail->idx);
893 return vq->num; 894 return -EFAULT;
894 } 895 }
895 896
896 if ((u16)(vq->avail_idx - last_avail_idx) > vq->num) { 897 if (unlikely((u16)(vq->avail_idx - last_avail_idx) > vq->num)) {
897 vq_err(vq, "Guest moved used index from %u to %u", 898 vq_err(vq, "Guest moved used index from %u to %u",
898 last_avail_idx, vq->avail_idx); 899 last_avail_idx, vq->avail_idx);
899 return vq->num; 900 return -EFAULT;
900 } 901 }
901 902
902 /* If there's nothing new since last we looked, return invalid. */ 903 /* If there's nothing new since last we looked, return invalid. */
@@ -908,18 +909,19 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
908 909
909 /* Grab the next descriptor number they're advertising, and increment 910 /* Grab the next descriptor number they're advertising, and increment
910 * the index we've seen. */ 911 * the index we've seen. */
911 if (get_user(head, &vq->avail->ring[last_avail_idx % vq->num])) { 912 if (unlikely(get_user(head,
913 &vq->avail->ring[last_avail_idx % vq->num]))) {
912 vq_err(vq, "Failed to read head: idx %d address %p\n", 914 vq_err(vq, "Failed to read head: idx %d address %p\n",
913 last_avail_idx, 915 last_avail_idx,
914 &vq->avail->ring[last_avail_idx % vq->num]); 916 &vq->avail->ring[last_avail_idx % vq->num]);
915 return vq->num; 917 return -EFAULT;
916 } 918 }
917 919
918 /* If their number is silly, that's an error. */ 920 /* If their number is silly, that's an error. */
919 if (head >= vq->num) { 921 if (unlikely(head >= vq->num)) {
920 vq_err(vq, "Guest says index %u > %u is available", 922 vq_err(vq, "Guest says index %u > %u is available",
921 head, vq->num); 923 head, vq->num);
922 return vq->num; 924 return -EINVAL;
923 } 925 }
924 926
925 /* When we start there are none of either input nor output. */ 927 /* When we start there are none of either input nor output. */
@@ -930,41 +932,41 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
930 i = head; 932 i = head;
931 do { 933 do {
932 unsigned iov_count = *in_num + *out_num; 934 unsigned iov_count = *in_num + *out_num;
933 if (i >= vq->num) { 935 if (unlikely(i >= vq->num)) {
934 vq_err(vq, "Desc index is %u > %u, head = %u", 936 vq_err(vq, "Desc index is %u > %u, head = %u",
935 i, vq->num, head); 937 i, vq->num, head);
936 return vq->num; 938 return -EINVAL;
937 } 939 }
938 if (++found > vq->num) { 940 if (unlikely(++found > vq->num)) {
939 vq_err(vq, "Loop detected: last one at %u " 941 vq_err(vq, "Loop detected: last one at %u "
940 "vq size %u head %u\n", 942 "vq size %u head %u\n",
941 i, vq->num, head); 943 i, vq->num, head);
942 return vq->num; 944 return -EINVAL;
943 } 945 }
944 ret = copy_from_user(&desc, vq->desc + i, sizeof desc); 946 ret = copy_from_user(&desc, vq->desc + i, sizeof desc);
945 if (ret) { 947 if (unlikely(ret)) {
946 vq_err(vq, "Failed to get descriptor: idx %d addr %p\n", 948 vq_err(vq, "Failed to get descriptor: idx %d addr %p\n",
947 i, vq->desc + i); 949 i, vq->desc + i);
948 return vq->num; 950 return -EFAULT;
949 } 951 }
950 if (desc.flags & VRING_DESC_F_INDIRECT) { 952 if (desc.flags & VRING_DESC_F_INDIRECT) {
951 ret = get_indirect(dev, vq, iov, iov_size, 953 ret = get_indirect(dev, vq, iov, iov_size,
952 out_num, in_num, 954 out_num, in_num,
953 log, log_num, &desc); 955 log, log_num, &desc);
954 if (ret < 0) { 956 if (unlikely(ret < 0)) {
955 vq_err(vq, "Failure detected " 957 vq_err(vq, "Failure detected "
956 "in indirect descriptor at idx %d\n", i); 958 "in indirect descriptor at idx %d\n", i);
957 return vq->num; 959 return ret;
958 } 960 }
959 continue; 961 continue;
960 } 962 }
961 963
962 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count, 964 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count,
963 iov_size - iov_count); 965 iov_size - iov_count);
964 if (ret < 0) { 966 if (unlikely(ret < 0)) {
965 vq_err(vq, "Translation failure %d descriptor idx %d\n", 967 vq_err(vq, "Translation failure %d descriptor idx %d\n",
966 ret, i); 968 ret, i);
967 return vq->num; 969 return ret;
968 } 970 }
969 if (desc.flags & VRING_DESC_F_WRITE) { 971 if (desc.flags & VRING_DESC_F_WRITE) {
970 /* If this is an input descriptor, 972 /* If this is an input descriptor,
@@ -978,10 +980,10 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
978 } else { 980 } else {
979 /* If it's an output descriptor, they're all supposed 981 /* If it's an output descriptor, they're all supposed
980 * to come before any input descriptors. */ 982 * to come before any input descriptors. */
981 if (*in_num) { 983 if (unlikely(*in_num)) {
982 vq_err(vq, "Descriptor has out after in: " 984 vq_err(vq, "Descriptor has out after in: "
983 "idx %d\n", i); 985 "idx %d\n", i);
984 return vq->num; 986 return -EINVAL;
985 } 987 }
986 *out_num += ret; 988 *out_num += ret;
987 } 989 }
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 44591ba9b07a..11ee13dba0f7 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -120,10 +120,10 @@ long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg);
120int vhost_vq_access_ok(struct vhost_virtqueue *vq); 120int vhost_vq_access_ok(struct vhost_virtqueue *vq);
121int vhost_log_access_ok(struct vhost_dev *); 121int vhost_log_access_ok(struct vhost_dev *);
122 122
123unsigned vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *, 123int vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *,
124 struct iovec iov[], unsigned int iov_count, 124 struct iovec iov[], unsigned int iov_count,
125 unsigned int *out_num, unsigned int *in_num, 125 unsigned int *out_num, unsigned int *in_num,
126 struct vhost_log *log, unsigned int *log_num); 126 struct vhost_log *log, unsigned int *log_num);
127void vhost_discard_vq_desc(struct vhost_virtqueue *); 127void vhost_discard_vq_desc(struct vhost_virtqueue *);
128 128
129int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len); 129int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len);
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 3dab9e9948d0..722743b152d8 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -680,7 +680,6 @@ int afs_writeback_all(struct afs_vnode *vnode)
680{ 680{
681 struct address_space *mapping = vnode->vfs_inode.i_mapping; 681 struct address_space *mapping = vnode->vfs_inode.i_mapping;
682 struct writeback_control wbc = { 682 struct writeback_control wbc = {
683 .bdi = mapping->backing_dev_info,
684 .sync_mode = WB_SYNC_ALL, 683 .sync_mode = WB_SYNC_ALL,
685 .nr_to_write = LONG_MAX, 684 .nr_to_write = LONG_MAX,
686 .range_cyclic = 1, 685 .range_cyclic = 1,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a4080c21ec55..d74e6af9b53a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2594,7 +2594,6 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
2594 .sync_io = wbc->sync_mode == WB_SYNC_ALL, 2594 .sync_io = wbc->sync_mode == WB_SYNC_ALL,
2595 }; 2595 };
2596 struct writeback_control wbc_writepages = { 2596 struct writeback_control wbc_writepages = {
2597 .bdi = wbc->bdi,
2598 .sync_mode = wbc->sync_mode, 2597 .sync_mode = wbc->sync_mode,
2599 .older_than_this = NULL, 2598 .older_than_this = NULL,
2600 .nr_to_write = 64, 2599 .nr_to_write = 64,
@@ -2628,7 +2627,6 @@ int extent_write_locked_range(struct extent_io_tree *tree, struct inode *inode,
2628 .sync_io = mode == WB_SYNC_ALL, 2627 .sync_io = mode == WB_SYNC_ALL,
2629 }; 2628 };
2630 struct writeback_control wbc_writepages = { 2629 struct writeback_control wbc_writepages = {
2631 .bdi = inode->i_mapping->backing_dev_info,
2632 .sync_mode = mode, 2630 .sync_mode = mode,
2633 .older_than_this = NULL, 2631 .older_than_this = NULL,
2634 .nr_to_write = nr_pages * 2, 2632 .nr_to_write = nr_pages * 2,
diff --git a/fs/ceph/auth_x.c b/fs/ceph/auth_x.c
index 83d4d2785ffe..3fe49042d8ad 100644
--- a/fs/ceph/auth_x.c
+++ b/fs/ceph/auth_x.c
@@ -493,7 +493,7 @@ static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result,
493 return -EAGAIN; 493 return -EAGAIN;
494 } 494 }
495 495
496 op = le32_to_cpu(head->op); 496 op = le16_to_cpu(head->op);
497 result = le32_to_cpu(head->result); 497 result = le32_to_cpu(head->result);
498 dout("handle_reply op %d result %d\n", op, result); 498 dout("handle_reply op %d result %d\n", op, result);
499 switch (op) { 499 switch (op) {
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 619b61655ee5..74144d6389f0 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -244,8 +244,14 @@ static struct ceph_cap *get_cap(struct ceph_cap_reservation *ctx)
244 struct ceph_cap *cap = NULL; 244 struct ceph_cap *cap = NULL;
245 245
246 /* temporary, until we do something about cap import/export */ 246 /* temporary, until we do something about cap import/export */
247 if (!ctx) 247 if (!ctx) {
248 return kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); 248 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS);
249 if (cap) {
250 caps_use_count++;
251 caps_total_count++;
252 }
253 return cap;
254 }
249 255
250 spin_lock(&caps_list_lock); 256 spin_lock(&caps_list_lock);
251 dout("get_cap ctx=%p (%d) %d = %d used + %d resv + %d avail\n", 257 dout("get_cap ctx=%p (%d) %d = %d used + %d resv + %d avail\n",
@@ -2886,18 +2892,19 @@ int ceph_encode_inode_release(void **p, struct inode *inode,
2886 struct ceph_inode_info *ci = ceph_inode(inode); 2892 struct ceph_inode_info *ci = ceph_inode(inode);
2887 struct ceph_cap *cap; 2893 struct ceph_cap *cap;
2888 struct ceph_mds_request_release *rel = *p; 2894 struct ceph_mds_request_release *rel = *p;
2895 int used, dirty;
2889 int ret = 0; 2896 int ret = 0;
2890 int used = 0;
2891 2897
2892 spin_lock(&inode->i_lock); 2898 spin_lock(&inode->i_lock);
2893 used = __ceph_caps_used(ci); 2899 used = __ceph_caps_used(ci);
2900 dirty = __ceph_caps_dirty(ci);
2894 2901
2895 dout("encode_inode_release %p mds%d used %s drop %s unless %s\n", inode, 2902 dout("encode_inode_release %p mds%d used|dirty %s drop %s unless %s\n",
2896 mds, ceph_cap_string(used), ceph_cap_string(drop), 2903 inode, mds, ceph_cap_string(used|dirty), ceph_cap_string(drop),
2897 ceph_cap_string(unless)); 2904 ceph_cap_string(unless));
2898 2905
2899 /* only drop unused caps */ 2906 /* only drop unused, clean caps */
2900 drop &= ~used; 2907 drop &= ~(used | dirty);
2901 2908
2902 cap = __get_cap_for_mds(ci, mds); 2909 cap = __get_cap_for_mds(ci, mds);
2903 if (cap && __cap_is_valid(cap)) { 2910 if (cap && __cap_is_valid(cap)) {
diff --git a/fs/ceph/crush/mapper.c b/fs/ceph/crush/mapper.c
index 9ba54efb6543..a4eec133258e 100644
--- a/fs/ceph/crush/mapper.c
+++ b/fs/ceph/crush/mapper.c
@@ -238,7 +238,7 @@ static int bucket_straw_choose(struct crush_bucket_straw *bucket,
238 238
239static int crush_bucket_choose(struct crush_bucket *in, int x, int r) 239static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
240{ 240{
241 dprintk("choose %d x=%d r=%d\n", in->id, x, r); 241 dprintk(" crush_bucket_choose %d x=%d r=%d\n", in->id, x, r);
242 switch (in->alg) { 242 switch (in->alg) {
243 case CRUSH_BUCKET_UNIFORM: 243 case CRUSH_BUCKET_UNIFORM:
244 return bucket_uniform_choose((struct crush_bucket_uniform *)in, 244 return bucket_uniform_choose((struct crush_bucket_uniform *)in,
@@ -264,7 +264,7 @@ static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
264 */ 264 */
265static int is_out(struct crush_map *map, __u32 *weight, int item, int x) 265static int is_out(struct crush_map *map, __u32 *weight, int item, int x)
266{ 266{
267 if (weight[item] >= 0x1000) 267 if (weight[item] >= 0x10000)
268 return 0; 268 return 0;
269 if (weight[item] == 0) 269 if (weight[item] == 0)
270 return 1; 270 return 1;
@@ -305,7 +305,9 @@ static int crush_choose(struct crush_map *map,
305 int itemtype; 305 int itemtype;
306 int collide, reject; 306 int collide, reject;
307 const int orig_tries = 5; /* attempts before we fall back to search */ 307 const int orig_tries = 5; /* attempts before we fall back to search */
308 dprintk("choose bucket %d x %d outpos %d\n", bucket->id, x, outpos); 308
309 dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "",
310 bucket->id, x, outpos, numrep);
309 311
310 for (rep = outpos; rep < numrep; rep++) { 312 for (rep = outpos; rep < numrep; rep++) {
311 /* keep trying until we get a non-out, non-colliding item */ 313 /* keep trying until we get a non-out, non-colliding item */
@@ -366,6 +368,7 @@ static int crush_choose(struct crush_map *map,
366 BUG_ON(item >= 0 || 368 BUG_ON(item >= 0 ||
367 (-1-item) >= map->max_buckets); 369 (-1-item) >= map->max_buckets);
368 in = map->buckets[-1-item]; 370 in = map->buckets[-1-item];
371 retry_bucket = 1;
369 continue; 372 continue;
370 } 373 }
371 374
@@ -377,15 +380,25 @@ static int crush_choose(struct crush_map *map,
377 } 380 }
378 } 381 }
379 382
380 if (recurse_to_leaf && 383 reject = 0;
381 item < 0 && 384 if (recurse_to_leaf) {
382 crush_choose(map, map->buckets[-1-item], 385 if (item < 0) {
383 weight, 386 if (crush_choose(map,
384 x, outpos+1, 0, 387 map->buckets[-1-item],
385 out2, outpos, 388 weight,
386 firstn, 0, NULL) <= outpos) { 389 x, outpos+1, 0,
387 reject = 1; 390 out2, outpos,
388 } else { 391 firstn, 0,
392 NULL) <= outpos)
393 /* didn't get leaf */
394 reject = 1;
395 } else {
396 /* we already have a leaf! */
397 out2[outpos] = item;
398 }
399 }
400
401 if (!reject) {
389 /* out? */ 402 /* out? */
390 if (itemtype == 0) 403 if (itemtype == 0)
391 reject = is_out(map, weight, 404 reject = is_out(map, weight,
@@ -424,12 +437,12 @@ reject:
424 continue; 437 continue;
425 } 438 }
426 439
427 dprintk("choose got %d\n", item); 440 dprintk("CHOOSE got %d\n", item);
428 out[outpos] = item; 441 out[outpos] = item;
429 outpos++; 442 outpos++;
430 } 443 }
431 444
432 dprintk("choose returns %d\n", outpos); 445 dprintk("CHOOSE returns %d\n", outpos);
433 return outpos; 446 return outpos;
434} 447}
435 448
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index 3be33fb066cc..f2f5332ddbba 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -261,7 +261,7 @@ static int osdc_show(struct seq_file *s, void *pp)
261 261
262static int caps_show(struct seq_file *s, void *p) 262static int caps_show(struct seq_file *s, void *p)
263{ 263{
264 struct ceph_client *client = p; 264 struct ceph_client *client = s->private;
265 int total, avail, used, reserved, min; 265 int total, avail, used, reserved, min;
266 266
267 ceph_reservation_status(client, &total, &avail, &used, &reserved, &min); 267 ceph_reservation_status(client, &total, &avail, &used, &reserved, &min);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index ab47f46ca282..8f9b9fe8ef9f 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -854,8 +854,8 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
854 d_drop(dn); 854 d_drop(dn);
855 realdn = d_materialise_unique(dn, in); 855 realdn = d_materialise_unique(dn, in);
856 if (IS_ERR(realdn)) { 856 if (IS_ERR(realdn)) {
857 pr_err("splice_dentry error %p inode %p ino %llx.%llx\n", 857 pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
858 dn, in, ceph_vinop(in)); 858 PTR_ERR(realdn), dn, in, ceph_vinop(in));
859 if (prehash) 859 if (prehash)
860 *prehash = false; /* don't rehash on error */ 860 *prehash = false; /* don't rehash on error */
861 dn = realdn; /* note realdn contains the error */ 861 dn = realdn; /* note realdn contains the error */
@@ -1234,18 +1234,23 @@ retry_lookup:
1234 goto out; 1234 goto out;
1235 } 1235 }
1236 dn = splice_dentry(dn, in, NULL); 1236 dn = splice_dentry(dn, in, NULL);
1237 if (IS_ERR(dn))
1238 dn = NULL;
1237 } 1239 }
1238 1240
1239 if (fill_inode(in, &rinfo->dir_in[i], NULL, session, 1241 if (fill_inode(in, &rinfo->dir_in[i], NULL, session,
1240 req->r_request_started, -1, 1242 req->r_request_started, -1,
1241 &req->r_caps_reservation) < 0) { 1243 &req->r_caps_reservation) < 0) {
1242 pr_err("fill_inode badness on %p\n", in); 1244 pr_err("fill_inode badness on %p\n", in);
1243 dput(dn); 1245 goto next_item;
1244 continue;
1245 } 1246 }
1246 update_dentry_lease(dn, rinfo->dir_dlease[i], 1247 if (dn)
1247 req->r_session, req->r_request_started); 1248 update_dentry_lease(dn, rinfo->dir_dlease[i],
1248 dput(dn); 1249 req->r_session,
1250 req->r_request_started);
1251next_item:
1252 if (dn)
1253 dput(dn);
1249 } 1254 }
1250 req->r_did_prepopulate = true; 1255 req->r_did_prepopulate = true;
1251 1256
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 1766947fc07a..3ab79f6c4ce8 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2783,6 +2783,12 @@ void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc)
2783 drop_leases(mdsc); 2783 drop_leases(mdsc);
2784 ceph_flush_dirty_caps(mdsc); 2784 ceph_flush_dirty_caps(mdsc);
2785 wait_requests(mdsc); 2785 wait_requests(mdsc);
2786
2787 /*
2788 * wait for reply handlers to drop their request refs and
2789 * their inode/dcache refs
2790 */
2791 ceph_msgr_flush();
2786} 2792}
2787 2793
2788/* 2794/*
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
index 64b8b1f7863d..9ad43a310a41 100644
--- a/fs/ceph/messenger.c
+++ b/fs/ceph/messenger.c
@@ -657,7 +657,7 @@ static void prepare_write_connect(struct ceph_messenger *msgr,
657 dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con, 657 dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con,
658 con->connect_seq, global_seq, proto); 658 con->connect_seq, global_seq, proto);
659 659
660 con->out_connect.features = CEPH_FEATURE_SUPPORTED_CLIENT; 660 con->out_connect.features = cpu_to_le64(CEPH_FEATURE_SUPPORTED_CLIENT);
661 con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT); 661 con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT);
662 con->out_connect.connect_seq = cpu_to_le32(con->connect_seq); 662 con->out_connect.connect_seq = cpu_to_le32(con->connect_seq);
663 con->out_connect.global_seq = cpu_to_le32(global_seq); 663 con->out_connect.global_seq = cpu_to_le32(global_seq);
@@ -1396,10 +1396,12 @@ static int read_partial_message(struct ceph_connection *con)
1396 if (!con->in_msg) { 1396 if (!con->in_msg) {
1397 dout("got hdr type %d front %d data %d\n", con->in_hdr.type, 1397 dout("got hdr type %d front %d data %d\n", con->in_hdr.type,
1398 con->in_hdr.front_len, con->in_hdr.data_len); 1398 con->in_hdr.front_len, con->in_hdr.data_len);
1399 skip = 0;
1399 con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip); 1400 con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip);
1400 if (skip) { 1401 if (skip) {
1401 /* skip this message */ 1402 /* skip this message */
1402 dout("alloc_msg said skip message\n"); 1403 dout("alloc_msg said skip message\n");
1404 BUG_ON(con->in_msg);
1403 con->in_base_pos = -front_len - middle_len - data_len - 1405 con->in_base_pos = -front_len - middle_len - data_len -
1404 sizeof(m->footer); 1406 sizeof(m->footer);
1405 con->in_tag = CEPH_MSGR_TAG_READY; 1407 con->in_tag = CEPH_MSGR_TAG_READY;
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 07a539906e67..cc115eafae11 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -725,7 +725,8 @@ static void handle_auth_reply(struct ceph_mon_client *monc,
725 dout("authenticated, starting session\n"); 725 dout("authenticated, starting session\n");
726 726
727 monc->client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT; 727 monc->client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT;
728 monc->client->msgr->inst.name.num = monc->auth->global_id; 728 monc->client->msgr->inst.name.num =
729 cpu_to_le64(monc->auth->global_id);
729 730
730 __send_subscribe(monc); 731 __send_subscribe(monc);
731 __resend_generic_request(monc); 732 __resend_generic_request(monc);
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index d25b4add85b4..92b7251a53f1 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -1344,7 +1344,7 @@ static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
1344 int type = le16_to_cpu(msg->hdr.type); 1344 int type = le16_to_cpu(msg->hdr.type);
1345 1345
1346 if (!osd) 1346 if (!osd)
1347 return; 1347 goto out;
1348 osdc = osd->o_osdc; 1348 osdc = osd->o_osdc;
1349 1349
1350 switch (type) { 1350 switch (type) {
@@ -1359,6 +1359,7 @@ static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
1359 pr_err("received unknown message type %d %s\n", type, 1359 pr_err("received unknown message type %d %s\n", type,
1360 ceph_msg_type_name(type)); 1360 ceph_msg_type_name(type));
1361 } 1361 }
1362out:
1362 ceph_msg_put(msg); 1363 ceph_msg_put(msg);
1363} 1364}
1364 1365
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
index ddc656fb5c05..50ce64ebd330 100644
--- a/fs/ceph/osdmap.c
+++ b/fs/ceph/osdmap.c
@@ -707,6 +707,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
707 newcrush = crush_decode(*p, min(*p+len, end)); 707 newcrush = crush_decode(*p, min(*p+len, end));
708 if (IS_ERR(newcrush)) 708 if (IS_ERR(newcrush))
709 return ERR_CAST(newcrush); 709 return ERR_CAST(newcrush);
710 *p += len;
710 } 711 }
711 712
712 /* new flags? */ 713 /* new flags? */
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 0609607d3955..d5be1693ac93 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -38,43 +38,18 @@ int nr_pdflush_threads;
38/* 38/*
39 * Passed into wb_writeback(), essentially a subset of writeback_control 39 * Passed into wb_writeback(), essentially a subset of writeback_control
40 */ 40 */
41struct wb_writeback_args { 41struct wb_writeback_work {
42 long nr_pages; 42 long nr_pages;
43 struct super_block *sb; 43 struct super_block *sb;
44 enum writeback_sync_modes sync_mode; 44 enum writeback_sync_modes sync_mode;
45 unsigned int for_kupdate:1; 45 unsigned int for_kupdate:1;
46 unsigned int range_cyclic:1; 46 unsigned int range_cyclic:1;
47 unsigned int for_background:1; 47 unsigned int for_background:1;
48};
49 48
50/*
51 * Work items for the bdi_writeback threads
52 */
53struct bdi_work {
54 struct list_head list; /* pending work list */ 49 struct list_head list; /* pending work list */
55 struct rcu_head rcu_head; /* for RCU free/clear of work */ 50 struct completion *done; /* set if the caller waits */
56
57 unsigned long seen; /* threads that have seen this work */
58 atomic_t pending; /* number of threads still to do work */
59
60 struct wb_writeback_args args; /* writeback arguments */
61
62 unsigned long state; /* flag bits, see WS_* */
63}; 51};
64 52
65enum {
66 WS_INPROGRESS = 0,
67 WS_ONSTACK,
68};
69
70static inline void bdi_work_init(struct bdi_work *work,
71 struct wb_writeback_args *args)
72{
73 INIT_RCU_HEAD(&work->rcu_head);
74 work->args = *args;
75 __set_bit(WS_INPROGRESS, &work->state);
76}
77
78/** 53/**
79 * writeback_in_progress - determine whether there is writeback in progress 54 * writeback_in_progress - determine whether there is writeback in progress
80 * @bdi: the device's backing_dev_info structure. 55 * @bdi: the device's backing_dev_info structure.
@@ -87,49 +62,11 @@ int writeback_in_progress(struct backing_dev_info *bdi)
87 return !list_empty(&bdi->work_list); 62 return !list_empty(&bdi->work_list);
88} 63}
89 64
90static void bdi_work_free(struct rcu_head *head) 65static void bdi_queue_work(struct backing_dev_info *bdi,
91{ 66 struct wb_writeback_work *work)
92 struct bdi_work *work = container_of(head, struct bdi_work, rcu_head);
93
94 clear_bit(WS_INPROGRESS, &work->state);
95 smp_mb__after_clear_bit();
96 wake_up_bit(&work->state, WS_INPROGRESS);
97
98 if (!test_bit(WS_ONSTACK, &work->state))
99 kfree(work);
100}
101
102static void wb_clear_pending(struct bdi_writeback *wb, struct bdi_work *work)
103{ 67{
104 /*
105 * The caller has retrieved the work arguments from this work,
106 * drop our reference. If this is the last ref, delete and free it
107 */
108 if (atomic_dec_and_test(&work->pending)) {
109 struct backing_dev_info *bdi = wb->bdi;
110
111 spin_lock(&bdi->wb_lock);
112 list_del_rcu(&work->list);
113 spin_unlock(&bdi->wb_lock);
114
115 call_rcu(&work->rcu_head, bdi_work_free);
116 }
117}
118
119static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
120{
121 work->seen = bdi->wb_mask;
122 BUG_ON(!work->seen);
123 atomic_set(&work->pending, bdi->wb_cnt);
124 BUG_ON(!bdi->wb_cnt);
125
126 /*
127 * list_add_tail_rcu() contains the necessary barriers to
128 * make sure the above stores are seen before the item is
129 * noticed on the list
130 */
131 spin_lock(&bdi->wb_lock); 68 spin_lock(&bdi->wb_lock);
132 list_add_tail_rcu(&work->list, &bdi->work_list); 69 list_add_tail(&work->list, &bdi->work_list);
133 spin_unlock(&bdi->wb_lock); 70 spin_unlock(&bdi->wb_lock);
134 71
135 /* 72 /*
@@ -146,55 +83,29 @@ static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
146 } 83 }
147} 84}
148 85
149/* 86static void
150 * Used for on-stack allocated work items. The caller needs to wait until 87__bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages,
151 * the wb threads have acked the work before it's safe to continue. 88 bool range_cyclic, bool for_background)
152 */
153static void bdi_wait_on_work_done(struct bdi_work *work)
154{ 89{
155 wait_on_bit(&work->state, WS_INPROGRESS, bdi_sched_wait, 90 struct wb_writeback_work *work;
156 TASK_UNINTERRUPTIBLE);
157}
158
159static void bdi_alloc_queue_work(struct backing_dev_info *bdi,
160 struct wb_writeback_args *args)
161{
162 struct bdi_work *work;
163 91
164 /* 92 /*
165 * This is WB_SYNC_NONE writeback, so if allocation fails just 93 * This is WB_SYNC_NONE writeback, so if allocation fails just
166 * wakeup the thread for old dirty data writeback 94 * wakeup the thread for old dirty data writeback
167 */ 95 */
168 work = kmalloc(sizeof(*work), GFP_ATOMIC); 96 work = kzalloc(sizeof(*work), GFP_ATOMIC);
169 if (work) { 97 if (!work) {
170 bdi_work_init(work, args); 98 if (bdi->wb.task)
171 bdi_queue_work(bdi, work); 99 wake_up_process(bdi->wb.task);
172 } else { 100 return;
173 struct bdi_writeback *wb = &bdi->wb;
174
175 if (wb->task)
176 wake_up_process(wb->task);
177 } 101 }
178}
179 102
180/** 103 work->sync_mode = WB_SYNC_NONE;
181 * bdi_queue_work_onstack - start and wait for writeback 104 work->nr_pages = nr_pages;
182 * @sb: write inodes from this super_block 105 work->range_cyclic = range_cyclic;
183 * 106 work->for_background = for_background;
184 * Description:
185 * This function initiates writeback and waits for the operation to
186 * complete. Callers must hold the sb s_umount semaphore for
187 * reading, to avoid having the super disappear before we are done.
188 */
189static void bdi_queue_work_onstack(struct wb_writeback_args *args)
190{
191 struct bdi_work work;
192
193 bdi_work_init(&work, args);
194 __set_bit(WS_ONSTACK, &work.state);
195 107
196 bdi_queue_work(args->sb->s_bdi, &work); 108 bdi_queue_work(bdi, work);
197 bdi_wait_on_work_done(&work);
198} 109}
199 110
200/** 111/**
@@ -210,13 +121,7 @@ static void bdi_queue_work_onstack(struct wb_writeback_args *args)
210 */ 121 */
211void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages) 122void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages)
212{ 123{
213 struct wb_writeback_args args = { 124 __bdi_start_writeback(bdi, nr_pages, true, false);
214 .sync_mode = WB_SYNC_NONE,
215 .nr_pages = nr_pages,
216 .range_cyclic = 1,
217 };
218
219 bdi_alloc_queue_work(bdi, &args);
220} 125}
221 126
222/** 127/**
@@ -230,13 +135,7 @@ void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages)
230 */ 135 */
231void bdi_start_background_writeback(struct backing_dev_info *bdi) 136void bdi_start_background_writeback(struct backing_dev_info *bdi)
232{ 137{
233 struct wb_writeback_args args = { 138 __bdi_start_writeback(bdi, LONG_MAX, true, true);
234 .sync_mode = WB_SYNC_NONE,
235 .nr_pages = LONG_MAX,
236 .for_background = 1,
237 .range_cyclic = 1,
238 };
239 bdi_alloc_queue_work(bdi, &args);
240} 139}
241 140
242/* 141/*
@@ -554,29 +453,41 @@ static bool pin_sb_for_writeback(struct super_block *sb)
554 453
555/* 454/*
556 * Write a portion of b_io inodes which belong to @sb. 455 * Write a portion of b_io inodes which belong to @sb.
557 * If @wbc->sb != NULL, then find and write all such 456 *
457 * If @only_this_sb is true, then find and write all such
558 * inodes. Otherwise write only ones which go sequentially 458 * inodes. Otherwise write only ones which go sequentially
559 * in reverse order. 459 * in reverse order.
460 *
560 * Return 1, if the caller writeback routine should be 461 * Return 1, if the caller writeback routine should be
561 * interrupted. Otherwise return 0. 462 * interrupted. Otherwise return 0.
562 */ 463 */
563static int writeback_sb_inodes(struct super_block *sb, 464static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb,
564 struct bdi_writeback *wb, 465 struct writeback_control *wbc, bool only_this_sb)
565 struct writeback_control *wbc)
566{ 466{
567 while (!list_empty(&wb->b_io)) { 467 while (!list_empty(&wb->b_io)) {
568 long pages_skipped; 468 long pages_skipped;
569 struct inode *inode = list_entry(wb->b_io.prev, 469 struct inode *inode = list_entry(wb->b_io.prev,
570 struct inode, i_list); 470 struct inode, i_list);
571 if (wbc->sb && sb != inode->i_sb) { 471
572 /* super block given and doesn't 472 if (inode->i_sb != sb) {
573 match, skip this inode */ 473 if (only_this_sb) {
574 redirty_tail(inode); 474 /*
575 continue; 475 * We only want to write back data for this
576 } 476 * superblock, move all inodes not belonging
577 if (sb != inode->i_sb) 477 * to it back onto the dirty list.
578 /* finish with this superblock */ 478 */
479 redirty_tail(inode);
480 continue;
481 }
482
483 /*
484 * The inode belongs to a different superblock.
485 * Bounce back to the caller to unpin this and
486 * pin the next superblock.
487 */
579 return 0; 488 return 0;
489 }
490
580 if (inode->i_state & (I_NEW | I_WILL_FREE)) { 491 if (inode->i_state & (I_NEW | I_WILL_FREE)) {
581 requeue_io(inode); 492 requeue_io(inode);
582 continue; 493 continue;
@@ -614,8 +525,8 @@ static int writeback_sb_inodes(struct super_block *sb,
614 return 1; 525 return 1;
615} 526}
616 527
617static void writeback_inodes_wb(struct bdi_writeback *wb, 528void writeback_inodes_wb(struct bdi_writeback *wb,
618 struct writeback_control *wbc) 529 struct writeback_control *wbc)
619{ 530{
620 int ret = 0; 531 int ret = 0;
621 532
@@ -629,29 +540,12 @@ static void writeback_inodes_wb(struct bdi_writeback *wb,
629 struct inode, i_list); 540 struct inode, i_list);
630 struct super_block *sb = inode->i_sb; 541 struct super_block *sb = inode->i_sb;
631 542
632 if (wbc->sb) { 543 if (!pin_sb_for_writeback(sb)) {
633 /* 544 requeue_io(inode);
634 * We are requested to write out inodes for a specific 545 continue;
635 * superblock. This means we already have s_umount
636 * taken by the caller which also waits for us to
637 * complete the writeout.
638 */
639 if (sb != wbc->sb) {
640 redirty_tail(inode);
641 continue;
642 }
643
644 WARN_ON(!rwsem_is_locked(&sb->s_umount));
645
646 ret = writeback_sb_inodes(sb, wb, wbc);
647 } else {
648 if (!pin_sb_for_writeback(sb)) {
649 requeue_io(inode);
650 continue;
651 }
652 ret = writeback_sb_inodes(sb, wb, wbc);
653 drop_super(sb);
654 } 546 }
547 ret = writeback_sb_inodes(sb, wb, wbc, false);
548 drop_super(sb);
655 549
656 if (ret) 550 if (ret)
657 break; 551 break;
@@ -660,11 +554,17 @@ static void writeback_inodes_wb(struct bdi_writeback *wb,
660 /* Leave any unwritten inodes on b_io */ 554 /* Leave any unwritten inodes on b_io */
661} 555}
662 556
663void writeback_inodes_wbc(struct writeback_control *wbc) 557static void __writeback_inodes_sb(struct super_block *sb,
558 struct bdi_writeback *wb, struct writeback_control *wbc)
664{ 559{
665 struct backing_dev_info *bdi = wbc->bdi; 560 WARN_ON(!rwsem_is_locked(&sb->s_umount));
666 561
667 writeback_inodes_wb(&bdi->wb, wbc); 562 wbc->wb_start = jiffies; /* livelock avoidance */
563 spin_lock(&inode_lock);
564 if (!wbc->for_kupdate || list_empty(&wb->b_io))
565 queue_io(wb, wbc->older_than_this);
566 writeback_sb_inodes(sb, wb, wbc, true);
567 spin_unlock(&inode_lock);
668} 568}
669 569
670/* 570/*
@@ -702,16 +602,14 @@ static inline bool over_bground_thresh(void)
702 * all dirty pages if they are all attached to "old" mappings. 602 * all dirty pages if they are all attached to "old" mappings.
703 */ 603 */
704static long wb_writeback(struct bdi_writeback *wb, 604static long wb_writeback(struct bdi_writeback *wb,
705 struct wb_writeback_args *args) 605 struct wb_writeback_work *work)
706{ 606{
707 struct writeback_control wbc = { 607 struct writeback_control wbc = {
708 .bdi = wb->bdi, 608 .sync_mode = work->sync_mode,
709 .sb = args->sb,
710 .sync_mode = args->sync_mode,
711 .older_than_this = NULL, 609 .older_than_this = NULL,
712 .for_kupdate = args->for_kupdate, 610 .for_kupdate = work->for_kupdate,
713 .for_background = args->for_background, 611 .for_background = work->for_background,
714 .range_cyclic = args->range_cyclic, 612 .range_cyclic = work->range_cyclic,
715 }; 613 };
716 unsigned long oldest_jif; 614 unsigned long oldest_jif;
717 long wrote = 0; 615 long wrote = 0;
@@ -731,21 +629,24 @@ static long wb_writeback(struct bdi_writeback *wb,
731 /* 629 /*
732 * Stop writeback when nr_pages has been consumed 630 * Stop writeback when nr_pages has been consumed
733 */ 631 */
734 if (args->nr_pages <= 0) 632 if (work->nr_pages <= 0)
735 break; 633 break;
736 634
737 /* 635 /*
738 * For background writeout, stop when we are below the 636 * For background writeout, stop when we are below the
739 * background dirty threshold 637 * background dirty threshold
740 */ 638 */
741 if (args->for_background && !over_bground_thresh()) 639 if (work->for_background && !over_bground_thresh())
742 break; 640 break;
743 641
744 wbc.more_io = 0; 642 wbc.more_io = 0;
745 wbc.nr_to_write = MAX_WRITEBACK_PAGES; 643 wbc.nr_to_write = MAX_WRITEBACK_PAGES;
746 wbc.pages_skipped = 0; 644 wbc.pages_skipped = 0;
747 writeback_inodes_wb(wb, &wbc); 645 if (work->sb)
748 args->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write; 646 __writeback_inodes_sb(work->sb, wb, &wbc);
647 else
648 writeback_inodes_wb(wb, &wbc);
649 work->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
749 wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write; 650 wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write;
750 651
751 /* 652 /*
@@ -781,31 +682,21 @@ static long wb_writeback(struct bdi_writeback *wb,
781} 682}
782 683
783/* 684/*
784 * Return the next bdi_work struct that hasn't been processed by this 685 * Return the next wb_writeback_work struct that hasn't been processed yet.
785 * wb thread yet. ->seen is initially set for each thread that exists
786 * for this device, when a thread first notices a piece of work it
787 * clears its bit. Depending on writeback type, the thread will notify
788 * completion on either receiving the work (WB_SYNC_NONE) or after
789 * it is done (WB_SYNC_ALL).
790 */ 686 */
791static struct bdi_work *get_next_work_item(struct backing_dev_info *bdi, 687static struct wb_writeback_work *
792 struct bdi_writeback *wb) 688get_next_work_item(struct backing_dev_info *bdi, struct bdi_writeback *wb)
793{ 689{
794 struct bdi_work *work, *ret = NULL; 690 struct wb_writeback_work *work = NULL;
795
796 rcu_read_lock();
797 691
798 list_for_each_entry_rcu(work, &bdi->work_list, list) { 692 spin_lock(&bdi->wb_lock);
799 if (!test_bit(wb->nr, &work->seen)) 693 if (!list_empty(&bdi->work_list)) {
800 continue; 694 work = list_entry(bdi->work_list.next,
801 clear_bit(wb->nr, &work->seen); 695 struct wb_writeback_work, list);
802 696 list_del_init(&work->list);
803 ret = work;
804 break;
805 } 697 }
806 698 spin_unlock(&bdi->wb_lock);
807 rcu_read_unlock(); 699 return work;
808 return ret;
809} 700}
810 701
811static long wb_check_old_data_flush(struct bdi_writeback *wb) 702static long wb_check_old_data_flush(struct bdi_writeback *wb)
@@ -830,14 +721,14 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
830 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 721 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
831 722
832 if (nr_pages) { 723 if (nr_pages) {
833 struct wb_writeback_args args = { 724 struct wb_writeback_work work = {
834 .nr_pages = nr_pages, 725 .nr_pages = nr_pages,
835 .sync_mode = WB_SYNC_NONE, 726 .sync_mode = WB_SYNC_NONE,
836 .for_kupdate = 1, 727 .for_kupdate = 1,
837 .range_cyclic = 1, 728 .range_cyclic = 1,
838 }; 729 };
839 730
840 return wb_writeback(wb, &args); 731 return wb_writeback(wb, &work);
841 } 732 }
842 733
843 return 0; 734 return 0;
@@ -849,33 +740,27 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
849long wb_do_writeback(struct bdi_writeback *wb, int force_wait) 740long wb_do_writeback(struct bdi_writeback *wb, int force_wait)
850{ 741{
851 struct backing_dev_info *bdi = wb->bdi; 742 struct backing_dev_info *bdi = wb->bdi;
852 struct bdi_work *work; 743 struct wb_writeback_work *work;
853 long wrote = 0; 744 long wrote = 0;
854 745
855 while ((work = get_next_work_item(bdi, wb)) != NULL) { 746 while ((work = get_next_work_item(bdi, wb)) != NULL) {
856 struct wb_writeback_args args = work->args;
857
858 /* 747 /*
859 * Override sync mode, in case we must wait for completion 748 * Override sync mode, in case we must wait for completion
749 * because this thread is exiting now.
860 */ 750 */
861 if (force_wait) 751 if (force_wait)
862 work->args.sync_mode = args.sync_mode = WB_SYNC_ALL; 752 work->sync_mode = WB_SYNC_ALL;
863
864 /*
865 * If this isn't a data integrity operation, just notify
866 * that we have seen this work and we are now starting it.
867 */
868 if (!test_bit(WS_ONSTACK, &work->state))
869 wb_clear_pending(wb, work);
870 753
871 wrote += wb_writeback(wb, &args); 754 wrote += wb_writeback(wb, work);
872 755
873 /* 756 /*
874 * This is a data integrity writeback, so only do the 757 * Notify the caller of completion if this is a synchronous
875 * notification when we have completed the work. 758 * work item, otherwise just free it.
876 */ 759 */
877 if (test_bit(WS_ONSTACK, &work->state)) 760 if (work->done)
878 wb_clear_pending(wb, work); 761 complete(work->done);
762 else
763 kfree(work);
879 } 764 }
880 765
881 /* 766 /*
@@ -938,14 +823,9 @@ int bdi_writeback_task(struct bdi_writeback *wb)
938void wakeup_flusher_threads(long nr_pages) 823void wakeup_flusher_threads(long nr_pages)
939{ 824{
940 struct backing_dev_info *bdi; 825 struct backing_dev_info *bdi;
941 struct wb_writeback_args args = {
942 .sync_mode = WB_SYNC_NONE,
943 };
944 826
945 if (nr_pages) { 827 if (!nr_pages) {
946 args.nr_pages = nr_pages; 828 nr_pages = global_page_state(NR_FILE_DIRTY) +
947 } else {
948 args.nr_pages = global_page_state(NR_FILE_DIRTY) +
949 global_page_state(NR_UNSTABLE_NFS); 829 global_page_state(NR_UNSTABLE_NFS);
950 } 830 }
951 831
@@ -953,7 +833,7 @@ void wakeup_flusher_threads(long nr_pages)
953 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { 833 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {
954 if (!bdi_has_dirty_io(bdi)) 834 if (!bdi_has_dirty_io(bdi))
955 continue; 835 continue;
956 bdi_alloc_queue_work(bdi, &args); 836 __bdi_start_writeback(bdi, nr_pages, false, false);
957 } 837 }
958 rcu_read_unlock(); 838 rcu_read_unlock();
959} 839}
@@ -1162,17 +1042,20 @@ void writeback_inodes_sb(struct super_block *sb)
1162{ 1042{
1163 unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); 1043 unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
1164 unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); 1044 unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
1165 struct wb_writeback_args args = { 1045 DECLARE_COMPLETION_ONSTACK(done);
1046 struct wb_writeback_work work = {
1166 .sb = sb, 1047 .sb = sb,
1167 .sync_mode = WB_SYNC_NONE, 1048 .sync_mode = WB_SYNC_NONE,
1049 .done = &done,
1168 }; 1050 };
1169 1051
1170 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 1052 WARN_ON(!rwsem_is_locked(&sb->s_umount));
1171 1053
1172 args.nr_pages = nr_dirty + nr_unstable + 1054 work.nr_pages = nr_dirty + nr_unstable +
1173 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 1055 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
1174 1056
1175 bdi_queue_work_onstack(&args); 1057 bdi_queue_work(sb->s_bdi, &work);
1058 wait_for_completion(&done);
1176} 1059}
1177EXPORT_SYMBOL(writeback_inodes_sb); 1060EXPORT_SYMBOL(writeback_inodes_sb);
1178 1061
@@ -1204,16 +1087,20 @@ EXPORT_SYMBOL(writeback_inodes_sb_if_idle);
1204 */ 1087 */
1205void sync_inodes_sb(struct super_block *sb) 1088void sync_inodes_sb(struct super_block *sb)
1206{ 1089{
1207 struct wb_writeback_args args = { 1090 DECLARE_COMPLETION_ONSTACK(done);
1091 struct wb_writeback_work work = {
1208 .sb = sb, 1092 .sb = sb,
1209 .sync_mode = WB_SYNC_ALL, 1093 .sync_mode = WB_SYNC_ALL,
1210 .nr_pages = LONG_MAX, 1094 .nr_pages = LONG_MAX,
1211 .range_cyclic = 0, 1095 .range_cyclic = 0,
1096 .done = &done,
1212 }; 1097 };
1213 1098
1214 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 1099 WARN_ON(!rwsem_is_locked(&sb->s_umount));
1215 1100
1216 bdi_queue_work_onstack(&args); 1101 bdi_queue_work(sb->s_bdi, &work);
1102 wait_for_completion(&done);
1103
1217 wait_sb_inodes(sb); 1104 wait_sb_inodes(sb);
1218} 1105}
1219EXPORT_SYMBOL(sync_inodes_sb); 1106EXPORT_SYMBOL(sync_inodes_sb);
diff --git a/fs/splice.c b/fs/splice.c
index 740e6b9faf7a..efdbfece9932 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1282,7 +1282,8 @@ static int direct_splice_actor(struct pipe_inode_info *pipe,
1282{ 1282{
1283 struct file *file = sd->u.file; 1283 struct file *file = sd->u.file;
1284 1284
1285 return do_splice_from(pipe, file, &sd->pos, sd->total_len, sd->flags); 1285 return do_splice_from(pipe, file, &file->f_pos, sd->total_len,
1286 sd->flags);
1286} 1287}
1287 1288
1288/** 1289/**
@@ -1371,8 +1372,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1371 if (off_in) 1372 if (off_in)
1372 return -ESPIPE; 1373 return -ESPIPE;
1373 if (off_out) { 1374 if (off_out) {
1374 if (!out->f_op || !out->f_op->llseek || 1375 if (!(out->f_mode & FMODE_PWRITE))
1375 out->f_op->llseek == no_llseek)
1376 return -EINVAL; 1376 return -EINVAL;
1377 if (copy_from_user(&offset, off_out, sizeof(loff_t))) 1377 if (copy_from_user(&offset, off_out, sizeof(loff_t)))
1378 return -EFAULT; 1378 return -EFAULT;
@@ -1392,8 +1392,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1392 if (off_out) 1392 if (off_out)
1393 return -ESPIPE; 1393 return -ESPIPE;
1394 if (off_in) { 1394 if (off_in) {
1395 if (!in->f_op || !in->f_op->llseek || 1395 if (!(in->f_mode & FMODE_PREAD))
1396 in->f_op->llseek == no_llseek)
1397 return -EINVAL; 1396 return -EINVAL;
1398 if (copy_from_user(&offset, off_in, sizeof(loff_t))) 1397 if (copy_from_user(&offset, off_in, sizeof(loff_t)))
1399 return -EFAULT; 1398 return -EFAULT;
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index 8bb4de567b2c..116821448c38 100644
--- a/include/drm/ttm/ttm_page_alloc.h
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -56,10 +56,6 @@ void ttm_put_pages(struct list_head *pages,
56 enum ttm_caching_state cstate); 56 enum ttm_caching_state cstate);
57/** 57/**
58 * Initialize pool allocator. 58 * Initialize pool allocator.
59 *
60 * Pool allocator is internaly reference counted so it can be initialized
61 * multiple times but ttm_page_alloc_fini has to be called same number of
62 * times.
63 */ 59 */
64int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages); 60int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
65/** 61/**
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 9ae2889096b6..e9aec0d099df 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -82,8 +82,6 @@ struct backing_dev_info {
82 struct bdi_writeback wb; /* default writeback info for this bdi */ 82 struct bdi_writeback wb; /* default writeback info for this bdi */
83 spinlock_t wb_lock; /* protects update side of wb_list */ 83 spinlock_t wb_lock; /* protects update side of wb_list */
84 struct list_head wb_list; /* the flusher threads hanging off this bdi */ 84 struct list_head wb_list; /* the flusher threads hanging off this bdi */
85 unsigned long wb_mask; /* bitmask of registered tasks */
86 unsigned int wb_cnt; /* number of registered tasks */
87 85
88 struct list_head work_list; 86 struct list_head work_list;
89 87
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 276b40a16835..b4207ca3ad52 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -379,6 +379,8 @@ struct ethtool_rxnfc {
379 __u32 flow_type; 379 __u32 flow_type;
380 /* The rx flow hash value or the rule DB size */ 380 /* The rx flow hash value or the rule DB size */
381 __u64 data; 381 __u64 data;
382 /* The following fields are not valid and must not be used for
383 * the ETHTOOL_{G,X}RXFH commands. */
382 struct ethtool_rx_flow_spec fs; 384 struct ethtool_rx_flow_spec fs;
383 __u32 rule_cnt; 385 __u32 rule_cnt;
384 __u32 rule_locs[0]; 386 __u32 rule_locs[0];
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 471e1ff5079a..68ca1b0491af 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1783,6 +1783,19 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1783 struct vfsmount *mnt); 1783 struct vfsmount *mnt);
1784extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1784extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1785 1785
1786static inline void sb_mark_dirty(struct super_block *sb)
1787{
1788 sb->s_dirt = 1;
1789}
1790static inline void sb_mark_clean(struct super_block *sb)
1791{
1792 sb->s_dirt = 0;
1793}
1794static inline int sb_is_dirty(struct super_block *sb)
1795{
1796 return sb->s_dirt;
1797}
1798
1786/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1799/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1787#define fops_get(fops) \ 1800#define fops_get(fops) \
1788 (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) 1801 (((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index cbbbe9bfecad..30b0c4e78f91 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -19,6 +19,11 @@ struct mv643xx_eth_shared_platform_data {
19 struct mbus_dram_target_info *dram; 19 struct mbus_dram_target_info *dram;
20 struct platform_device *shared_smi; 20 struct platform_device *shared_smi;
21 unsigned int t_clk; 21 unsigned int t_clk;
22 /*
23 * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default
24 * limit of 9KiB will be used.
25 */
26 int tx_csum_limit;
22}; 27};
23 28
24#define MV643XX_ETH_PHY_ADDR_DEFAULT 0 29#define MV643XX_ETH_PHY_ADDR_DEFAULT 0
diff --git a/include/linux/net.h b/include/linux/net.h
index 2b4deeeb8646..dee0b11a8759 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -129,10 +129,9 @@ struct socket_wq {
129 * @type: socket type (%SOCK_STREAM, etc) 129 * @type: socket type (%SOCK_STREAM, etc)
130 * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc) 130 * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc)
131 * @ops: protocol specific socket operations 131 * @ops: protocol specific socket operations
132 * @fasync_list: Asynchronous wake up list
133 * @file: File back pointer for gc 132 * @file: File back pointer for gc
134 * @sk: internal networking protocol agnostic socket representation 133 * @sk: internal networking protocol agnostic socket representation
135 * @wait: wait queue for several uses 134 * @wq: wait queue for several uses
136 */ 135 */
137struct socket { 136struct socket {
138 socket_state state; 137 socket_state state;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 40291f375024..b21e4054c12c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1656,6 +1656,9 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
1656 return (dev->num_tx_queues > 1); 1656 return (dev->num_tx_queues > 1);
1657} 1657}
1658 1658
1659extern void netif_set_real_num_tx_queues(struct net_device *dev,
1660 unsigned int txq);
1661
1659/* Use this variant when it is known for sure that it 1662/* Use this variant when it is known for sure that it
1660 * is executing from hardware interrupt context or with hardware interrupts 1663 * is executing from hardware interrupt context or with hardware interrupts
1661 * disabled. 1664 * disabled.
@@ -2329,7 +2332,7 @@ do { \
2329#endif 2332#endif
2330 2333
2331#if defined(VERBOSE_DEBUG) 2334#if defined(VERBOSE_DEBUG)
2332#define netif_vdbg netdev_dbg 2335#define netif_vdbg netif_dbg
2333#else 2336#else
2334#define netif_vdbg(priv, type, dev, format, args...) \ 2337#define netif_vdbg(priv, type, dev, format, args...) \
2335({ \ 2338({ \
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index fe1872e5b37e..7066acb2c530 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -110,7 +110,6 @@ struct rb_node
110struct rb_root 110struct rb_root
111{ 111{
112 struct rb_node *rb_node; 112 struct rb_node *rb_node;
113 void (*augment_cb)(struct rb_node *node);
114}; 113};
115 114
116 115
@@ -130,9 +129,7 @@ static inline void rb_set_color(struct rb_node *rb, int color)
130 rb->rb_parent_color = (rb->rb_parent_color & ~1) | color; 129 rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
131} 130}
132 131
133#define RB_ROOT (struct rb_root) { NULL, NULL, } 132#define RB_ROOT (struct rb_root) { NULL, }
134#define RB_AUGMENT_ROOT(x) (struct rb_root) { NULL, x}
135
136#define rb_entry(ptr, type, member) container_of(ptr, type, member) 133#define rb_entry(ptr, type, member) container_of(ptr, type, member)
137 134
138#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) 135#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
@@ -142,6 +139,14 @@ static inline void rb_set_color(struct rb_node *rb, int color)
142extern void rb_insert_color(struct rb_node *, struct rb_root *); 139extern void rb_insert_color(struct rb_node *, struct rb_root *);
143extern void rb_erase(struct rb_node *, struct rb_root *); 140extern void rb_erase(struct rb_node *, struct rb_root *);
144 141
142typedef void (*rb_augment_f)(struct rb_node *node, void *data);
143
144extern void rb_augment_insert(struct rb_node *node,
145 rb_augment_f func, void *data);
146extern struct rb_node *rb_augment_erase_begin(struct rb_node *node);
147extern void rb_augment_erase_end(struct rb_node *node,
148 rb_augment_f func, void *data);
149
145/* Find logical next and previous nodes in a tree */ 150/* Find logical next and previous nodes in a tree */
146extern struct rb_node *rb_next(const struct rb_node *); 151extern struct rb_node *rb_next(const struct rb_node *);
147extern struct rb_node *rb_prev(const struct rb_node *); 152extern struct rb_node *rb_prev(const struct rb_node *);
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index d63ef8f9609f..c24eca71e80c 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -27,10 +27,6 @@ enum writeback_sync_modes {
27 * in a manner such that unspecified fields are set to zero. 27 * in a manner such that unspecified fields are set to zero.
28 */ 28 */
29struct writeback_control { 29struct writeback_control {
30 struct backing_dev_info *bdi; /* If !NULL, only write back this
31 queue */
32 struct super_block *sb; /* if !NULL, only write inodes from
33 this super_block */
34 enum writeback_sync_modes sync_mode; 30 enum writeback_sync_modes sync_mode;
35 unsigned long *older_than_this; /* If !NULL, only write back inodes 31 unsigned long *older_than_this; /* If !NULL, only write back inodes
36 older than this */ 32 older than this */
@@ -66,7 +62,8 @@ int inode_wait(void *);
66void writeback_inodes_sb(struct super_block *); 62void writeback_inodes_sb(struct super_block *);
67int writeback_inodes_sb_if_idle(struct super_block *); 63int writeback_inodes_sb_if_idle(struct super_block *);
68void sync_inodes_sb(struct super_block *); 64void sync_inodes_sb(struct super_block *);
69void writeback_inodes_wbc(struct writeback_control *wbc); 65void writeback_inodes_wb(struct bdi_writeback *wb,
66 struct writeback_control *wbc);
70long wb_do_writeback(struct bdi_writeback *wb, int force_wait); 67long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
71void wakeup_flusher_threads(long nr_pages); 68void wakeup_flusher_threads(long nr_pages);
72 69
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 03ca5d826757..433604bb3fe8 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -313,12 +313,24 @@ extern void qdisc_calculate_pkt_len(struct sk_buff *skb,
313extern void tcf_destroy(struct tcf_proto *tp); 313extern void tcf_destroy(struct tcf_proto *tp);
314extern void tcf_destroy_chain(struct tcf_proto **fl); 314extern void tcf_destroy_chain(struct tcf_proto **fl);
315 315
316/* Reset all TX qdiscs of a device. */ 316/* Reset all TX qdiscs greater then index of a device. */
317static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
318{
319 struct Qdisc *qdisc;
320
321 for (; i < dev->num_tx_queues; i++) {
322 qdisc = netdev_get_tx_queue(dev, i)->qdisc;
323 if (qdisc) {
324 spin_lock_bh(qdisc_lock(qdisc));
325 qdisc_reset(qdisc);
326 spin_unlock_bh(qdisc_lock(qdisc));
327 }
328 }
329}
330
317static inline void qdisc_reset_all_tx(struct net_device *dev) 331static inline void qdisc_reset_all_tx(struct net_device *dev)
318{ 332{
319 unsigned int i; 333 qdisc_reset_all_tx_gt(dev, 0);
320 for (i = 0; i < dev->num_tx_queues; i++)
321 qdisc_reset(netdev_get_tx_queue(dev, i)->qdisc);
322} 334}
323 335
324/* Are all TX queues of the device empty? */ 336/* Are all TX queues of the device empty? */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 1913af67c43d..fc8f36dd0f5c 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1586,7 +1586,7 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb)
1586static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m) 1586static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
1587{ 1587{
1588 if (attrs[XFRMA_MARK]) 1588 if (attrs[XFRMA_MARK])
1589 memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(m)); 1589 memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(struct xfrm_mark));
1590 else 1590 else
1591 m->v = m->m = 0; 1591 m->v = m->m = 0;
1592 1592
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 15e10b1afdd2..4693f79195d3 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -44,11 +44,6 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
44 else 44 else
45 root->rb_node = right; 45 root->rb_node = right;
46 rb_set_parent(node, right); 46 rb_set_parent(node, right);
47
48 if (root->augment_cb) {
49 root->augment_cb(node);
50 root->augment_cb(right);
51 }
52} 47}
53 48
54static void __rb_rotate_right(struct rb_node *node, struct rb_root *root) 49static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
@@ -72,20 +67,12 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
72 else 67 else
73 root->rb_node = left; 68 root->rb_node = left;
74 rb_set_parent(node, left); 69 rb_set_parent(node, left);
75
76 if (root->augment_cb) {
77 root->augment_cb(node);
78 root->augment_cb(left);
79 }
80} 70}
81 71
82void rb_insert_color(struct rb_node *node, struct rb_root *root) 72void rb_insert_color(struct rb_node *node, struct rb_root *root)
83{ 73{
84 struct rb_node *parent, *gparent; 74 struct rb_node *parent, *gparent;
85 75
86 if (root->augment_cb)
87 root->augment_cb(node);
88
89 while ((parent = rb_parent(node)) && rb_is_red(parent)) 76 while ((parent = rb_parent(node)) && rb_is_red(parent))
90 { 77 {
91 gparent = rb_parent(parent); 78 gparent = rb_parent(parent);
@@ -240,15 +227,12 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
240 else 227 else
241 { 228 {
242 struct rb_node *old = node, *left; 229 struct rb_node *old = node, *left;
243 int old_parent_cb = 0;
244 int successor_parent_cb = 0;
245 230
246 node = node->rb_right; 231 node = node->rb_right;
247 while ((left = node->rb_left) != NULL) 232 while ((left = node->rb_left) != NULL)
248 node = left; 233 node = left;
249 234
250 if (rb_parent(old)) { 235 if (rb_parent(old)) {
251 old_parent_cb = 1;
252 if (rb_parent(old)->rb_left == old) 236 if (rb_parent(old)->rb_left == old)
253 rb_parent(old)->rb_left = node; 237 rb_parent(old)->rb_left = node;
254 else 238 else
@@ -263,10 +247,8 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
263 if (parent == old) { 247 if (parent == old) {
264 parent = node; 248 parent = node;
265 } else { 249 } else {
266 successor_parent_cb = 1;
267 if (child) 250 if (child)
268 rb_set_parent(child, parent); 251 rb_set_parent(child, parent);
269
270 parent->rb_left = child; 252 parent->rb_left = child;
271 253
272 node->rb_right = old->rb_right; 254 node->rb_right = old->rb_right;
@@ -277,24 +259,6 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
277 node->rb_left = old->rb_left; 259 node->rb_left = old->rb_left;
278 rb_set_parent(old->rb_left, node); 260 rb_set_parent(old->rb_left, node);
279 261
280 if (root->augment_cb) {
281 /*
282 * Here, three different nodes can have new children.
283 * The parent of the successor node that was selected
284 * to replace the node to be erased.
285 * The node that is getting erased and is now replaced
286 * by its successor.
287 * The parent of the node getting erased-replaced.
288 */
289 if (successor_parent_cb)
290 root->augment_cb(parent);
291
292 root->augment_cb(node);
293
294 if (old_parent_cb)
295 root->augment_cb(rb_parent(old));
296 }
297
298 goto color; 262 goto color;
299 } 263 }
300 264
@@ -303,19 +267,15 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
303 267
304 if (child) 268 if (child)
305 rb_set_parent(child, parent); 269 rb_set_parent(child, parent);
306 270 if (parent)
307 if (parent) { 271 {
308 if (parent->rb_left == node) 272 if (parent->rb_left == node)
309 parent->rb_left = child; 273 parent->rb_left = child;
310 else 274 else
311 parent->rb_right = child; 275 parent->rb_right = child;
312
313 if (root->augment_cb)
314 root->augment_cb(parent);
315
316 } else {
317 root->rb_node = child;
318 } 276 }
277 else
278 root->rb_node = child;
319 279
320 color: 280 color:
321 if (color == RB_BLACK) 281 if (color == RB_BLACK)
@@ -323,6 +283,74 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
323} 283}
324EXPORT_SYMBOL(rb_erase); 284EXPORT_SYMBOL(rb_erase);
325 285
286static void rb_augment_path(struct rb_node *node, rb_augment_f func, void *data)
287{
288 struct rb_node *parent;
289
290up:
291 func(node, data);
292 parent = rb_parent(node);
293 if (!parent)
294 return;
295
296 if (node == parent->rb_left && parent->rb_right)
297 func(parent->rb_right, data);
298 else if (parent->rb_left)
299 func(parent->rb_left, data);
300
301 node = parent;
302 goto up;
303}
304
305/*
306 * after inserting @node into the tree, update the tree to account for
307 * both the new entry and any damage done by rebalance
308 */
309void rb_augment_insert(struct rb_node *node, rb_augment_f func, void *data)
310{
311 if (node->rb_left)
312 node = node->rb_left;
313 else if (node->rb_right)
314 node = node->rb_right;
315
316 rb_augment_path(node, func, data);
317}
318
319/*
320 * before removing the node, find the deepest node on the rebalance path
321 * that will still be there after @node gets removed
322 */
323struct rb_node *rb_augment_erase_begin(struct rb_node *node)
324{
325 struct rb_node *deepest;
326
327 if (!node->rb_right && !node->rb_left)
328 deepest = rb_parent(node);
329 else if (!node->rb_right)
330 deepest = node->rb_left;
331 else if (!node->rb_left)
332 deepest = node->rb_right;
333 else {
334 deepest = rb_next(node);
335 if (deepest->rb_right)
336 deepest = deepest->rb_right;
337 else if (rb_parent(deepest) != node)
338 deepest = rb_parent(deepest);
339 }
340
341 return deepest;
342}
343
344/*
345 * after removal, update the tree to account for the removed entry
346 * and any rebalance damage.
347 */
348void rb_augment_erase_end(struct rb_node *node, rb_augment_f func, void *data)
349{
350 if (node)
351 rb_augment_path(node, func, data);
352}
353
326/* 354/*
327 * This function returns the first node (in sort order) of the tree. 355 * This function returns the first node (in sort order) of the tree.
328 */ 356 */
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 660a87a22511..123bcef13e51 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -104,15 +104,13 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
104 "b_more_io: %8lu\n" 104 "b_more_io: %8lu\n"
105 "bdi_list: %8u\n" 105 "bdi_list: %8u\n"
106 "state: %8lx\n" 106 "state: %8lx\n"
107 "wb_mask: %8lx\n" 107 "wb_list: %8u\n",
108 "wb_list: %8u\n"
109 "wb_cnt: %8u\n",
110 (unsigned long) K(bdi_stat(bdi, BDI_WRITEBACK)), 108 (unsigned long) K(bdi_stat(bdi, BDI_WRITEBACK)),
111 (unsigned long) K(bdi_stat(bdi, BDI_RECLAIMABLE)), 109 (unsigned long) K(bdi_stat(bdi, BDI_RECLAIMABLE)),
112 K(bdi_thresh), K(dirty_thresh), 110 K(bdi_thresh), K(dirty_thresh),
113 K(background_thresh), nr_wb, nr_dirty, nr_io, nr_more_io, 111 K(background_thresh), nr_wb, nr_dirty, nr_io, nr_more_io,
114 !list_empty(&bdi->bdi_list), bdi->state, bdi->wb_mask, 112 !list_empty(&bdi->bdi_list), bdi->state,
115 !list_empty(&bdi->wb_list), bdi->wb_cnt); 113 !list_empty(&bdi->wb_list));
116#undef K 114#undef K
117 115
118 return 0; 116 return 0;
@@ -340,14 +338,13 @@ int bdi_has_dirty_io(struct backing_dev_info *bdi)
340static void bdi_flush_io(struct backing_dev_info *bdi) 338static void bdi_flush_io(struct backing_dev_info *bdi)
341{ 339{
342 struct writeback_control wbc = { 340 struct writeback_control wbc = {
343 .bdi = bdi,
344 .sync_mode = WB_SYNC_NONE, 341 .sync_mode = WB_SYNC_NONE,
345 .older_than_this = NULL, 342 .older_than_this = NULL,
346 .range_cyclic = 1, 343 .range_cyclic = 1,
347 .nr_to_write = 1024, 344 .nr_to_write = 1024,
348 }; 345 };
349 346
350 writeback_inodes_wbc(&wbc); 347 writeback_inodes_wb(&bdi->wb, &wbc);
351} 348}
352 349
353/* 350/*
@@ -675,12 +672,6 @@ int bdi_init(struct backing_dev_info *bdi)
675 672
676 bdi_wb_init(&bdi->wb, bdi); 673 bdi_wb_init(&bdi->wb, bdi);
677 674
678 /*
679 * Just one thread support for now, hard code mask and count
680 */
681 bdi->wb_mask = 1;
682 bdi->wb_cnt = 1;
683
684 for (i = 0; i < NR_BDI_STAT_ITEMS; i++) { 675 for (i = 0; i < NR_BDI_STAT_ITEMS; i++) {
685 err = percpu_counter_init(&bdi->bdi_stat[i], 0); 676 err = percpu_counter_init(&bdi->bdi_stat[i], 0);
686 if (err) 677 if (err)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 54f28bd493d3..37498ef61548 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -495,7 +495,6 @@ static void balance_dirty_pages(struct address_space *mapping,
495 495
496 for (;;) { 496 for (;;) {
497 struct writeback_control wbc = { 497 struct writeback_control wbc = {
498 .bdi = bdi,
499 .sync_mode = WB_SYNC_NONE, 498 .sync_mode = WB_SYNC_NONE,
500 .older_than_this = NULL, 499 .older_than_this = NULL,
501 .nr_to_write = write_chunk, 500 .nr_to_write = write_chunk,
@@ -537,7 +536,7 @@ static void balance_dirty_pages(struct address_space *mapping,
537 * up. 536 * up.
538 */ 537 */
539 if (bdi_nr_reclaimable > bdi_thresh) { 538 if (bdi_nr_reclaimable > bdi_thresh) {
540 writeback_inodes_wbc(&wbc); 539 writeback_inodes_wb(&bdi->wb, &wbc);
541 pages_written += write_chunk - wbc.nr_to_write; 540 pages_written += write_chunk - wbc.nr_to_write;
542 get_dirty_limits(&background_thresh, &dirty_thresh, 541 get_dirty_limits(&background_thresh, &dirty_thresh,
543 &bdi_thresh, bdi); 542 &bdi_thresh, bdi);
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 9d21d98ae5fa..27ae946363f1 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -99,6 +99,15 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get(
99 return NULL; 99 return NULL;
100} 100}
101 101
102static struct net_bridge_mdb_entry *br_mdb_ip_get(
103 struct net_bridge_mdb_htable *mdb, struct br_ip *dst)
104{
105 if (!mdb)
106 return NULL;
107
108 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst));
109}
110
102static struct net_bridge_mdb_entry *br_mdb_ip4_get( 111static struct net_bridge_mdb_entry *br_mdb_ip4_get(
103 struct net_bridge_mdb_htable *mdb, __be32 dst) 112 struct net_bridge_mdb_htable *mdb, __be32 dst)
104{ 113{
@@ -107,7 +116,7 @@ static struct net_bridge_mdb_entry *br_mdb_ip4_get(
107 br_dst.u.ip4 = dst; 116 br_dst.u.ip4 = dst;
108 br_dst.proto = htons(ETH_P_IP); 117 br_dst.proto = htons(ETH_P_IP);
109 118
110 return __br_mdb_ip_get(mdb, &br_dst, __br_ip4_hash(mdb, dst)); 119 return br_mdb_ip_get(mdb, &br_dst);
111} 120}
112 121
113#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 122#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
@@ -119,23 +128,17 @@ static struct net_bridge_mdb_entry *br_mdb_ip6_get(
119 ipv6_addr_copy(&br_dst.u.ip6, dst); 128 ipv6_addr_copy(&br_dst.u.ip6, dst);
120 br_dst.proto = htons(ETH_P_IPV6); 129 br_dst.proto = htons(ETH_P_IPV6);
121 130
122 return __br_mdb_ip_get(mdb, &br_dst, __br_ip6_hash(mdb, dst)); 131 return br_mdb_ip_get(mdb, &br_dst);
123} 132}
124#endif 133#endif
125 134
126static struct net_bridge_mdb_entry *br_mdb_ip_get(
127 struct net_bridge_mdb_htable *mdb, struct br_ip *dst)
128{
129 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst));
130}
131
132struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br, 135struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
133 struct sk_buff *skb) 136 struct sk_buff *skb)
134{ 137{
135 struct net_bridge_mdb_htable *mdb = br->mdb; 138 struct net_bridge_mdb_htable *mdb = br->mdb;
136 struct br_ip ip; 139 struct br_ip ip;
137 140
138 if (!mdb || br->multicast_disabled) 141 if (br->multicast_disabled)
139 return NULL; 142 return NULL;
140 143
141 if (BR_INPUT_SKB_CB(skb)->igmp) 144 if (BR_INPUT_SKB_CB(skb)->igmp)
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 44420992f72f..8fb75f89c4aa 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -591,6 +591,9 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,
591 591
592 pskb_trim_rcsum(skb, len); 592 pskb_trim_rcsum(skb, len);
593 593
594 /* BUG: Should really parse the IP options here. */
595 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
596
594 nf_bridge_put(skb->nf_bridge); 597 nf_bridge_put(skb->nf_bridge);
595 if (!nf_bridge_alloc(skb)) 598 if (!nf_bridge_alloc(skb))
596 return NF_DROP; 599 return NF_DROP;
diff --git a/net/core/dev.c b/net/core/dev.c
index 2b3bf53bc687..723a34710ad4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1553,6 +1553,24 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
1553 rcu_read_unlock(); 1553 rcu_read_unlock();
1554} 1554}
1555 1555
1556/*
1557 * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
1558 * greater then real_num_tx_queues stale skbs on the qdisc must be flushed.
1559 */
1560void netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
1561{
1562 unsigned int real_num = dev->real_num_tx_queues;
1563
1564 if (unlikely(txq > dev->num_tx_queues))
1565 ;
1566 else if (txq > real_num)
1567 dev->real_num_tx_queues = txq;
1568 else if (txq < real_num) {
1569 dev->real_num_tx_queues = txq;
1570 qdisc_reset_all_tx_gt(dev, txq);
1571 }
1572}
1573EXPORT_SYMBOL(netif_set_real_num_tx_queues);
1556 1574
1557static inline void __netif_reschedule(struct Qdisc *q) 1575static inline void __netif_reschedule(struct Qdisc *q)
1558{ 1576{
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index a0f4964033d2..75e4ffeb8cc9 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -318,23 +318,33 @@ out:
318} 318}
319 319
320static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, 320static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
321 void __user *useraddr) 321 u32 cmd, void __user *useraddr)
322{ 322{
323 struct ethtool_rxnfc cmd; 323 struct ethtool_rxnfc info;
324 size_t info_size = sizeof(info);
324 325
325 if (!dev->ethtool_ops->set_rxnfc) 326 if (!dev->ethtool_ops->set_rxnfc)
326 return -EOPNOTSUPP; 327 return -EOPNOTSUPP;
327 328
328 if (copy_from_user(&cmd, useraddr, sizeof(cmd))) 329 /* struct ethtool_rxnfc was originally defined for
330 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
331 * members. User-space might still be using that
332 * definition. */
333 if (cmd == ETHTOOL_SRXFH)
334 info_size = (offsetof(struct ethtool_rxnfc, data) +
335 sizeof(info.data));
336
337 if (copy_from_user(&info, useraddr, info_size))
329 return -EFAULT; 338 return -EFAULT;
330 339
331 return dev->ethtool_ops->set_rxnfc(dev, &cmd); 340 return dev->ethtool_ops->set_rxnfc(dev, &info);
332} 341}
333 342
334static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, 343static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
335 void __user *useraddr) 344 u32 cmd, void __user *useraddr)
336{ 345{
337 struct ethtool_rxnfc info; 346 struct ethtool_rxnfc info;
347 size_t info_size = sizeof(info);
338 const struct ethtool_ops *ops = dev->ethtool_ops; 348 const struct ethtool_ops *ops = dev->ethtool_ops;
339 int ret; 349 int ret;
340 void *rule_buf = NULL; 350 void *rule_buf = NULL;
@@ -342,13 +352,22 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
342 if (!ops->get_rxnfc) 352 if (!ops->get_rxnfc)
343 return -EOPNOTSUPP; 353 return -EOPNOTSUPP;
344 354
345 if (copy_from_user(&info, useraddr, sizeof(info))) 355 /* struct ethtool_rxnfc was originally defined for
356 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
357 * members. User-space might still be using that
358 * definition. */
359 if (cmd == ETHTOOL_GRXFH)
360 info_size = (offsetof(struct ethtool_rxnfc, data) +
361 sizeof(info.data));
362
363 if (copy_from_user(&info, useraddr, info_size))
346 return -EFAULT; 364 return -EFAULT;
347 365
348 if (info.cmd == ETHTOOL_GRXCLSRLALL) { 366 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
349 if (info.rule_cnt > 0) { 367 if (info.rule_cnt > 0) {
350 rule_buf = kmalloc(info.rule_cnt * sizeof(u32), 368 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
351 GFP_USER); 369 rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
370 GFP_USER);
352 if (!rule_buf) 371 if (!rule_buf)
353 return -ENOMEM; 372 return -ENOMEM;
354 } 373 }
@@ -359,7 +378,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
359 goto err_out; 378 goto err_out;
360 379
361 ret = -EFAULT; 380 ret = -EFAULT;
362 if (copy_to_user(useraddr, &info, sizeof(info))) 381 if (copy_to_user(useraddr, &info, info_size))
363 goto err_out; 382 goto err_out;
364 383
365 if (rule_buf) { 384 if (rule_buf) {
@@ -1516,12 +1535,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1516 case ETHTOOL_GRXCLSRLCNT: 1535 case ETHTOOL_GRXCLSRLCNT:
1517 case ETHTOOL_GRXCLSRULE: 1536 case ETHTOOL_GRXCLSRULE:
1518 case ETHTOOL_GRXCLSRLALL: 1537 case ETHTOOL_GRXCLSRLALL:
1519 rc = ethtool_get_rxnfc(dev, useraddr); 1538 rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1520 break; 1539 break;
1521 case ETHTOOL_SRXFH: 1540 case ETHTOOL_SRXFH:
1522 case ETHTOOL_SRXCLSRLDEL: 1541 case ETHTOOL_SRXCLSRLDEL:
1523 case ETHTOOL_SRXCLSRLINS: 1542 case ETHTOOL_SRXCLSRLINS:
1524 rc = ethtool_set_rxnfc(dev, useraddr); 1543 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1525 break; 1544 break;
1526 case ETHTOOL_GGRO: 1545 case ETHTOOL_GGRO:
1527 rc = ethtool_get_gro(dev, useraddr); 1546 rc = ethtool_get_gro(dev, useraddr);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 1705476670ef..23883a48ebfb 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -108,6 +108,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
108 u8 *xprth = skb_network_header(skb) + iph->ihl * 4; 108 u8 *xprth = skb_network_header(skb) + iph->ihl * 4;
109 109
110 memset(fl, 0, sizeof(struct flowi)); 110 memset(fl, 0, sizeof(struct flowi));
111 fl->mark = skb->mark;
112
111 if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { 113 if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) {
112 switch (iph->protocol) { 114 switch (iph->protocol) {
113 case IPPROTO_UDP: 115 case IPPROTO_UDP:
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
index 47d227713758..2933396e0281 100644
--- a/net/ipv6/netfilter/ip6t_REJECT.c
+++ b/net/ipv6/netfilter/ip6t_REJECT.c
@@ -97,9 +97,11 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
97 fl.fl_ip_dport = otcph.source; 97 fl.fl_ip_dport = otcph.source;
98 security_skb_classify_flow(oldskb, &fl); 98 security_skb_classify_flow(oldskb, &fl);
99 dst = ip6_route_output(net, NULL, &fl); 99 dst = ip6_route_output(net, NULL, &fl);
100 if (dst == NULL) 100 if (dst == NULL || dst->error) {
101 dst_release(dst);
101 return; 102 return;
102 if (dst->error || xfrm_lookup(net, &dst, &fl, NULL, 0)) 103 }
104 if (xfrm_lookup(net, &dst, &fl, NULL, 0))
103 return; 105 return;
104 106
105 hh_len = (dst->dev->hard_header_len + 15)&~15; 107 hh_len = (dst->dev->hard_header_len + 15)&~15;
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 4a0e77e14468..6baeabbbca82 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -124,6 +124,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
124 u8 nexthdr = nh[IP6CB(skb)->nhoff]; 124 u8 nexthdr = nh[IP6CB(skb)->nhoff];
125 125
126 memset(fl, 0, sizeof(struct flowi)); 126 memset(fl, 0, sizeof(struct flowi));
127 fl->mark = skb->mark;
128
127 ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr); 129 ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr);
128 ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr); 130 ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr);
129 131
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index f8779006986d..f6127b9f5aca 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -503,6 +503,11 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
503 strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || 503 strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 ||
504 strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0) 504 strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0)
505 return 1; 505 return 1;
506 if (info->hdr->e_machine == EM_PPC64)
507 /* Special register function linked on all modules during final link of .ko */
508 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 ||
509 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0)
510 return 1;
506 /* Do not ignore this symbol */ 511 /* Do not ignore this symbol */
507 return 0; 512 return 0;
508} 513}