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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc

* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (36 commits)
powerpc/gc/wii: Remove get_irq_desc()
powerpc/gc/wii: hlwd-pic: convert irq_desc.lock to raw_spinlock
powerpc/gamecube/wii: Fix off-by-one error in ugecon/usbgecko_udbg
powerpc/mpic: Fix problem that affinity is not updated
powerpc/mm: Fix stupid bug in subpge protection handling
powerpc/iseries: use DECLARE_COMPLETION_ONSTACK for non-constant completion
powerpc: Fix MSI support on U4 bridge PCIe slot
powerpc: Handle VSX alignment faults correctly in little-endian mode
powerpc/mm: Fix typo of cpumask_clear_cpu()
powerpc/mm: Fix hash_utils_64.c compile errors with DEBUG enabled.
powerpc: Convert BUG() to use unreachable()
powerpc/pseries: Make declarations of cpu_hotplug_driver_lock() ANSI compatible.
powerpc/pseries: Don't panic when H_PROD fails during cpu-online.
powerpc/mm: Fix a WARN_ON() with CONFIG_DEBUG_PAGEALLOC and CONFIG_DEBUG_VM
powerpc/defconfigs: Set HZ=100 on pseries and ppc64 defconfigs
powerpc/defconfigs: Disable token ring in powerpc defconfigs
powerpc/defconfigs: Reduce 64bit vmlinux by making acenic and cramfs modules
powerpc/pseries: Select XICS and PCI_MSI PSERIES
powerpc/85xx: Wrong variable returned on error
powerpc/iseries: Convert to proc_fops
...

+879 -181
+42
Documentation/powerpc/dts-bindings/fsl/mpic.txt
··· 1 + * OpenPIC and its interrupt numbers on Freescale's e500/e600 cores 2 + 3 + The OpenPIC specification does not specify which interrupt source has to 4 + become which interrupt number. This is up to the software implementation 5 + of the interrupt controller. The only requirement is that every 6 + interrupt source has to have an unique interrupt number / vector number. 7 + To accomplish this the current implementation assigns the number zero to 8 + the first source, the number one to the second source and so on until 9 + all interrupt sources have their unique number. 10 + Usually the assigned vector number equals the interrupt number mentioned 11 + in the documentation for a given core / CPU. This is however not true 12 + for the e500 cores (MPC85XX CPUs) where the documentation distinguishes 13 + between internal and external interrupt sources and starts counting at 14 + zero for both of them. 15 + 16 + So what to write for external interrupt source X or internal interrupt 17 + source Y into the device tree? Here is an example: 18 + 19 + The memory map for the interrupt controller in the MPC8544[0] shows, 20 + that the first interrupt source starts at 0x5_0000 (PIC Register Address 21 + Map-Interrupt Source Configuration Registers). This source becomes the 22 + number zero therefore: 23 + External interrupt 0 = interrupt number 0 24 + External interrupt 1 = interrupt number 1 25 + External interrupt 2 = interrupt number 2 26 + ... 27 + Every interrupt number allocates 0x20 bytes register space. So to get 28 + its number it is sufficient to shift the lower 16bits to right by five. 29 + So for the external interrupt 10 we have: 30 + 0x0140 >> 5 = 10 31 + 32 + After the external sources, the internal sources follow. The in core I2C 33 + controller on the MPC8544 for instance has the internal source number 34 + 27. Oo obtain its interrupt number we take the lower 16bits of its memory 35 + address (0x5_0560) and shift it right: 36 + 0x0560 >> 5 = 43 37 + 38 + Therefore the I2C device node for the MPC8544 CPU has to have the 39 + interrupt number 43 specified in the device tree. 40 + 41 + [0] MPC8544E PowerQUICCTM III, Integrated Host Processor Family Reference Manual 42 + MPC8544ERM Rev. 1 10/2007
+51 -1
arch/powerpc/boot/dts/katmai.dts
··· 108 108 dcr-reg = <0x00c 0x002>; 109 109 }; 110 110 111 + MQ0: mq { 112 + compatible = "ibm,mq-440spe"; 113 + dcr-reg = <0x040 0x020>; 114 + }; 115 + 111 116 plb { 112 117 compatible = "ibm,plb-440spe", "ibm,plb-440gp", "ibm,plb4"; 113 118 #address-cells = <2>; 114 119 #size-cells = <1>; 115 120 /* addr-child addr-parent size */ 116 - ranges = <0x4 0xe0000000 0x4 0xe0000000 0x20000000 121 + ranges = <0x4 0x00100000 0x4 0x00100000 0x00001000 122 + 0x4 0x00200000 0x4 0x00200000 0x00000400 123 + 0x4 0xe0000000 0x4 0xe0000000 0x20000000 117 124 0xc 0x00000000 0xc 0x00000000 0x20000000 118 125 0xd 0x00000000 0xd 0x00000000 0x80000000 119 126 0xd 0x80000000 0xd 0x80000000 0x80000000 ··· 406 399 0x0 0x0 0x0 0x2 &UIC3 0x9 0x4 /* swizzled int B */ 407 400 0x0 0x0 0x0 0x3 &UIC3 0xa 0x4 /* swizzled int C */ 408 401 0x0 0x0 0x0 0x4 &UIC3 0xb 0x4 /* swizzled int D */>; 402 + }; 403 + 404 + I2O: i2o@400100000 { 405 + compatible = "ibm,i2o-440spe"; 406 + reg = <0x00000004 0x00100000 0x100>; 407 + dcr-reg = <0x060 0x020>; 408 + }; 409 + 410 + DMA0: dma0@400100100 { 411 + compatible = "ibm,dma-440spe"; 412 + cell-index = <0>; 413 + reg = <0x00000004 0x00100100 0x100>; 414 + dcr-reg = <0x060 0x020>; 415 + interrupt-parent = <&DMA0>; 416 + interrupts = <0 1>; 417 + #interrupt-cells = <1>; 418 + #address-cells = <0>; 419 + #size-cells = <0>; 420 + interrupt-map = < 421 + 0 &UIC0 0x14 4 422 + 1 &UIC1 0x16 4>; 423 + }; 424 + 425 + DMA1: dma1@400100200 { 426 + compatible = "ibm,dma-440spe"; 427 + cell-index = <1>; 428 + reg = <0x00000004 0x00100200 0x100>; 429 + dcr-reg = <0x060 0x020>; 430 + interrupt-parent = <&DMA1>; 431 + interrupts = <0 1>; 432 + #interrupt-cells = <1>; 433 + #address-cells = <0>; 434 + #size-cells = <0>; 435 + interrupt-map = < 436 + 0 &UIC0 0x16 4 437 + 1 &UIC1 0x16 4>; 438 + }; 439 + 440 + xor-accel@400200000 { 441 + compatible = "amcc,xor-accelerator"; 442 + reg = <0x00000004 0x00200000 0x400>; 443 + interrupt-parent = <&UIC1>; 444 + interrupts = <0x1f 4>; 409 445 }; 410 446 }; 411 447
+27
arch/powerpc/boot/dts/mpc8315erdb.dts
··· 204 204 interrupt-parent = <&ipic>; 205 205 tbi-handle = <&tbi0>; 206 206 phy-handle = < &phy0 >; 207 + fsl,magic-packet; 207 208 208 209 mdio@520 { 209 210 #address-cells = <1>; ··· 247 246 interrupt-parent = <&ipic>; 248 247 tbi-handle = <&tbi1>; 249 248 phy-handle = < &phy1 >; 249 + fsl,magic-packet; 250 250 251 251 mdio@520 { 252 252 #address-cells = <1>; ··· 311 309 interrupt-parent = <&ipic>; 312 310 }; 313 311 312 + gtm1: timer@500 { 313 + compatible = "fsl,mpc8315-gtm", "fsl,gtm"; 314 + reg = <0x500 0x100>; 315 + interrupts = <90 8 78 8 84 8 72 8>; 316 + interrupt-parent = <&ipic>; 317 + clock-frequency = <133333333>; 318 + }; 319 + 320 + timer@600 { 321 + compatible = "fsl,mpc8315-gtm", "fsl,gtm"; 322 + reg = <0x600 0x100>; 323 + interrupts = <91 8 79 8 85 8 73 8>; 324 + interrupt-parent = <&ipic>; 325 + clock-frequency = <133333333>; 326 + }; 327 + 314 328 /* IPIC 315 329 * interrupts cell = <intr #, sense> 316 330 * sense values match linux IORESOURCE_IRQ_* defines: ··· 354 336 0x58 0x8 355 337 0x59 0x8>; 356 338 interrupt-parent = < &ipic >; 339 + }; 340 + 341 + pmc: power@b00 { 342 + compatible = "fsl,mpc8315-pmc", "fsl,mpc8313-pmc", 343 + "fsl,mpc8349-pmc"; 344 + reg = <0xb00 0x100 0xa00 0x100>; 345 + interrupts = <80 8>; 346 + interrupt-parent = <&ipic>; 347 + fsl,mpc8313-wakeup-timer = <&gtm1>; 357 348 }; 358 349 }; 359 350
+81 -1
arch/powerpc/boot/dts/mpc8349emitx.dts
··· 63 63 reg = <0x200 0x100>; 64 64 }; 65 65 66 + gpio1: gpio-controller@c00 { 67 + #gpio-cells = <2>; 68 + compatible = "fsl,mpc8349-gpio"; 69 + reg = <0xc00 0x100>; 70 + interrupts = <74 0x8>; 71 + interrupt-parent = <&ipic>; 72 + gpio-controller; 73 + }; 74 + 75 + gpio2: gpio-controller@d00 { 76 + #gpio-cells = <2>; 77 + compatible = "fsl,mpc8349-gpio"; 78 + reg = <0xd00 0x100>; 79 + interrupts = <75 0x8>; 80 + interrupt-parent = <&ipic>; 81 + gpio-controller; 82 + }; 83 + 66 84 i2c@3000 { 67 85 #address-cells = <1>; 68 86 #size-cells = <0>; ··· 90 72 interrupts = <14 0x8>; 91 73 interrupt-parent = <&ipic>; 92 74 dfsrr; 75 + 76 + eeprom: at24@50 { 77 + compatible = "st-micro,24c256"; 78 + reg = <0x50>; 79 + }; 80 + 93 81 }; 94 82 95 83 i2c@3100 { ··· 113 89 reg = <0x68>; 114 90 interrupts = <18 0x8>; 115 91 interrupt-parent = <&ipic>; 92 + }; 93 + 94 + pcf1: iexp@38 { 95 + #gpio-cells = <2>; 96 + compatible = "ti,pcf8574a"; 97 + reg = <0x38>; 98 + gpio-controller; 99 + }; 100 + 101 + pcf2: iexp@39 { 102 + #gpio-cells = <2>; 103 + compatible = "ti,pcf8574a"; 104 + reg = <0x39>; 105 + gpio-controller; 106 + }; 107 + 108 + spd: at24@51 { 109 + compatible = "at24,spd"; 110 + reg = <0x51>; 116 111 }; 117 112 118 113 mcu_pio: mcu@a { ··· 318 275 reg = <0x700 0x100>; 319 276 device_type = "ipic"; 320 277 }; 278 + 279 + gpio-leds { 280 + compatible = "gpio-leds"; 281 + 282 + green { 283 + label = "Green"; 284 + gpios = <&pcf1 0 1>; 285 + linux,default-trigger = "heartbeat"; 286 + }; 287 + 288 + yellow { 289 + label = "Yellow"; 290 + gpios = <&pcf1 1 1>; 291 + /* linux,default-trigger = "heartbeat"; */ 292 + default-state = "on"; 293 + }; 294 + }; 295 + 321 296 }; 322 297 323 298 pci0: pci@e0008500 { ··· 392 331 compatible = "fsl,mpc8349e-localbus", 393 332 "fsl,pq2pro-localbus"; 394 333 reg = <0xe0005000 0xd8>; 395 - ranges = <0x3 0x0 0xf0000000 0x210>; 334 + ranges = <0x0 0x0 0xfe000000 0x1000000 /* flash */ 335 + 0x1 0x0 0xf8000000 0x20000 /* VSC 7385 */ 336 + 0x2 0x0 0xf9000000 0x200000 /* exp slot */ 337 + 0x3 0x0 0xf0000000 0x210>; /* CF slot */ 338 + 339 + flash@0,0 { 340 + compatible = "cfi-flash"; 341 + reg = <0x0 0x0 0x800000>; 342 + bank-width = <2>; 343 + device-width = <1>; 344 + }; 345 + 346 + flash@0,800000 { 347 + #address-cells = <1>; 348 + #size-cells = <1>; 349 + compatible = "cfi-flash"; 350 + reg = <0x0 0x800000 0x800000>; 351 + bank-width = <2>; 352 + device-width = <1>; 353 + }; 396 354 397 355 pata@3,0 { 398 356 compatible = "fsl,mpc8349emitx-pata", "ata-generic";
+1 -1
arch/powerpc/boot/dts/warp.dts
··· 146 146 147 147 fpga@2,4000 { 148 148 compatible = "pika,fpga-sd"; 149 - reg = <0x00000002 0x00004000 0x00000A00>; 149 + reg = <0x00000002 0x00004000 0x00004000>; 150 150 }; 151 151 152 152 nor@0,0 {
+1 -1
arch/powerpc/boot/ugecon.c
··· 86 86 87 87 while (!ug_is_txfifo_ready() && count--) 88 88 barrier(); 89 - if (count) 89 + if (count >= 0) 90 90 ug_raw_putc(ch); 91 91 } 92 92
+3 -3
arch/powerpc/configs/g5_defconfig
··· 757 757 # CONFIG_B44 is not set 758 758 # CONFIG_ATL2 is not set 759 759 CONFIG_NETDEV_1000=y 760 - CONFIG_ACENIC=y 760 + CONFIG_ACENIC=m 761 761 CONFIG_ACENIC_OMIT_TIGON_I=y 762 762 # CONFIG_DL2K is not set 763 763 CONFIG_E1000=y ··· 794 794 # CONFIG_BNX2X is not set 795 795 # CONFIG_QLGE is not set 796 796 # CONFIG_SFC is not set 797 - CONFIG_TR=y 798 - CONFIG_IBMOL=y 797 + # CONFIG_TR is not set 798 + # CONFIG_IBMOL is not set 799 799 # CONFIG_3C359 is not set 800 800 # CONFIG_TMS380TR is not set 801 801
+2 -2
arch/powerpc/configs/iseries_defconfig
··· 714 714 # CONFIG_BNX2X is not set 715 715 # CONFIG_QLGE is not set 716 716 # CONFIG_SFC is not set 717 - CONFIG_TR=y 718 - CONFIG_IBMOL=y 717 + # CONFIG_TR is not set 718 + # CONFIG_IBMOL is not set 719 719 # CONFIG_3C359 is not set 720 720 # CONFIG_TMS380TR is not set 721 721
+7 -7
arch/powerpc/configs/ppc64_defconfig
··· 304 304 CONFIG_NO_HZ=y 305 305 CONFIG_HIGH_RES_TIMERS=y 306 306 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 307 - # CONFIG_HZ_100 is not set 308 - CONFIG_HZ_250=y 307 + CONFIG_HZ_100=y 308 + # CONFIG_HZ_250 is not set 309 309 # CONFIG_HZ_300 is not set 310 310 # CONFIG_HZ_1000 is not set 311 - CONFIG_HZ=250 311 + CONFIG_HZ=100 312 312 CONFIG_SCHED_HRTICK=y 313 313 CONFIG_PREEMPT_NONE=y 314 314 # CONFIG_PREEMPT_VOLUNTARY is not set ··· 980 980 # CONFIG_SC92031 is not set 981 981 # CONFIG_ATL2 is not set 982 982 CONFIG_NETDEV_1000=y 983 - CONFIG_ACENIC=y 983 + CONFIG_ACENIC=m 984 984 CONFIG_ACENIC_OMIT_TIGON_I=y 985 985 # CONFIG_DL2K is not set 986 986 CONFIG_E1000=y ··· 1023 1023 # CONFIG_BNX2X is not set 1024 1024 # CONFIG_QLGE is not set 1025 1025 # CONFIG_SFC is not set 1026 - CONFIG_TR=y 1027 - CONFIG_IBMOL=y 1026 + # CONFIG_TR is not set 1027 + # CONFIG_IBMOL is not set 1028 1028 # CONFIG_3C359 is not set 1029 1029 # CONFIG_TMS380TR is not set 1030 1030 ··· 1863 1863 # CONFIG_BEFS_FS is not set 1864 1864 # CONFIG_BFS_FS is not set 1865 1865 # CONFIG_EFS_FS is not set 1866 - CONFIG_CRAMFS=y 1866 + CONFIG_CRAMFS=m 1867 1867 # CONFIG_VXFS_FS is not set 1868 1868 # CONFIG_MINIX_FS is not set 1869 1869 # CONFIG_OMFS_FS is not set
+2 -2
arch/powerpc/configs/ppc64e_defconfig
··· 1008 1008 # CONFIG_QLGE is not set 1009 1009 # CONFIG_SFC is not set 1010 1010 # CONFIG_BE2NET is not set 1011 - CONFIG_TR=y 1012 - CONFIG_IBMOL=y 1011 + # CONFIG_TR is not set 1012 + # CONFIG_IBMOL is not set 1013 1013 # CONFIG_3C359 is not set 1014 1014 # CONFIG_TMS380TR is not set 1015 1015 CONFIG_WLAN=y
+7 -7
arch/powerpc/configs/pseries_defconfig
··· 230 230 CONFIG_NO_HZ=y 231 231 CONFIG_HIGH_RES_TIMERS=y 232 232 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 233 - # CONFIG_HZ_100 is not set 234 - CONFIG_HZ_250=y 233 + CONFIG_HZ_100=y 234 + # CONFIG_HZ_250 is not set 235 235 # CONFIG_HZ_300 is not set 236 236 # CONFIG_HZ_1000 is not set 237 - CONFIG_HZ=250 237 + CONFIG_HZ=100 238 238 CONFIG_SCHED_HRTICK=y 239 239 CONFIG_PREEMPT_NONE=y 240 240 # CONFIG_PREEMPT_VOLUNTARY is not set ··· 796 796 # CONFIG_NET_POCKET is not set 797 797 # CONFIG_ATL2 is not set 798 798 CONFIG_NETDEV_1000=y 799 - CONFIG_ACENIC=y 799 + CONFIG_ACENIC=m 800 800 CONFIG_ACENIC_OMIT_TIGON_I=y 801 801 # CONFIG_DL2K is not set 802 802 CONFIG_E1000=y ··· 834 834 # CONFIG_BNX2X is not set 835 835 # CONFIG_QLGE is not set 836 836 # CONFIG_SFC is not set 837 - CONFIG_TR=y 838 - CONFIG_IBMOL=y 837 + # CONFIG_TR is not set 838 + # CONFIG_IBMOL is not set 839 839 # CONFIG_3C359 is not set 840 840 # CONFIG_TMS380TR is not set 841 841 ··· 1494 1494 # CONFIG_BEFS_FS is not set 1495 1495 # CONFIG_BFS_FS is not set 1496 1496 # CONFIG_EFS_FS is not set 1497 - CONFIG_CRAMFS=y 1497 + CONFIG_CRAMFS=m 1498 1498 # CONFIG_VXFS_FS is not set 1499 1499 # CONFIG_MINIX_FS is not set 1500 1500 # CONFIG_OMFS_FS is not set
+1 -1
arch/powerpc/include/asm/bug.h
··· 68 68 _EMIT_BUG_ENTRY \ 69 69 : : "i" (__FILE__), "i" (__LINE__), \ 70 70 "i" (0), "i" (sizeof(struct bug_entry))); \ 71 - for(;;) ; \ 71 + unreachable(); \ 72 72 } while (0) 73 73 74 74 #define BUG_ON(x) do { \
+1 -4
arch/powerpc/include/asm/gpio.h
··· 38 38 return __gpio_cansleep(gpio); 39 39 } 40 40 41 - /* 42 - * Not implemented, yet. 43 - */ 44 41 static inline int gpio_to_irq(unsigned int gpio) 45 42 { 46 - return -ENOSYS; 43 + return __gpio_to_irq(gpio); 47 44 } 48 45 49 46 static inline int irq_to_gpio(unsigned int irq)
+46 -17
arch/powerpc/kernel/align.c
··· 642 642 */ 643 643 static int emulate_vsx(unsigned char __user *addr, unsigned int reg, 644 644 unsigned int areg, struct pt_regs *regs, 645 - unsigned int flags, unsigned int length) 645 + unsigned int flags, unsigned int length, 646 + unsigned int elsize) 646 647 { 647 648 char *ptr; 649 + unsigned long *lptr; 648 650 int ret = 0; 651 + int sw = 0; 652 + int i, j; 649 653 650 654 flush_vsx_to_thread(current); 651 655 ··· 658 654 else 659 655 ptr = (char *) &current->thread.vr[reg - 32]; 660 656 661 - if (flags & ST) 662 - ret = __copy_to_user(addr, ptr, length); 663 - else { 664 - if (flags & SPLT){ 665 - ret = __copy_from_user(ptr, addr, length); 666 - ptr += length; 657 + lptr = (unsigned long *) ptr; 658 + 659 + if (flags & SW) 660 + sw = elsize-1; 661 + 662 + for (j = 0; j < length; j += elsize) { 663 + for (i = 0; i < elsize; ++i) { 664 + if (flags & ST) 665 + ret |= __put_user(ptr[i^sw], addr + i); 666 + else 667 + ret |= __get_user(ptr[i^sw], addr + i); 667 668 } 668 - ret |= __copy_from_user(ptr, addr, length); 669 + ptr += elsize; 670 + addr += elsize; 669 671 } 670 - if (flags & U) 671 - regs->gpr[areg] = regs->dar; 672 - if (ret) 672 + 673 + if (!ret) { 674 + if (flags & U) 675 + regs->gpr[areg] = regs->dar; 676 + 677 + /* Splat load copies the same data to top and bottom 8 bytes */ 678 + if (flags & SPLT) 679 + lptr[1] = lptr[0]; 680 + /* For 8 byte loads, zero the top 8 bytes */ 681 + else if (!(flags & ST) && (8 == length)) 682 + lptr[1] = 0; 683 + } else 673 684 return -EFAULT; 685 + 674 686 return 1; 675 687 } 676 688 #endif ··· 787 767 788 768 #ifdef CONFIG_VSX 789 769 if ((instruction & 0xfc00003e) == 0x7c000018) { 790 - /* Additional register addressing bit (64 VSX vs 32 FPR/GPR */ 770 + unsigned int elsize; 771 + 772 + /* Additional register addressing bit (64 VSX vs 32 FPR/GPR) */ 791 773 reg |= (instruction & 0x1) << 5; 792 774 /* Simple inline decoder instead of a table */ 775 + /* VSX has only 8 and 16 byte memory accesses */ 776 + nb = 8; 793 777 if (instruction & 0x200) 794 778 nb = 16; 795 - else if (instruction & 0x080) 796 - nb = 8; 797 - else 798 - nb = 4; 779 + 780 + /* Vector stores in little-endian mode swap individual 781 + elements, so process them separately */ 782 + elsize = 4; 783 + if (instruction & 0x80) 784 + elsize = 8; 785 + 799 786 flags = 0; 787 + if (regs->msr & MSR_LE) 788 + flags |= SW; 800 789 if (instruction & 0x100) 801 790 flags |= ST; 802 791 if (instruction & 0x040) ··· 816 787 nb = 8; 817 788 } 818 789 PPC_WARN_ALIGNMENT(vsx, regs); 819 - return emulate_vsx(addr, reg, areg, regs, flags, nb); 790 + return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize); 820 791 } 821 792 #endif 822 793 /* A size of 0 indicates an instruction we don't support, with
+6 -6
arch/powerpc/mm/hash_utils_64.c
··· 340 340 else 341 341 def->tlbiel = 0; 342 342 343 - DBG(" %d: shift=%02x, sllp=%04x, avpnm=%08x, " 343 + DBG(" %d: shift=%02x, sllp=%04lx, avpnm=%08lx, " 344 344 "tlbiel=%d, penc=%d\n", 345 345 idx, shift, def->sllp, def->avpnm, def->tlbiel, 346 346 def->penc); ··· 663 663 base = (unsigned long)__va(lmb.memory.region[i].base); 664 664 size = lmb.memory.region[i].size; 665 665 666 - DBG("creating mapping for region: %lx..%lx (prot: %x)\n", 666 + DBG("creating mapping for region: %lx..%lx (prot: %lx)\n", 667 667 base, size, prot); 668 668 669 669 #ifdef CONFIG_U3_DART ··· 879 879 */ 880 880 int hash_page(unsigned long ea, unsigned long access, unsigned long trap) 881 881 { 882 - void *pgdir; 882 + pgd_t *pgdir; 883 883 unsigned long vsid; 884 884 struct mm_struct *mm; 885 885 pte_t *ptep; ··· 1025 1025 else 1026 1026 #endif /* CONFIG_PPC_HAS_HASH_64K */ 1027 1027 { 1028 - int spp = subpage_protection(pgdir, ea); 1028 + int spp = subpage_protection(mm, ea); 1029 1029 if (access & spp) 1030 1030 rc = -2; 1031 1031 else ··· 1115 1115 { 1116 1116 unsigned long hash, index, shift, hidx, slot; 1117 1117 1118 - DBG_LOW("flush_hash_page(va=%016x)\n", va); 1118 + DBG_LOW("flush_hash_page(va=%016lx)\n", va); 1119 1119 pte_iterate_hashed_subpages(pte, psize, va, index, shift) { 1120 1120 hash = hpt_hash(va, shift, ssize); 1121 1121 hidx = __rpte_to_hidx(pte, index); ··· 1123 1123 hash = ~hash; 1124 1124 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 1125 1125 slot += hidx & _PTEIDX_GROUP_IX; 1126 - DBG_LOW(" sub %d: hash=%x, hidx=%x\n", index, slot, hidx); 1126 + DBG_LOW(" sub %ld: hash=%lx, hidx=%lx\n", index, slot, hidx); 1127 1127 ppc_md.hpte_invalidate(slot, va, psize, ssize, local); 1128 1128 } pte_iterate_hashed_end(); 1129 1129 }
+1 -1
arch/powerpc/mm/mmu_context_nohash.c
··· 353 353 read_lock(&tasklist_lock); 354 354 for_each_process(p) { 355 355 if (p->mm) 356 - cpu_mask_clear_cpu(cpu, mm_cpumask(p->mm)); 356 + cpumask_clear_cpu(cpu, mm_cpumask(p->mm)); 357 357 } 358 358 read_unlock(&tasklist_lock); 359 359 break;
+1 -1
arch/powerpc/mm/pgtable_32.c
··· 382 382 return 0; 383 383 if (!get_pteptr(&init_mm, address, &kpte, &kpmd)) 384 384 return -EINVAL; 385 - set_pte_at(&init_mm, address, kpte, mk_pte(page, prot)); 385 + __set_pte_at(&init_mm, address, kpte, mk_pte(page, prot), 0); 386 386 wmb(); 387 387 #ifdef CONFIG_PPC_STD_MMU 388 388 flush_hash_pages(0, address, pmd_val(*kpmd), 1);
+50 -2
arch/powerpc/platforms/83xx/suspend.c
··· 32 32 #define PMCCR1_NEXT_STATE 0x0C /* Next state for power management */ 33 33 #define PMCCR1_NEXT_STATE_SHIFT 2 34 34 #define PMCCR1_CURR_STATE 0x03 /* Current state for power management*/ 35 + #define IMMR_SYSCR_OFFSET 0x100 35 36 #define IMMR_RCW_OFFSET 0x900 36 37 #define RCW_PCI_HOST 0x80000000 37 38 ··· 79 78 u32 sccr; 80 79 }; 81 80 81 + struct mpc83xx_syscr { 82 + __be32 sgprl; 83 + __be32 sgprh; 84 + __be32 spridr; 85 + __be32 :32; 86 + __be32 spcr; 87 + __be32 sicrl; 88 + __be32 sicrh; 89 + }; 90 + 91 + struct mpc83xx_saved { 92 + u32 sicrl; 93 + u32 sicrh; 94 + u32 sccr; 95 + }; 96 + 82 97 struct pmc_type { 83 98 int has_deep_sleep; 84 99 }; ··· 104 87 static int pmc_irq; 105 88 static struct mpc83xx_pmc __iomem *pmc_regs; 106 89 static struct mpc83xx_clock __iomem *clock_regs; 90 + static struct mpc83xx_syscr __iomem *syscr_regs; 91 + static struct mpc83xx_saved saved_regs; 107 92 static int is_pci_agent, wake_from_pci; 108 93 static phys_addr_t immrbase; 109 94 static int pci_pm_state; ··· 156 137 return ret; 157 138 } 158 139 140 + static void mpc83xx_suspend_restore_regs(void) 141 + { 142 + out_be32(&syscr_regs->sicrl, saved_regs.sicrl); 143 + out_be32(&syscr_regs->sicrh, saved_regs.sicrh); 144 + out_be32(&clock_regs->sccr, saved_regs.sccr); 145 + } 146 + 147 + static void mpc83xx_suspend_save_regs(void) 148 + { 149 + saved_regs.sicrl = in_be32(&syscr_regs->sicrl); 150 + saved_regs.sicrh = in_be32(&syscr_regs->sicrh); 151 + saved_regs.sccr = in_be32(&clock_regs->sccr); 152 + } 153 + 159 154 static int mpc83xx_suspend_enter(suspend_state_t state) 160 155 { 161 156 int ret = -EAGAIN; ··· 199 166 */ 200 167 201 168 if (deep_sleeping) { 169 + mpc83xx_suspend_save_regs(); 170 + 202 171 out_be32(&pmc_regs->mask, PMCER_ALL); 203 172 204 173 out_be32(&pmc_regs->config1, ··· 214 179 in_be32(&pmc_regs->config1) & ~PMCCR1_POWER_OFF); 215 180 216 181 out_be32(&pmc_regs->mask, PMCER_PMCI); 182 + 183 + mpc83xx_suspend_restore_regs(); 217 184 } else { 218 185 out_be32(&pmc_regs->mask, PMCER_PMCI); 219 186 ··· 231 194 return ret; 232 195 } 233 196 234 - static void mpc83xx_suspend_finish(void) 197 + static void mpc83xx_suspend_end(void) 235 198 { 236 199 deep_sleeping = 0; 237 200 } ··· 315 278 .valid = mpc83xx_suspend_valid, 316 279 .begin = mpc83xx_suspend_begin, 317 280 .enter = mpc83xx_suspend_enter, 318 - .finish = mpc83xx_suspend_finish, 281 + .end = mpc83xx_suspend_end, 319 282 }; 320 283 321 284 static int pmc_probe(struct of_device *ofdev, ··· 370 333 goto out_pmc; 371 334 } 372 335 336 + if (has_deep_sleep) { 337 + syscr_regs = ioremap(immrbase + IMMR_SYSCR_OFFSET, 338 + sizeof(*syscr_regs)); 339 + if (!syscr_regs) { 340 + ret = -ENOMEM; 341 + goto out_syscr; 342 + } 343 + } 344 + 373 345 if (is_pci_agent) 374 346 mpc83xx_set_agent(); 375 347 376 348 suspend_set_ops(&mpc83xx_suspend_ops); 377 349 return 0; 378 350 351 + out_syscr: 352 + iounmap(clock_regs); 379 353 out_pmc: 380 354 iounmap(pmc_regs); 381 355 out:
+1 -1
arch/powerpc/platforms/85xx/mpc85xx_mds.c
··· 86 86 scr = phy_read(phydev, MV88E1111_SCR); 87 87 88 88 if (scr < 0) 89 - return err; 89 + return scr; 90 90 91 91 err = phy_write(phydev, MV88E1111_SCR, scr | 0x0008); 92 92
+1 -1
arch/powerpc/platforms/embedded6xx/flipper-pic.c
··· 102 102 irq_hw_number_t hwirq) 103 103 { 104 104 set_irq_chip_data(virq, h->host_data); 105 - get_irq_desc(virq)->status |= IRQ_LEVEL; 105 + irq_to_desc(virq)->status |= IRQ_LEVEL; 106 106 set_irq_chip_and_handler(virq, &flipper_pic, handle_level_irq); 107 107 return 0; 108 108 }
+5 -5
arch/powerpc/platforms/embedded6xx/hlwd-pic.c
··· 95 95 irq_hw_number_t hwirq) 96 96 { 97 97 set_irq_chip_data(virq, h->host_data); 98 - get_irq_desc(virq)->status |= IRQ_LEVEL; 98 + irq_to_desc(virq)->status |= IRQ_LEVEL; 99 99 set_irq_chip_and_handler(virq, &hlwd_pic, handle_level_irq); 100 100 return 0; 101 101 } ··· 132 132 struct irq_host *irq_host = get_irq_data(cascade_virq); 133 133 unsigned int virq; 134 134 135 - spin_lock(&desc->lock); 135 + raw_spin_lock(&desc->lock); 136 136 desc->chip->mask(cascade_virq); /* IRQ_LEVEL */ 137 - spin_unlock(&desc->lock); 137 + raw_spin_unlock(&desc->lock); 138 138 139 139 virq = __hlwd_pic_get_irq(irq_host); 140 140 if (virq != NO_IRQ) ··· 142 142 else 143 143 pr_err("spurious interrupt!\n"); 144 144 145 - spin_lock(&desc->lock); 145 + raw_spin_lock(&desc->lock); 146 146 desc->chip->ack(cascade_virq); /* IRQ_LEVEL */ 147 147 if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask) 148 148 desc->chip->unmask(cascade_virq); 149 - spin_unlock(&desc->lock); 149 + raw_spin_unlock(&desc->lock); 150 150 } 151 151 152 152 /*
+1 -1
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
··· 120 120 121 121 while (!ug_is_txfifo_ready() && count--) 122 122 barrier(); 123 - if (count) 123 + if (count >= 0) 124 124 ug_raw_putc(ch); 125 125 } 126 126
+85 -66
arch/powerpc/platforms/iseries/mf.c
··· 855 855 } 856 856 857 857 #ifdef CONFIG_PROC_FS 858 - 859 - static int proc_mf_dump_cmdline(char *page, char **start, off_t off, 860 - int count, int *eof, void *data) 858 + static int mf_cmdline_proc_show(struct seq_file *m, void *v) 861 859 { 862 - int len; 863 - char *p; 860 + char *page, *p; 864 861 struct vsp_cmd_data vsp_cmd; 865 862 int rc; 866 863 dma_addr_t dma_addr; 867 864 868 865 /* The HV appears to return no more than 256 bytes of command line */ 869 - if (off >= 256) 870 - return 0; 871 - if ((off + count) > 256) 872 - count = 256 - off; 873 - 874 - dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE); 875 - if (dma_addr == DMA_ERROR_CODE) 866 + page = kmalloc(256, GFP_KERNEL); 867 + if (!page) 876 868 return -ENOMEM; 877 - memset(page, 0, off + count); 869 + 870 + dma_addr = iseries_hv_map(page, 256, DMA_FROM_DEVICE); 871 + if (dma_addr == DMA_ERROR_CODE) { 872 + kfree(page); 873 + return -ENOMEM; 874 + } 875 + memset(page, 0, 256); 878 876 memset(&vsp_cmd, 0, sizeof(vsp_cmd)); 879 877 vsp_cmd.cmd = 33; 880 878 vsp_cmd.sub_data.kern.token = dma_addr; 881 879 vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex; 882 - vsp_cmd.sub_data.kern.side = (u64)data; 883 - vsp_cmd.sub_data.kern.length = off + count; 880 + vsp_cmd.sub_data.kern.side = (u64)m->private; 881 + vsp_cmd.sub_data.kern.length = 256; 884 882 mb(); 885 883 rc = signal_vsp_instruction(&vsp_cmd); 886 - iseries_hv_unmap(dma_addr, off + count, DMA_FROM_DEVICE); 887 - if (rc) 884 + iseries_hv_unmap(dma_addr, 256, DMA_FROM_DEVICE); 885 + if (rc) { 886 + kfree(page); 888 887 return rc; 889 - if (vsp_cmd.result_code != 0) 888 + } 889 + if (vsp_cmd.result_code != 0) { 890 + kfree(page); 890 891 return -ENOMEM; 892 + } 891 893 p = page; 892 - len = 0; 893 - while (len < (off + count)) { 894 - if ((*p == '\0') || (*p == '\n')) { 895 - if (*p == '\0') 896 - *p = '\n'; 897 - p++; 898 - len++; 899 - *eof = 1; 894 + while (p - page < 256) { 895 + if (*p == '\0' || *p == '\n') { 896 + *p = '\n'; 900 897 break; 901 898 } 902 899 p++; 903 - len++; 904 - } 905 900 906 - if (len < off) { 907 - *eof = 1; 908 - len = 0; 909 901 } 910 - return len; 902 + seq_write(m, page, p - page); 903 + kfree(page); 904 + return 0; 905 + } 906 + 907 + static int mf_cmdline_proc_open(struct inode *inode, struct file *file) 908 + { 909 + return single_open(file, mf_cmdline_proc_show, PDE(inode)->data); 911 910 } 912 911 913 912 #if 0 ··· 961 962 } 962 963 #endif 963 964 964 - static int proc_mf_dump_side(char *page, char **start, off_t off, 965 - int count, int *eof, void *data) 965 + static int mf_side_proc_show(struct seq_file *m, void *v) 966 966 { 967 - int len; 968 967 char mf_current_side = ' '; 969 968 struct vsp_cmd_data vsp_cmd; 970 969 ··· 986 989 } 987 990 } 988 991 989 - len = sprintf(page, "%c\n", mf_current_side); 990 - 991 - if (len <= (off + count)) 992 - *eof = 1; 993 - *start = page + off; 994 - len -= off; 995 - if (len > count) 996 - len = count; 997 - if (len < 0) 998 - len = 0; 999 - return len; 992 + seq_printf(m, "%c\n", mf_current_side); 993 + return 0; 1000 994 } 1001 995 1002 - static int proc_mf_change_side(struct file *file, const char __user *buffer, 1003 - unsigned long count, void *data) 996 + static int mf_side_proc_open(struct inode *inode, struct file *file) 997 + { 998 + return single_open(file, mf_side_proc_show, NULL); 999 + } 1000 + 1001 + static ssize_t mf_side_proc_write(struct file *file, const char __user *buffer, 1002 + size_t count, loff_t *pos) 1004 1003 { 1005 1004 char side; 1006 1005 u64 newSide; ··· 1033 1040 1034 1041 return count; 1035 1042 } 1043 + 1044 + static const struct file_operations mf_side_proc_fops = { 1045 + .owner = THIS_MODULE, 1046 + .open = mf_side_proc_open, 1047 + .read = seq_read, 1048 + .llseek = seq_lseek, 1049 + .release = single_release, 1050 + .write = mf_side_proc_write, 1051 + }; 1036 1052 1037 1053 #if 0 1038 1054 static void mf_getSrcHistory(char *buffer, int size) ··· 1089 1087 } 1090 1088 #endif 1091 1089 1092 - static int proc_mf_dump_src(char *page, char **start, off_t off, 1093 - int count, int *eof, void *data) 1090 + static int mf_src_proc_show(struct seq_file *m, void *v) 1094 1091 { 1095 1092 #if 0 1096 1093 int len; ··· 1110 1109 #endif 1111 1110 } 1112 1111 1113 - static int proc_mf_change_src(struct file *file, const char __user *buffer, 1114 - unsigned long count, void *data) 1112 + static int mf_src_proc_open(struct inode *inode, struct file *file) 1113 + { 1114 + return single_open(file, mf_src_proc_show, NULL); 1115 + } 1116 + 1117 + static ssize_t mf_src_proc_write(struct file *file, const char __user *buffer, 1118 + size_t count, loff_t *pos) 1115 1119 { 1116 1120 char stkbuf[10]; 1117 1121 ··· 1141 1135 return count; 1142 1136 } 1143 1137 1144 - static int proc_mf_change_cmdline(struct file *file, const char __user *buffer, 1145 - unsigned long count, void *data) 1138 + static const struct file_operations mf_src_proc_fops = { 1139 + .owner = THIS_MODULE, 1140 + .open = mf_src_proc_open, 1141 + .read = seq_read, 1142 + .llseek = seq_lseek, 1143 + .release = single_release, 1144 + .write = mf_src_proc_write, 1145 + }; 1146 + 1147 + static ssize_t mf_cmdline_proc_write(struct file *file, const char __user *buffer, 1148 + size_t count, loff_t *pos) 1146 1149 { 1150 + void *data = PDE(file->f_path.dentry->d_inode)->data; 1147 1151 struct vsp_cmd_data vsp_cmd; 1148 1152 dma_addr_t dma_addr; 1149 1153 char *page; ··· 1187 1171 out: 1188 1172 return ret; 1189 1173 } 1174 + 1175 + static const struct file_operations mf_cmdline_proc_fops = { 1176 + .owner = THIS_MODULE, 1177 + .open = mf_cmdline_proc_open, 1178 + .read = seq_read, 1179 + .llseek = seq_lseek, 1180 + .release = single_release, 1181 + .write = mf_cmdline_proc_write, 1182 + }; 1190 1183 1191 1184 static ssize_t proc_mf_change_vmlinux(struct file *file, 1192 1185 const char __user *buf, ··· 1271 1246 if (!mf) 1272 1247 return 1; 1273 1248 1274 - ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf); 1249 + ent = proc_create_data("cmdline", S_IRUSR|S_IWUSR, mf, 1250 + &mf_cmdline_proc_fops, (void *)(long)i); 1275 1251 if (!ent) 1276 1252 return 1; 1277 - ent->data = (void *)(long)i; 1278 - ent->read_proc = proc_mf_dump_cmdline; 1279 - ent->write_proc = proc_mf_change_cmdline; 1280 1253 1281 1254 if (i == 3) /* no vmlinux entry for 'D' */ 1282 1255 continue; ··· 1286 1263 return 1; 1287 1264 } 1288 1265 1289 - ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); 1266 + ent = proc_create("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root, 1267 + &mf_side_proc_fops); 1290 1268 if (!ent) 1291 1269 return 1; 1292 - ent->data = (void *)0; 1293 - ent->read_proc = proc_mf_dump_side; 1294 - ent->write_proc = proc_mf_change_side; 1295 1270 1296 - ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); 1271 + ent = proc_create("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root, 1272 + &mf_src_proc_fops); 1297 1273 if (!ent) 1298 1274 return 1; 1299 - ent->data = (void *)0; 1300 - ent->read_proc = proc_mf_dump_src; 1301 - ent->write_proc = proc_mf_change_src; 1302 1275 1303 1276 return 0; 1304 1277 }
+1 -1
arch/powerpc/platforms/iseries/viopath.c
··· 116 116 u16 vlanMap; 117 117 dma_addr_t handle; 118 118 HvLpEvent_Rc hvrc; 119 - DECLARE_COMPLETION(done); 119 + DECLARE_COMPLETION_ONSTACK(done); 120 120 struct device_node *node; 121 121 const char *sysid; 122 122
+2
arch/powerpc/platforms/pseries/Kconfig
··· 2 2 depends on PPC64 && PPC_BOOK3S 3 3 bool "IBM pSeries & new (POWER5-based) iSeries" 4 4 select MPIC 5 + select PCI_MSI 6 + select XICS 5 7 select PPC_I8259 6 8 select PPC_RTAS 7 9 select PPC_RTAS_DAEMON
+248 -6
arch/powerpc/platforms/pseries/cmm.c
··· 38 38 #include <asm/mmu.h> 39 39 #include <asm/pgalloc.h> 40 40 #include <asm/uaccess.h> 41 + #include <linux/memory.h> 41 42 42 43 #include "plpar_wrappers.h" 43 44 44 45 #define CMM_DRIVER_VERSION "1.0.0" 45 46 #define CMM_DEFAULT_DELAY 1 47 + #define CMM_HOTPLUG_DELAY 5 46 48 #define CMM_DEBUG 0 47 49 #define CMM_DISABLE 0 48 50 #define CMM_OOM_KB 1024 49 51 #define CMM_MIN_MEM_MB 256 50 52 #define KB2PAGES(_p) ((_p)>>(PAGE_SHIFT-10)) 51 53 #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) 54 + /* 55 + * The priority level tries to ensure that this notifier is called as 56 + * late as possible to reduce thrashing in the shared memory pool. 57 + */ 58 + #define CMM_MEM_HOTPLUG_PRI 1 59 + #define CMM_MEM_ISOLATE_PRI 15 52 60 53 61 static unsigned int delay = CMM_DEFAULT_DELAY; 62 + static unsigned int hotplug_delay = CMM_HOTPLUG_DELAY; 54 63 static unsigned int oom_kb = CMM_OOM_KB; 55 64 static unsigned int cmm_debug = CMM_DEBUG; 56 65 static unsigned int cmm_disabled = CMM_DISABLE; ··· 74 65 module_param_named(delay, delay, uint, S_IRUGO | S_IWUSR); 75 66 MODULE_PARM_DESC(delay, "Delay (in seconds) between polls to query hypervisor paging requests. " 76 67 "[Default=" __stringify(CMM_DEFAULT_DELAY) "]"); 68 + module_param_named(hotplug_delay, hotplug_delay, uint, S_IRUGO | S_IWUSR); 69 + MODULE_PARM_DESC(delay, "Delay (in seconds) after memory hotplug remove " 70 + "before loaning resumes. " 71 + "[Default=" __stringify(CMM_HOTPLUG_DELAY) "]"); 77 72 module_param_named(oom_kb, oom_kb, uint, S_IRUGO | S_IWUSR); 78 73 MODULE_PARM_DESC(oom_kb, "Amount of memory in kb to free on OOM. " 79 74 "[Default=" __stringify(CMM_OOM_KB) "]"); ··· 105 92 static struct cmm_page_array *cmm_page_list; 106 93 static DEFINE_SPINLOCK(cmm_lock); 107 94 95 + static DEFINE_MUTEX(hotplug_mutex); 96 + static int hotplug_occurred; /* protected by the hotplug mutex */ 97 + 108 98 static struct task_struct *cmm_thread_ptr; 109 99 110 100 /** ··· 126 110 cmm_dbg("Begin request for %ld pages\n", nr); 127 111 128 112 while (nr) { 113 + /* Exit if a hotplug operation is in progress or occurred */ 114 + if (mutex_trylock(&hotplug_mutex)) { 115 + if (hotplug_occurred) { 116 + mutex_unlock(&hotplug_mutex); 117 + break; 118 + } 119 + mutex_unlock(&hotplug_mutex); 120 + } else { 121 + break; 122 + } 123 + 129 124 addr = __get_free_page(GFP_NOIO | __GFP_NOWARN | 130 125 __GFP_NORETRY | __GFP_NOMEMALLOC); 131 126 if (!addr) ··· 146 119 if (!pa || pa->index >= CMM_NR_PAGES) { 147 120 /* Need a new page for the page list. */ 148 121 spin_unlock(&cmm_lock); 149 - npa = (struct cmm_page_array *)__get_free_page(GFP_NOIO | __GFP_NOWARN | 150 - __GFP_NORETRY | __GFP_NOMEMALLOC); 122 + npa = (struct cmm_page_array *)__get_free_page( 123 + GFP_NOIO | __GFP_NOWARN | 124 + __GFP_NORETRY | __GFP_NOMEMALLOC); 151 125 if (!npa) { 152 126 pr_info("%s: Can not allocate new page list\n", __func__); 153 127 free_page(addr); ··· 310 282 while (1) { 311 283 timeleft = msleep_interruptible(delay * 1000); 312 284 313 - if (kthread_should_stop() || timeleft) { 314 - loaned_pages_target = loaned_pages; 285 + if (kthread_should_stop() || timeleft) 315 286 break; 287 + 288 + if (mutex_trylock(&hotplug_mutex)) { 289 + if (hotplug_occurred) { 290 + hotplug_occurred = 0; 291 + mutex_unlock(&hotplug_mutex); 292 + cmm_dbg("Hotplug operation has occurred, " 293 + "loaning activity suspended " 294 + "for %d seconds.\n", 295 + hotplug_delay); 296 + timeleft = msleep_interruptible(hotplug_delay * 297 + 1000); 298 + if (kthread_should_stop() || timeleft) 299 + break; 300 + continue; 301 + } 302 + mutex_unlock(&hotplug_mutex); 303 + } else { 304 + cmm_dbg("Hotplug operation in progress, activity " 305 + "suspended\n"); 306 + continue; 316 307 } 317 308 318 309 cmm_get_mpp(); ··· 461 414 }; 462 415 463 416 /** 417 + * cmm_count_pages - Count the number of pages loaned in a particular range. 418 + * 419 + * @arg: memory_isolate_notify structure with address range and count 420 + * 421 + * Return value: 422 + * 0 on success 423 + **/ 424 + static unsigned long cmm_count_pages(void *arg) 425 + { 426 + struct memory_isolate_notify *marg = arg; 427 + struct cmm_page_array *pa; 428 + unsigned long start = (unsigned long)pfn_to_kaddr(marg->start_pfn); 429 + unsigned long end = start + (marg->nr_pages << PAGE_SHIFT); 430 + unsigned long idx; 431 + 432 + spin_lock(&cmm_lock); 433 + pa = cmm_page_list; 434 + while (pa) { 435 + if ((unsigned long)pa >= start && (unsigned long)pa < end) 436 + marg->pages_found++; 437 + for (idx = 0; idx < pa->index; idx++) 438 + if (pa->page[idx] >= start && pa->page[idx] < end) 439 + marg->pages_found++; 440 + pa = pa->next; 441 + } 442 + spin_unlock(&cmm_lock); 443 + return 0; 444 + } 445 + 446 + /** 447 + * cmm_memory_isolate_cb - Handle memory isolation notifier calls 448 + * @self: notifier block struct 449 + * @action: action to take 450 + * @arg: struct memory_isolate_notify data for handler 451 + * 452 + * Return value: 453 + * NOTIFY_OK or notifier error based on subfunction return value 454 + **/ 455 + static int cmm_memory_isolate_cb(struct notifier_block *self, 456 + unsigned long action, void *arg) 457 + { 458 + int ret = 0; 459 + 460 + if (action == MEM_ISOLATE_COUNT) 461 + ret = cmm_count_pages(arg); 462 + 463 + if (ret) 464 + ret = notifier_from_errno(ret); 465 + else 466 + ret = NOTIFY_OK; 467 + 468 + return ret; 469 + } 470 + 471 + static struct notifier_block cmm_mem_isolate_nb = { 472 + .notifier_call = cmm_memory_isolate_cb, 473 + .priority = CMM_MEM_ISOLATE_PRI 474 + }; 475 + 476 + /** 477 + * cmm_mem_going_offline - Unloan pages where memory is to be removed 478 + * @arg: memory_notify structure with page range to be offlined 479 + * 480 + * Return value: 481 + * 0 on success 482 + **/ 483 + static int cmm_mem_going_offline(void *arg) 484 + { 485 + struct memory_notify *marg = arg; 486 + unsigned long start_page = (unsigned long)pfn_to_kaddr(marg->start_pfn); 487 + unsigned long end_page = start_page + (marg->nr_pages << PAGE_SHIFT); 488 + struct cmm_page_array *pa_curr, *pa_last, *npa; 489 + unsigned long idx; 490 + unsigned long freed = 0; 491 + 492 + cmm_dbg("Memory going offline, searching 0x%lx (%ld pages).\n", 493 + start_page, marg->nr_pages); 494 + spin_lock(&cmm_lock); 495 + 496 + /* Search the page list for pages in the range to be offlined */ 497 + pa_last = pa_curr = cmm_page_list; 498 + while (pa_curr) { 499 + for (idx = (pa_curr->index - 1); (idx + 1) > 0; idx--) { 500 + if ((pa_curr->page[idx] < start_page) || 501 + (pa_curr->page[idx] >= end_page)) 502 + continue; 503 + 504 + plpar_page_set_active(__pa(pa_curr->page[idx])); 505 + free_page(pa_curr->page[idx]); 506 + freed++; 507 + loaned_pages--; 508 + totalram_pages++; 509 + pa_curr->page[idx] = pa_last->page[--pa_last->index]; 510 + if (pa_last->index == 0) { 511 + if (pa_curr == pa_last) 512 + pa_curr = pa_last->next; 513 + pa_last = pa_last->next; 514 + free_page((unsigned long)cmm_page_list); 515 + cmm_page_list = pa_last; 516 + continue; 517 + } 518 + } 519 + pa_curr = pa_curr->next; 520 + } 521 + 522 + /* Search for page list structures in the range to be offlined */ 523 + pa_last = NULL; 524 + pa_curr = cmm_page_list; 525 + while (pa_curr) { 526 + if (((unsigned long)pa_curr >= start_page) && 527 + ((unsigned long)pa_curr < end_page)) { 528 + npa = (struct cmm_page_array *)__get_free_page( 529 + GFP_NOIO | __GFP_NOWARN | 530 + __GFP_NORETRY | __GFP_NOMEMALLOC); 531 + if (!npa) { 532 + spin_unlock(&cmm_lock); 533 + cmm_dbg("Failed to allocate memory for list " 534 + "management. Memory hotplug " 535 + "failed.\n"); 536 + return ENOMEM; 537 + } 538 + memcpy(npa, pa_curr, PAGE_SIZE); 539 + if (pa_curr == cmm_page_list) 540 + cmm_page_list = npa; 541 + if (pa_last) 542 + pa_last->next = npa; 543 + free_page((unsigned long) pa_curr); 544 + freed++; 545 + pa_curr = npa; 546 + } 547 + 548 + pa_last = pa_curr; 549 + pa_curr = pa_curr->next; 550 + } 551 + 552 + spin_unlock(&cmm_lock); 553 + cmm_dbg("Released %ld pages in the search range.\n", freed); 554 + 555 + return 0; 556 + } 557 + 558 + /** 559 + * cmm_memory_cb - Handle memory hotplug notifier calls 560 + * @self: notifier block struct 561 + * @action: action to take 562 + * @arg: struct memory_notify data for handler 563 + * 564 + * Return value: 565 + * NOTIFY_OK or notifier error based on subfunction return value 566 + * 567 + **/ 568 + static int cmm_memory_cb(struct notifier_block *self, 569 + unsigned long action, void *arg) 570 + { 571 + int ret = 0; 572 + 573 + switch (action) { 574 + case MEM_GOING_OFFLINE: 575 + mutex_lock(&hotplug_mutex); 576 + hotplug_occurred = 1; 577 + ret = cmm_mem_going_offline(arg); 578 + break; 579 + case MEM_OFFLINE: 580 + case MEM_CANCEL_OFFLINE: 581 + mutex_unlock(&hotplug_mutex); 582 + cmm_dbg("Memory offline operation complete.\n"); 583 + break; 584 + case MEM_GOING_ONLINE: 585 + case MEM_ONLINE: 586 + case MEM_CANCEL_ONLINE: 587 + break; 588 + } 589 + 590 + if (ret) 591 + ret = notifier_from_errno(ret); 592 + else 593 + ret = NOTIFY_OK; 594 + 595 + return ret; 596 + } 597 + 598 + static struct notifier_block cmm_mem_nb = { 599 + .notifier_call = cmm_memory_cb, 600 + .priority = CMM_MEM_HOTPLUG_PRI 601 + }; 602 + 603 + /** 464 604 * cmm_init - Module initialization 465 605 * 466 606 * Return value: ··· 669 435 if ((rc = cmm_sysfs_register(&cmm_sysdev))) 670 436 goto out_reboot_notifier; 671 437 438 + if (register_memory_notifier(&cmm_mem_nb) || 439 + register_memory_isolate_notifier(&cmm_mem_isolate_nb)) 440 + goto out_unregister_notifier; 441 + 672 442 if (cmm_disabled) 673 443 return rc; 674 444 675 445 cmm_thread_ptr = kthread_run(cmm_thread, NULL, "cmmthread"); 676 446 if (IS_ERR(cmm_thread_ptr)) { 677 447 rc = PTR_ERR(cmm_thread_ptr); 678 - goto out_unregister_sysfs; 448 + goto out_unregister_notifier; 679 449 } 680 450 681 451 return rc; 682 452 683 - out_unregister_sysfs: 453 + out_unregister_notifier: 454 + unregister_memory_notifier(&cmm_mem_nb); 455 + unregister_memory_isolate_notifier(&cmm_mem_isolate_nb); 684 456 cmm_unregister_sysfs(&cmm_sysdev); 685 457 out_reboot_notifier: 686 458 unregister_reboot_notifier(&cmm_reboot_nb); ··· 707 467 kthread_stop(cmm_thread_ptr); 708 468 unregister_oom_notifier(&cmm_oom_nb); 709 469 unregister_reboot_notifier(&cmm_reboot_nb); 470 + unregister_memory_notifier(&cmm_mem_nb); 471 + unregister_memory_isolate_notifier(&cmm_mem_isolate_nb); 710 472 cmm_free_pages(loaned_pages); 711 473 cmm_unregister_sysfs(&cmm_sysdev); 712 474 }
+4 -2
arch/powerpc/platforms/pseries/dlpar.c
··· 346 346 347 347 static DEFINE_MUTEX(pseries_cpu_hotplug_mutex); 348 348 349 - void cpu_hotplug_driver_lock() 349 + void cpu_hotplug_driver_lock(void) 350 + __acquires(pseries_cpu_hotplug_mutex) 350 351 { 351 352 mutex_lock(&pseries_cpu_hotplug_mutex); 352 353 } 353 354 354 - void cpu_hotplug_driver_unlock() 355 + void cpu_hotplug_driver_unlock(void) 356 + __releases(pseries_cpu_hotplug_mutex) 355 357 { 356 358 mutex_unlock(&pseries_cpu_hotplug_mutex); 357 359 }
+2 -2
arch/powerpc/platforms/pseries/smp.c
··· 144 144 hcpuid = get_hard_smp_processor_id(nr); 145 145 rc = plpar_hcall_norets(H_PROD, hcpuid); 146 146 if (rc != H_SUCCESS) 147 - panic("Error: Prod to wake up processor %d Ret= %ld\n", 148 - nr, rc); 147 + printk(KERN_ERR "Error: Prod to wake up processor %d\ 148 + Ret= %ld\n", nr, rc); 149 149 } 150 150 } 151 151
+20 -6
arch/powerpc/sysdev/cpm2_pic.c
··· 143 143 struct irq_desc *desc = irq_to_desc(virq); 144 144 unsigned int vold, vnew, edibit; 145 145 146 - if (flow_type == IRQ_TYPE_NONE) 147 - flow_type = IRQ_TYPE_LEVEL_LOW; 146 + /* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or 147 + * IRQ_TYPE_EDGE_BOTH (default). All others are IRQ_TYPE_EDGE_FALLING 148 + * or IRQ_TYPE_LEVEL_LOW (default) 149 + */ 150 + if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) { 151 + if (flow_type == IRQ_TYPE_NONE) 152 + flow_type = IRQ_TYPE_EDGE_BOTH; 148 153 149 - if (flow_type & IRQ_TYPE_EDGE_RISING) { 150 - printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n", 151 - flow_type); 152 - return -EINVAL; 154 + if (flow_type != IRQ_TYPE_EDGE_BOTH && 155 + flow_type != IRQ_TYPE_EDGE_FALLING) 156 + goto err_sense; 157 + } else { 158 + if (flow_type == IRQ_TYPE_NONE) 159 + flow_type = IRQ_TYPE_LEVEL_LOW; 160 + 161 + if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) 162 + goto err_sense; 153 163 } 154 164 155 165 desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL); ··· 191 181 if (vold != vnew) 192 182 out_be32(&cpm2_intctl->ic_siexr, vnew); 193 183 return 0; 184 + 185 + err_sense: 186 + pr_err("CPM2 PIC: sense type 0x%x not supported\n", flow_type); 187 + return -EINVAL; 194 188 } 195 189 196 190 static struct irq_chip cpm2_pic = {
+6 -2
arch/powerpc/sysdev/fsl_pci.c
··· 464 464 { 465 465 struct pci_controller *hose = pci_bus_to_host(bus); 466 466 struct mpc83xx_pcie_priv *pcie = hose->dn->data; 467 - u8 bus_no = bus->number - hose->first_busno; 468 - u32 dev_base = bus_no << 24 | devfn << 16; 467 + u32 dev_base = bus->number << 24 | devfn << 16; 469 468 int ret; 470 469 471 470 ret = mpc83xx_pcie_exclude_device(bus, devfn); ··· 514 515 static int mpc83xx_pcie_write_config(struct pci_bus *bus, unsigned int devfn, 515 516 int offset, int len, u32 val) 516 517 { 518 + struct pci_controller *hose = pci_bus_to_host(bus); 517 519 void __iomem *cfg_addr; 518 520 519 521 cfg_addr = mpc83xx_pcie_remap_cfg(bus, devfn, offset); 520 522 if (!cfg_addr) 521 523 return PCIBIOS_DEVICE_NOT_FOUND; 524 + 525 + /* PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS */ 526 + if (offset == PCI_PRIMARY_BUS && bus->number == hose->first_busno) 527 + val &= 0xffffff00; 522 528 523 529 switch (len) { 524 530 case 1:
+20 -1
arch/powerpc/sysdev/mpc8xxx_gpio.c
··· 54 54 mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT); 55 55 } 56 56 57 + /* Workaround GPIO 1 errata on MPC8572/MPC8536. The status of GPIOs 58 + * defined as output cannot be determined by reading GPDAT register, 59 + * so we use shadow data register instead. The status of input pins 60 + * is determined by reading GPDAT register. 61 + */ 62 + static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) 63 + { 64 + u32 val; 65 + struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); 66 + struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); 67 + 68 + val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR); 69 + 70 + return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio); 71 + } 72 + 57 73 static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) 58 74 { 59 75 struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); ··· 152 136 gc->ngpio = MPC8XXX_GPIO_PINS; 153 137 gc->direction_input = mpc8xxx_gpio_dir_in; 154 138 gc->direction_output = mpc8xxx_gpio_dir_out; 155 - gc->get = mpc8xxx_gpio_get; 139 + if (of_device_is_compatible(np, "fsl,mpc8572-gpio")) 140 + gc->get = mpc8572_gpio_get; 141 + else 142 + gc->get = mpc8xxx_gpio_get; 156 143 gc->set = mpc8xxx_gpio_set; 157 144 158 145 ret = of_mm_gpiochip_add(np, mm_gc);
+6 -13
arch/powerpc/sysdev/mpic.c
··· 567 567 #endif /* CONFIG_MPIC_U3_HT_IRQS */ 568 568 569 569 #ifdef CONFIG_SMP 570 - static int irq_choose_cpu(unsigned int virt_irq) 570 + static int irq_choose_cpu(const cpumask_t *mask) 571 571 { 572 - cpumask_t mask; 573 572 int cpuid; 574 573 575 - cpumask_copy(&mask, irq_to_desc(virt_irq)->affinity); 576 - if (cpus_equal(mask, CPU_MASK_ALL)) { 574 + if (cpumask_equal(mask, cpu_all_mask)) { 577 575 static int irq_rover; 578 576 static DEFINE_SPINLOCK(irq_rover_lock); 579 577 unsigned long flags; ··· 592 594 593 595 spin_unlock_irqrestore(&irq_rover_lock, flags); 594 596 } else { 595 - cpumask_t tmp; 596 - 597 - cpus_and(tmp, cpu_online_map, mask); 598 - 599 - if (cpus_empty(tmp)) 597 + cpuid = cpumask_first_and(mask, cpu_online_mask); 598 + if (cpuid >= nr_cpu_ids) 600 599 goto do_round_robin; 601 - 602 - cpuid = first_cpu(tmp); 603 600 } 604 601 605 602 return get_hard_smp_processor_id(cpuid); 606 603 } 607 604 #else 608 - static int irq_choose_cpu(unsigned int virt_irq) 605 + static int irq_choose_cpu(const cpumask_t *mask) 609 606 { 610 607 return hard_smp_processor_id(); 611 608 } ··· 809 816 unsigned int src = mpic_irq_to_hw(irq); 810 817 811 818 if (mpic->flags & MPIC_SINGLE_DEST_CPU) { 812 - int cpuid = irq_choose_cpu(irq); 819 + int cpuid = irq_choose_cpu(cpumask); 813 820 814 821 mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid); 815 822 } else {
+10 -1
arch/powerpc/sysdev/mpic_msi.c
··· 39 39 40 40 pr_debug("mpic: found U3, guessing msi allocator setup\n"); 41 41 42 - /* Reserve source numbers we know are reserved in the HW */ 42 + /* Reserve source numbers we know are reserved in the HW. 43 + * 44 + * This is a bit of a mix of U3 and U4 reserves but that's going 45 + * to work fine, we have plenty enugh numbers left so let's just 46 + * mark anything we don't like reserved. 47 + */ 43 48 for (i = 0; i < 8; i++) 44 49 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i); 45 50 ··· 53 48 54 49 for (i = 100; i < 105; i++) 55 50 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i); 51 + 52 + for (i = 124; i < mpic->irq_count; i++) 53 + msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i); 54 + 56 55 57 56 np = NULL; 58 57 while ((np = of_find_all_nodes(np))) {
+39 -7
arch/powerpc/sysdev/mpic_u3msi.c
··· 64 64 return addr; 65 65 } 66 66 67 - static u64 find_ht_magic_addr(struct pci_dev *pdev) 67 + static u64 find_ht_magic_addr(struct pci_dev *pdev, unsigned int hwirq) 68 68 { 69 69 struct pci_bus *bus; 70 70 unsigned int pos; 71 71 72 - for (bus = pdev->bus; bus; bus = bus->parent) { 72 + for (bus = pdev->bus; bus && bus->self; bus = bus->parent) { 73 73 pos = pci_find_ht_capability(bus->self, HT_CAPTYPE_MSI_MAPPING); 74 74 if (pos) 75 75 return read_ht_magic_addr(bus->self, pos); 76 76 } 77 + 78 + return 0; 79 + } 80 + 81 + static u64 find_u4_magic_addr(struct pci_dev *pdev, unsigned int hwirq) 82 + { 83 + struct pci_controller *hose = pci_bus_to_host(pdev->bus); 84 + 85 + /* U4 PCIe MSIs need to write to the special register in 86 + * the bridge that generates interrupts. There should be 87 + * theorically a register at 0xf8005000 where you just write 88 + * the MSI number and that triggers the right interrupt, but 89 + * unfortunately, this is busted in HW, the bridge endian swaps 90 + * the value and hits the wrong nibble in the register. 91 + * 92 + * So instead we use another register set which is used normally 93 + * for converting HT interrupts to MPIC interrupts, which decodes 94 + * the interrupt number as part of the low address bits 95 + * 96 + * This will not work if we ever use more than one legacy MSI in 97 + * a block but we never do. For one MSI or multiple MSI-X where 98 + * each interrupt address can be specified separately, it works 99 + * just fine. 100 + */ 101 + if (of_device_is_compatible(hose->dn, "u4-pcie") || 102 + of_device_is_compatible(hose->dn, "U4-pcie")) 103 + return 0xf8004000 | (hwirq << 4); 77 104 78 105 return 0; 79 106 } ··· 111 84 pr_debug("u3msi: MSI-X untested, trying anyway.\n"); 112 85 113 86 /* If we can't find a magic address then MSI ain't gonna work */ 114 - if (find_ht_magic_addr(pdev) == 0) { 87 + if (find_ht_magic_addr(pdev, 0) == 0 && 88 + find_u4_magic_addr(pdev, 0) == 0) { 115 89 pr_debug("u3msi: no magic address found for %s\n", 116 90 pci_name(pdev)); 117 91 return -ENXIO; ··· 146 118 u64 addr; 147 119 int hwirq; 148 120 149 - addr = find_ht_magic_addr(pdev); 150 - msg.address_lo = addr & 0xFFFFFFFF; 151 - msg.address_hi = addr >> 32; 152 - 153 121 list_for_each_entry(entry, &pdev->msi_list, list) { 154 122 hwirq = msi_bitmap_alloc_hwirqs(&msi_mpic->msi_bitmap, 1); 155 123 if (hwirq < 0) { 156 124 pr_debug("u3msi: failed allocating hwirq\n"); 157 125 return hwirq; 158 126 } 127 + 128 + addr = find_ht_magic_addr(pdev, hwirq); 129 + if (addr == 0) 130 + addr = find_u4_magic_addr(pdev, hwirq); 131 + msg.address_lo = addr & 0xFFFFFFFF; 132 + msg.address_hi = addr >> 32; 159 133 160 134 virq = irq_create_mapping(msi_mpic->irqhost, hwirq); 161 135 if (virq == NO_IRQ) { ··· 173 143 pr_debug("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n", 174 144 virq, hwirq, (unsigned long)addr); 175 145 146 + printk("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n", 147 + virq, hwirq, (unsigned long)addr); 176 148 msg.data = hwirq; 177 149 write_msi_msg(virq, &msg); 178 150
+19
drivers/base/memory.c
··· 63 63 } 64 64 EXPORT_SYMBOL(unregister_memory_notifier); 65 65 66 + static ATOMIC_NOTIFIER_HEAD(memory_isolate_chain); 67 + 68 + int register_memory_isolate_notifier(struct notifier_block *nb) 69 + { 70 + return atomic_notifier_chain_register(&memory_isolate_chain, nb); 71 + } 72 + EXPORT_SYMBOL(register_memory_isolate_notifier); 73 + 74 + void unregister_memory_isolate_notifier(struct notifier_block *nb) 75 + { 76 + atomic_notifier_chain_unregister(&memory_isolate_chain, nb); 77 + } 78 + EXPORT_SYMBOL(unregister_memory_isolate_notifier); 79 + 66 80 /* 67 81 * register_memory - Setup a sysfs device for a memory block 68 82 */ ··· 169 155 int memory_notify(unsigned long val, void *v) 170 156 { 171 157 return blocking_notifier_call_chain(&memory_chain, val, v); 158 + } 159 + 160 + int memory_isolate_notify(unsigned long val, void *v) 161 + { 162 + return atomic_notifier_call_chain(&memory_isolate_chain, val, v); 172 163 } 173 164 174 165 /*
+27
include/linux/memory.h
··· 50 50 int status_change_nid; 51 51 }; 52 52 53 + /* 54 + * During pageblock isolation, count the number of pages within the 55 + * range [start_pfn, start_pfn + nr_pages) which are owned by code 56 + * in the notifier chain. 57 + */ 58 + #define MEM_ISOLATE_COUNT (1<<0) 59 + 60 + struct memory_isolate_notify { 61 + unsigned long start_pfn; /* Start of range to check */ 62 + unsigned int nr_pages; /* # pages in range to check */ 63 + unsigned int pages_found; /* # pages owned found by callbacks */ 64 + }; 65 + 53 66 struct notifier_block; 54 67 struct mem_section; 55 68 ··· 89 76 { 90 77 return 0; 91 78 } 79 + static inline int register_memory_isolate_notifier(struct notifier_block *nb) 80 + { 81 + return 0; 82 + } 83 + static inline void unregister_memory_isolate_notifier(struct notifier_block *nb) 84 + { 85 + } 86 + static inline int memory_isolate_notify(unsigned long val, void *v) 87 + { 88 + return 0; 89 + } 92 90 #else 93 91 extern int register_memory_notifier(struct notifier_block *nb); 94 92 extern void unregister_memory_notifier(struct notifier_block *nb); 93 + extern int register_memory_isolate_notifier(struct notifier_block *nb); 94 + extern void unregister_memory_isolate_notifier(struct notifier_block *nb); 95 95 extern int register_new_memory(int, struct mem_section *); 96 96 extern int unregister_memory_section(struct mem_section *); 97 97 extern int memory_dev_init(void); 98 98 extern int remove_memory_block(unsigned long, struct mem_section *, int); 99 99 extern int memory_notify(unsigned long val, void *v); 100 + extern int memory_isolate_notify(unsigned long val, void *v); 100 101 extern struct memory_block *find_memory_block(struct mem_section *); 101 102 #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) 102 103 enum mem_add_context { BOOT, HOTPLUG };
+52 -9
mm/page_alloc.c
··· 48 48 #include <linux/page_cgroup.h> 49 49 #include <linux/debugobjects.h> 50 50 #include <linux/kmemleak.h> 51 + #include <linux/memory.h> 51 52 #include <trace/events/kmem.h> 52 53 53 54 #include <asm/tlbflush.h> ··· 5009 5008 int set_migratetype_isolate(struct page *page) 5010 5009 { 5011 5010 struct zone *zone; 5012 - unsigned long flags; 5011 + struct page *curr_page; 5012 + unsigned long flags, pfn, iter; 5013 + unsigned long immobile = 0; 5014 + struct memory_isolate_notify arg; 5015 + int notifier_ret; 5013 5016 int ret = -EBUSY; 5014 5017 int zone_idx; 5015 5018 5016 5019 zone = page_zone(page); 5017 5020 zone_idx = zone_idx(zone); 5021 + 5018 5022 spin_lock_irqsave(&zone->lock, flags); 5019 - /* 5020 - * In future, more migrate types will be able to be isolation target. 5021 - */ 5022 - if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE && 5023 - zone_idx != ZONE_MOVABLE) 5023 + if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE || 5024 + zone_idx == ZONE_MOVABLE) { 5025 + ret = 0; 5024 5026 goto out; 5025 - set_pageblock_migratetype(page, MIGRATE_ISOLATE); 5026 - move_freepages_block(zone, page, MIGRATE_ISOLATE); 5027 - ret = 0; 5027 + } 5028 + 5029 + pfn = page_to_pfn(page); 5030 + arg.start_pfn = pfn; 5031 + arg.nr_pages = pageblock_nr_pages; 5032 + arg.pages_found = 0; 5033 + 5034 + /* 5035 + * It may be possible to isolate a pageblock even if the 5036 + * migratetype is not MIGRATE_MOVABLE. The memory isolation 5037 + * notifier chain is used by balloon drivers to return the 5038 + * number of pages in a range that are held by the balloon 5039 + * driver to shrink memory. If all the pages are accounted for 5040 + * by balloons, are free, or on the LRU, isolation can continue. 5041 + * Later, for example, when memory hotplug notifier runs, these 5042 + * pages reported as "can be isolated" should be isolated(freed) 5043 + * by the balloon driver through the memory notifier chain. 5044 + */ 5045 + notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg); 5046 + notifier_ret = notifier_to_errno(notifier_ret); 5047 + if (notifier_ret || !arg.pages_found) 5048 + goto out; 5049 + 5050 + for (iter = pfn; iter < (pfn + pageblock_nr_pages); iter++) { 5051 + if (!pfn_valid_within(pfn)) 5052 + continue; 5053 + 5054 + curr_page = pfn_to_page(iter); 5055 + if (!page_count(curr_page) || PageLRU(curr_page)) 5056 + continue; 5057 + 5058 + immobile++; 5059 + } 5060 + 5061 + if (arg.pages_found == immobile) 5062 + ret = 0; 5063 + 5028 5064 out: 5065 + if (!ret) { 5066 + set_pageblock_migratetype(page, MIGRATE_ISOLATE); 5067 + move_freepages_block(zone, page, MIGRATE_ISOLATE); 5068 + } 5069 + 5029 5070 spin_unlock_irqrestore(&zone->lock, flags); 5030 5071 if (!ret) 5031 5072 drain_all_pages();